我要开设一家小商店,到目前为止,它相对简单。您可以一次,每周或每月订购该产品。
我已经在Stripe仪表板中设置了相应的产品。
如果客户发送了他们想要重复执行的订单,它将创建一个Customer
及其信息。
但是,每当我尝试创建重复订单时,我都会收到This customer has no attached payment source or default payment method. thrown in
。
我正在使用Stripe Elements,并且由于卡数据从不发送到我的服务器,因此我不确定如何向此Customer
添加付款方式。
创建订阅:
\Stripe\Subscription::create([
'customer' => $customer_id,
'items' => [
[
'price' => 'price_id_2',
'quantity' => $qty_1,
'price' => 'price_id_2',
'quantity' => $qty_2,
],
],
]);
$.post
将数据发送到PHP文件
$.post('./secret.php', data, null, "json")
.done(function(data) {
clientSecret = data.client_secret;
stripe.confirmCardPayment(clientSecret, {
payment_method: {
card: card,
}
}).then(function(result) {
if (result.error) {
console.log(result.error.message);
} else {
if (result.paymentIntent.status === 'succeeded') {
console.log("Payment success.");
document.getElementById("processing").classList.add("hide");
document.getElementById("order-success").classList.remove("hide");
}
}
})
})
.fail(function(xhr, status, error) {
document.getElementById("processing").classList.add("hide");
document.getElementById("order-failure").classList.remove("hide");
});
我的一次性订单可以正常工作,但是我不知道该怎么做。文档将“保存卡数据”显示为不推荐使用的实用程序,因此我不确定该怎么办。