调至内容部分
创建账户
或
登录
Stripe 文档徽标
/
询问人工智能
创建账户
登录
开始
付款
销售收入
平台和交易市场
资金管理
开发人员资源
概览
关于 Stripe 支付
升级您的集成
支付分析
线上付款
概览查找您的用例Managed Payments
使用 Payment Link
构建结账页面
构建高级集成
构建应用内集成
支付方式
添加支付方式
    概览
    支付方式集成选项
    在管理平台中管理默认支付方式
    支付方式类型
    银行卡
    使用 Stripe 余额支付
    加密货币
    银行借记
    银行重定向
    银行转账
    贷记转账(来源)
    先买后付
    实时付款
    付款凭单
    钱包
      支付宝
        收款
      Amazon Pay
      Apple Pay
      Cash App Pay
      Google Pay
      GrabPay
      Link
      MB WAY
      MobilePay
      PayPal
      PayPay
      Revolut Pay
      Satispay
      Secure Remote Commerce
      Vipps
      微信支付
    按国家启用本地支付方式
    自定义支付方式
管理支付方式
用 Link 更快结账
支付接口
Payment Links
结账
Web Elements
应用内 Element
支付场景
处理多种货币
自定义支付流程
灵活收单
编排
线下支付
Terminal
超越支付功能
成立公司
加密货币
Financial Connections
Climate
了解欺诈
Radar 欺诈保护
管理争议
验证身份
首页付款Add payment methodsWalletsAlipay

接受支付宝付款

用 Stripe API 和 Checkout 接受支付宝付款,这是中国人广泛使用的一种数字钱包

Alipay 是一种单次使用的支付方式,客户需要验证他们的付款。客户在您的网站或应用程序中被跳转到 Alipay 页面,授权付款,然后返回您的网站或应用,然后在这里收到付款成功或失败的即时通知。

设置 Stripe
服务器端
客户端

首先,您需要有 Stripe 账户。立即注册。

服务器端

该集成要求您的服务器上的端点与 Stripe API 通讯。请用官方库从您的服务器访问 Stripe API:

Command Line
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# Available as a gem sudo gem install stripe
Gemfile
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

客户端

Stripe Android SDK 是开源的,且有完整的文档。

安装 SDK 时,将 stripe-android 添加到您的 app/build.gradle 文件的 dependencies 块中:

