简体   繁体   English

Stripe Connect – 启用 Apple Pay?

[英]Stripe Connect – enable Apple Pay?

I'm trying to make Stripe Connect accounts accept payments in my app with the use of PaymentElement .我正在尝试使用PaymentElement使 Stripe Connect 帐户在我的应用程序中接受付款。 So far the payments are going through with the regular credit card input, but now I want to enable Apple Pay.到目前为止,付款是通过常规信用卡输入进行的,但现在我想启用 Apple Pay。

So, I added my domain name to my main Stripe account configuration.因此,我将我的域名添加到我的主要 Stripe 帐户配置中。 It seems that is not enough, so I added the domain name also for the particular Connect account using their API:似乎这还不够,所以我还使用他们的 API 为特定的 Connect 帐户添加了域名:

await stripe.applePayDomains.create(
  { domain_name: 'my_domain_here.com' },
  { stripeAccount: 'stripe_connect_account_id_here' },
);

When I now access my PaymentElement component Safari on macOS with the support of Apple Pay (tested and working on other sites), the ApplePay options does not appear and I get a console warning of:当我现在在支持 Apple Pay 的 macOS 上访问我的PaymentElement组件 Safari 时(已在其他网站上测试和工作),ApplePay 选项不会出现,并且我收到以下控制台警告:

Either you do not have a card saved to your Wallet or the current domain (my_domain_here.com) or stripeAccount parameter (stripe_connect_account_id_here) is not registered for Apple Pay.

The card is in my Wallet, the domain is visible when listing it them for the account with stripe.applePayDomains.list({ stripeAccount: 'stripe_connect_account_id_here' }) .该卡在我的钱包中,当为带有stripe.applePayDomains.list({ stripeAccount: 'stripe_connect_account_id_here' })的帐户列出它们时,域是可见的。

When I try to access it on my iOS device, the ApplePay option appears, yet triggering stripe.confirmPayment make the iOS payment drawer appear for ~1 second, just to disappear right away.当我尝试在我的 iOS 设备上访问它时,会出现 ApplePay 选项,但触发stripe.confirmPayment会使 iOS 支付抽屉出现约 1 秒钟,然后立即消失。

What am I missing here?我在这里想念什么?

So, as of the day of this post, this is indeed a default behaviour inside the test mode.因此,截至本文发布之日,这确实是测试模式中的默认行为。 All works fine inside the production environment.在生产环境中一切正常。

I'm not entirely sure if Stripe will (or even can) fix this.我不完全确定 Stripe 是否会(甚至可以)解决这个问题。

To add more to the answer from @mdmb it's not just Test mode, but because we are using connected accounts we need to create the Apple Domain verification in the connected account.要为@mdmb 的答案添加更多内容,这不仅仅是测试模式,而且因为我们使用的是连接帐户,我们需要在连接帐户中创建 Apple 域验证。

I contacted Stripe and they suggested I create the Apple Domain in code as the connected account as per https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=html#verifying-your-domain-with-apple-pay我联系了 Stripe,他们建议我按照https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=html#verifying在代码中创建 Apple 域作为连接帐户-your-domain-with-apple-pay

Their response to me was:他们对我的回应是:


There are a few things to fix here to get Apple Pay working:要让 Apple Pay 正常工作,这里需要解决一些问题:

1/ The Connect account has to be created in live mode, the one above is in test mode. 1/ Connect账户必须在live模式下创建,上面那个是test模式。 So you need to create a new Connect account in live mode with live mode details.因此,您需要使用实时模式详细信息在实时模式下创建一个新的 Connect 帐户。

2/ Step one is needed because you need to add your Apple Pay domain to the Connect account in live mode as well, which requires a live mode account in the first place. 2/ 需要第一步,因为您还需要在实时模式下将您的 Apple Pay 域添加到 Connect 帐户,这首先需要一个实时模式帐户。

The important part here is you need to add the Apple Pay domain using the Stripe-Account header + Platform secret key, as shown here: https://stripe.com/docs/stripe-js/elements/payment-request-button?html-or-react=html#html-js-using-with-connect .这里的重要部分是您需要使用 Stripe-Account header + 平台密钥添加 Apple Pay 域,如下所示: https://stripe.com/docs/stripe-js/elements/payment-request-button? html-or-react=html#html-js-using-with-connect

Once you do those two things, you can still initialize Stripe.js with your platform's test mode publishable key and stripeAccount parameter, and Apple Pay will work in that it will only create test mode tokens, if that is something you may be looking to do.一旦你做了这两件事,你仍然可以使用你平台的测试模式可发布密钥和 stripeAccount 参数初始化 Stripe.js,Apple Pay 将工作,它只会创建测试模式令牌,如果这是你可能想要做的事情.


So they suggest the key part of doing (in PHP):所以他们建议做的关键部分(在 PHP 中):

\Stripe\Stripe::setApiKey("sk_live_••••••••••••••••••••••••");

\Stripe\ApplePayDomain::create([
  'domain_name' => 'example.com',
]);

However if you are using the more up to date Client way then you'll want to do something like:但是,如果您使用的是更新的客户端方式,那么您需要执行以下操作:

$stripeClient = new \Stripe\StripeClient(['api_key' => $this->stripeApiKey,'stripe_account' => $connectedAccount->stripeAccountId]);
$stripeClient->applePayDomains->create([
   'domain_name' => $domainName,
]);

Tested it and this works.对其进行了测试,并且有效。 It seems to take about 1.5s to do the domain verification, then seems basically instant later.进行域验证似乎需要大约 1.5 秒,然后似乎基本是即时的。

Cheers!干杯!

I was having issue adding domain verification for apple pay to my connect account.我在将 Apple Pay 的域验证添加到我的连接帐户时遇到问题。 For connect account, you do need to add domain verification to connect account too.对于连接帐户,您也需要添加域验证来连接帐户。 The mistake that I was doing was that I was passing https://mysubdomain.example.com whereas stripe accepts just mysubdomain.example.com format.我犯的错误是我传递了 https://mysubdomain.example.com而 stripe 只接受 mysubdomain.example.com 格式。 Although in the error I was getting it was just saying We had trouble validating your domain.虽然在错误中我得到它只是说我们在验证您的域时遇到了麻烦。 So the error didn't point correctly but after hit and trial thats what I found.所以错误没有正确指出,但经过反复试验,这就是我发现的。 Hope it helps someone希望它可以帮助某人

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM