我对如何使用 Stripe 处理订阅 + 费用支付有点困惑,
这是我得到的:
HTML:
<form id="req" action="/thank-you" method="post">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_RrE21sY9Xbtwq9ZvbKPpp0LJ"
data-name="Wizard.Build Hosting Package"
data-description=""
data-image="https://stripe.com/img/documentation/checkout/marketplace.png"
data-locale="auto"
data-currency="usd">
</script>
...
感谢页面:
require_once('lib-stripe/init.php');
// create api key
\Stripe\Stripe::setApiKey("sk_TESTING");
// create customer
$customerO =\Stripe\Customer::create(array(
"email" => $_POST["e"]
));
$customer = $customerO->jsonSerialize();
//var_dump($customer);
//create subscription (Package Bronze, Silver or Gold)
$subscriptionO = \Stripe\Subscription::create(array(
"customer" => $customer["id"],
"items" => array(
array(
"plan" => $_POST["pack"],
),
)
));
$subscription = $subscriptionO->jsonSerialize();
//var_dump($subscription);
//create invoice (3rdparty cost)
$invoiceO = \Stripe\Invoice::create(array(
"customer" => $customer["id"],
"amount" =>$p3price,
"currency" => "usd",
"description" => "3rdp Cost",
"subscription" => $subscription["id"]
));
$invoice = $invoiceO->jsonSerialize();
//var_dump($invoice);
我显然错过了整个过程的工作方式......
我将填充电子邮件字段,但我如何在该弹出表单中请求每月重新发生的设置费 + 订阅?
理想情况下,工作流程如下:
带有表单的我的网站页面:用户填写姓名、电子邮件、商品名称[需要此元数据]、商品价格、包裹名称[需要此元数据]、包裹价格
点击提交按钮,Stripe弹出表单出现预填充电子邮件,用户同意打包每月付款+商品价格,用户输入卡信息,用户提交条纹表单,
用户现在需要支付第 1 个月的包裹 + 商品价格,每个月都会自动为包裹付款。
返回包含所有元数据、价格、包裹等的 url,带有密码或某种安全表单字段,然后我从返回的 url 数据中自动处理订单,
请帮助,感谢社区!