【发布时间】:2019-09-30 13:39:40
【问题描述】:
我想在我的网站中添加 Stripe,但我注意到它很难使用,而且网络上没有更多的帮助资源。
我的第一个问题是如何将 PaymentIntent 的客户端密码传递给客户端,那么如何在我的 html 表单中传递一个 php 变量。
在我应该创建一个 PaymentIntent 对象之前:
\Stripe\Stripe::setApiKey('sk_test_8cpWr3HupPdvL9QK9cVToa4w009OYgxfNm');
$intent = \Stripe\PaymentIntent::create([
'amount' => 0.89,
'currency' => 'eur',
]);
那么API Stripe建议通过这种方式将PaymentIntent的客户端秘钥传递给客户端:
<?php
$intent = # ... Fetch or create the PaymentIntent;
?>
...
<input id="cardholder-name" type="text">
<!-- placeholder for Elements -->
<div id="card-element"></div>
<button id="card-button" data-secret="<?= $intent->client_secret ?>">
Submit Payment
</button>
...
这是 API 页面:https://stripe.com/docs/payments/payment-intents/quickstart#passing-to-client
但是如何在 html 页面中传递一个 php 变量呢?
有人可以解释一下这个客户机密是什么?
【问题讨论】:
标签: php html stripe-payments