build.gradle.kts
Kotlin
Groovy
No results
plugins { id("com.android.application") } android { ... } dependencies { // ... // Stripe Android SDK implementation("com.stripe:stripe-android:21.26.0") // Include the financial connections SDK to support US bank account as a payment method implementation("com.stripe:financial-connections:21.26.0") }

注意

有关最新 SDK 发布及过往版本的详细信息,请查看 GitHub 上的发布页面。要想在新版本发布时接收通知,请查看仓库的发布情况。

用您的 Stripe 公钥配置 SDK,以便它可以向 Stripe API 发送请求,例如在您的 Application 子类中:

Kotlin
Java
No results
import com.stripe.android.PaymentConfiguration class MyApp : Application() { override fun onCreate() { super.onCreate() PaymentConfiguration.init( applicationContext,
"pk_test_TYooMQauvdEDq54NiTphI7jx"
) } }

注意

测试时使用您的测试密钥,发布应用时使用真实模式密钥。

Stripe 的示例还用 OkHttp 和 GSON 向服务器发送了 HTTP 请求。

集成支付宝 SDK
客户端

对于使用支付宝的应用间跳转流程的应用内付款,必须集成支付宝 SDK。如果您不想集成支付宝 SDK,则 Stripe SDK 会用一个 WebView 将客户重定向到支付宝。集成支付宝 SDK 后可为您的客户提供一个更加无缝的使用体验,但会让您的应用程序的下载尺寸变大。更多详情,请查看使用 WebView。

解压后,将 alipaySdk-{version}.aar 添加到您的应用程序的 libs 目录。将 libs 文件夹添加到您的项目的依赖库列表:

build.gradle
allprojects { repositories { flatDir { dirs 'libs' } } }

向应用程序添加依赖:

app/build.gradle
dependencies { // ... // Replace {version} with the version number of the Alipay SDK that you downloaded above implementation(name:"alipaySdk-{version}", ext:"aar") }

创建 PaymentIntent
服务器端

PaymentIntent 是一个用来表示您从客户收款意图的对象,并可用于跟踪付款流程的生命周期。在您的服务器上创建一个 PaymentIntent,并指定要收取的金额和支持的币种。如果您有现成的 Payment Intents 集成,则将 alipay 添加到 payment method types 列表。

Command Line
cURL
Stripe CLI
Ruby
Python
PHP
Java
Node.js
Go
.NET
No results
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "payment_method_types[]"=alipay \ -d amount=1099 \ -d currency=hkd

重定向到支付宝钱包
客户端

从您的服务器请求 PaymentIntent 并保存它的客户端私钥。

Kotlin
Java
No results
class AlipayActivity : AppCompatActivity() { private lateinit var paymentIntentClientSecret: String override fun onCreate(savedInstanceState: Bundle?) { // ... fetchPaymentIntent() } private fun fetchPaymentIntent() { // Request a PaymentIntent from your server and store its client secret } }

当客户点击支付宝进行支付时,用 Stripe confirmAlipayPayment 确认 PaymentIntent。必须提供一个 AlipayAuthenticator 来将来自 Stripe SDK 的数据传递给支付宝 SDK。验证器通过提供的数据字串调用支付宝 payV2 方式。支付宝 SDK 打开支付宝应用程序(若安装),或显示它自己的 UI 并自动将结果返回到 Stripe SDK。

注意

支付宝 Android SDK 不支持测试付款。要全面测试此集成,请使用真实模式。

Kotlin
Java
No results
import com.alipay.sdk.app.PayTask class AlipayActivity : AppCompatActivity() { // ... private lateinit var paymentIntentClientSecret: String private val stripe: Stripe by lazy { Stripe( applicationContext, PaymentConfiguration.getInstance(applicationContext).publishableKey ) } // Call this function when the customer taps "Pay with Alipay" private fun startCheckout() { // ... lifecycleScope.launch { runCatching { stripe.confirmAlipayPayment( ConfirmPaymentIntentParams.createAlipay(paymentIntentClientSecret), { data -> PayTask(this@AlipayActivity).payV2(data, true) } ) }.fold( onSuccess = { result -> val paymentIntent = result.intent val status = paymentIntent.status when (status) { StripeIntent.Status.Succeeded -> { // Payment succeeded } StripeIntent.Status.RequiresAction -> { // Customer didn't complete the payment // You can try to confirm this Payment Intent again } else -> { // Payment failed/canceled } } }, onFailure = { // Payment failed } ) } } }

可选使用 WebView
客户端

可选处理付款后事件

支持的货币

Your account must have a bank account for one of the following currencies. You can create Alipay payments in the currencies that map to your country. The default local currency for Alipay is cny and customers also see their purchase amount in cny.

货币国家/地区
cny任何国家
aud澳大利亚
cad加拿大
eur奥地利、比利时、保加利亚、塞浦路斯、捷克共和国、丹麦、爱沙尼亚、芬兰、法国、德国、希腊、爱尔兰、意大利、拉脱维亚、立陶宛、卢森堡、马耳他、荷兰、挪威、葡萄牙、罗马尼亚、斯洛伐克、斯洛文尼亚、西班牙、瑞典、瑞士
gbp英国
hkd香港
jpy日本
myr马来西亚
nzd新西兰
sgd新加坡
usd美国

如果您拥有以另一种货币开设的银行账户,并希望以该货币创建支付宝支付,可以联系支持服务。我们会根据具体情况为其他货币提供支持服务。

此页面的内容有帮助吗?
是否
  • 需要帮助?联系支持。
  • 加入我们的早期使用计划。
  • 查看我们的更改日志。
  • 有问题?联系销售。
  • LLM? Read llms.txt.
  • Powered by Markdoc