如何在Stripe SetupIntent中集成Google Pay与Apple Pay支付方式?
Stripe SetupIntent集成Google Pay/Apple Pay方案
可用性确认
Google Pay和Apple Pay均支持通过Stripe SetupIntent用于后续支付,二者属于基于card支付方式的数字钱包方案,Stripe会自动完成底层适配,不需要单独添加专属的支付方式类型。
集成步骤
前置配置
- 在Stripe后台启用Google Pay和Apple Pay功能
- 配置允许使用钱包支付的域名(在Stripe后台支付设置中完成)
后端代码调整
无需修改payment_method_types字段,保留card即可(数字钱包支付会通过card通道处理),原代码只需确保包含card类型。若需针对钱包支付做额外配置,可在payment_method_options中添加card相关参数,示例如下:$setupIntents = $stripe->setupIntents->create([ 'customer' => $customer_id, 'description' => 'abcdefgh', 'payment_method_types' => ['card', 'sepa_debit', 'ideal', 'bancontact'], 'metadata' => [ "lastname" => $item->name, "email" => $item->email, ], // 可选:针对card类型(含钱包支付)配置额外选项 'payment_method_options' => [ 'card' => [ 'request_three_d_secure' => 'automatic', ], ], ], [ 'idempotency_key' => vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4)), ]);前端适配
必须使用Stripe官方的Elements组件(如Payment Element或Wallet Element)渲染Google Pay/Apple Pay选择按钮,前端通过SetupIntent的client_secret完成支付流程初始化,Stripe会自动检测用户设备并显示对应钱包支付选项。
内容的提问来源于stack exchange,提问作者maidan
相关产品推荐
相关产品推荐

