更新记录

1.0.4(2026-06-03)

支持可选启用 Apple Pay / Google Pay

1.0.3(2026-06-03)

修复已知问题

1.0.2(2026-05-26)

修复 uni-app项目 安卓平台无法收到支付回调的问题

查看更多

平台兼容性

uni-app(4.87)

Vue2 Vue2插件版本 Vue3 Vue3插件版本 Chrome Safari app-vue app-vue插件版本 app-nvue app-nvue插件版本 Android Android插件版本 iOS iOS插件版本 鸿蒙
1.0.0 1.0.0 × × 1.0.0 1.0.0 5.0 1.0.0 13 1.0.0 ×
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
× × × × × × × × × × × ×

uni-app x(4.87)

Chrome Safari Android Android插件版本 iOS iOS插件版本 鸿蒙 微信小程序
× × 5.0 1.0.0 13 1.0.0 × ×

tt-stripe-pay

uni-app / uni-app x 的 Stripe PaymentSheet 插件:在 iOS、Android App 内调起原生收银台。需服务端创建 PaymentIntent 并下发 client_secret


1. 接入前必读

  1. 服务端必须用 Secret Key 创建 PaymentIntent,再把 client_secret 和 Publishable Key 下发给 App。
  2. client_secret 和 Publishable Key 必须属于同一 Stripe 账号和同一环境(test / live)。
  3. 含 Stripe 原生依赖时,请使用自定义基座或正式包测试;不要用未集成本插件的标准基座。
  4. success 只表示客户端 PaymentSheet 流程完成;最终支付状态以服务端查询 PaymentIntent 或 Webhook 为准。
  5. Apple Pay / Google Pay 默认关闭;不传 applePay / googlePay 就是普通 PaymentSheet。

2. iOS:外跳回 App(returnURL)

启用会跳出 App 的支付方式时,建议配置自定义 URL Scheme,并传入同 scheme 的 returnURL

  1. utssdk/app-ios/Info.plist 配置 CFBundleURLSchemes
  2. 调用时传入完整 returnURL,如 myapp://stripe-redirect
  3. 挂载 TTStripePayHookProxy,把 iOS open URL 回调交给 Stripe。

只测不外跳的卡支付时,returnURL 可不传。


3. Apple Pay / Google Pay(可选)

iOS:启用 Apple Pay

启用前需要:

  1. 在 Apple Developer 创建 Merchant ID,如 merchant.com.example.app
  2. 为 App ID 启用 Apple Pay,并关联该 Merchant ID。
  3. 在 Stripe Dashboard 配置 Apple Pay iOS certificate。
  4. 复制 utssdk/app-ios/UTS.entitlements.exampleutssdk/app-ios/UTS.entitlements,把 merchant.com.example.app 改为你的 Merchant ID。
  5. 调用 presentPaymentSheet 时传入同一个 merchantId

applePay.merchantCountryCode 是商户业务国家/地区代码,不是用户所在地。

UTS.entitlements 示例:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.developer.in-app-payments</key>
    <array>
        <string>merchant.com.example.app</string>
    </array>
</dict>
</plist>

不需要 Apple Pay 时,不要创建 UTS.entitlements,或不要包含 com.apple.developer.in-app-payments。可以保留有效的空 plist,但不要保留零字节空文件。

Android:启用 Google Pay

插件已声明 Google Pay API:

<meta-data
    android:name="com.google.android.gms.wallet.api.enabled"
    android:value="true" />

调用时传入 googlePay 即可启用。测试环境设置 testEnv: true。不使用 Google Pay 时不需要删除上面的 meta-data;只要不传 googlePay,插件不会启用 Google Pay。

googlePay.merchantCountryCode 是商户业务国家/地区代码。currencyCode 对 PaymentIntent 可选但建议传,对 SetupIntent 必填。Google Pay 需在支持地区用 Android 真机测试,并登录已配置 Google Wallet 的账号。


4. 代码示例

// #ifdef APP-ANDROID || APP-IOS
import { getTTStripePay } from '@/uni_modules/tt-stripe-pay';
// #endif

const stripePay = getTTStripePay();

stripePay.presentPaymentSheet({
    publishableKey: 'pk_test_xxx',
    paymentIntentClientSecret: 'pi_xxx_secret_xxx',
    merchantDisplayName: '我的商户',
    returnURL: 'myapp://stripe-redirect',
    customerId: 'cus_xxx',
    customerEphemeralKeySecret: 'ek_test_xxx',
    // #ifdef APP-IOS
    applePay: {
        merchantId: 'merchant.com.example.app',
        merchantCountryCode: 'US',
    },
    // #endif
    // #ifdef APP-ANDROID
    googlePay: {
        merchantCountryCode: 'US',
        currencyCode: 'USD',
        testEnv: true,
    },
    // #endif
    success: () => {
        /* 建议服务端再查 PaymentIntent */
    },
    fail: (err) => {
        console.error(err.errCode, err.errMsg);
    },
    complete: null,
});

类型见 utssdk/interface.uts


5. API:presentPaymentSheet

参数 必填 说明
publishableKey Stripe Publishable Key,pk_test_ / pk_live_
paymentIntentClientSecret PaymentIntent 的 client_secret
merchantDisplayName 收银台标题,默认 App
returnURL iOS 外跳回 App 的 URL
customerId customerEphemeralKeySecret 成对传入
customerEphemeralKeySecret Customer 的 Ephemeral Key secret
applePay iOS Apple Pay 配置;不传则不启用
googlePay Android Google Pay 配置;不传则不启用
success / fail / complete 回调;取消走 failerrCode102

applePay

参数 必填 说明
merchantId Apple Merchant ID;须与 UTS.entitlements 一致
merchantCountryCode 商户业务国家/地区代码,如 USSG

googlePay

参数 必填 说明
merchantCountryCode 商户业务国家/地区代码,如 USSG
currencyCode 币种代码,如 USDSGD;PaymentIntent 可选,SetupIntent 必填
testEnv true 使用 Test 环境;默认 false 使用 Production

6. 演示联调(可选)

Stripe 官方示例后端:

  • POST https://stripe-mobile-payment-sheet.stripedemos.com/checkout
  • 响应含 publishableKeypaymentIntentcustomerephemeralKey
  • 演示 returnURLpayments-example://stripe-redirect,iOS 需保留或追加 payments-example scheme。
  • 该接口不下发 Apple Pay / Google Pay 配置;钱包测试需手动填写参数。

tt-stripe-demo 内「拉取官方演示数据」可一键填入。


7. 错误码(errSubject: TTStripePay

errCode 说明
100 参数无效
102 用户取消 / 关闭收银台
103 iOS 无法取得 UIViewController
104 Android 无法取得 Activity
105 Android 无法取得 Application Context
106 Android PaymentSheet 未就绪
999 Stripe 或其它错误(见 errMsg
1000 平台不支持

8. 常见问题

问题 处理
iOS 一点支付就崩 检查 PI 是否关联 Customer 但未传 customerId + customerEphemeralKeySecret;再检查是否用了未集成插件的标准基座。
Apple Pay 不显示 检查 applePayUTS.entitlements、Merchant ID、provisioning profile、设备和银行卡。
Google Pay 不显示 检查 googlePay、国家/币种、Android 真机、Google Wallet;生产环境还需完成 Google Pay 发布配置。
能否只在客户端收款 不能,PaymentIntent 必须由服务端创建。
客户端 success 是否等于到账 不一定,以服务端状态与 Webhook 为准。

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率: