Javascript 条带支付流程
我对如何使用Stripe处理订阅+费用支付有点困惑 以下是我得到的: HTML: 我很明显不知道整个过程是如何运作的 我将填充电子邮件字段,但如何在该弹出表单中请求每月重新发生的安装费+订阅 理想情况下,工作流程如下所示: 我的网页及表格: 用户填写名称、电子邮件、商品名称[需要此元数据]、商品价格、包装名称[需要此元数据]、包装价格 点击提交按钮, 条带弹出表单显示,并预先填充电子邮件,用户同意打包每月付款+项目价格,用户输入卡信息, 用户提交条带表单 用户现在被收取第一个月的包裹+项目价格,付款将发生在每个月的包裹自动 返回到一个包含所有元数据、价格、包等的url,带有密码或某种安全表单字段,然后我自动处理返回url数据中的订单Javascript 条带支付流程,javascript,php,stripe-payments,stripe.js,Javascript,Php,Stripe Payments,Stripe.js,我对如何使用Stripe处理订阅+费用支付有点困惑 以下是我得到的: HTML: 我很明显不知道整个过程是如何运作的 我将填充电子邮件字段,但如何在该弹出表单中请求每月重新发生的安装费+订阅 理想情况下,工作流程如下所示: 我的网页及表格: 用户填写名称、电子邮件、商品名称[需要此元数据]、商品价格、包装名称[需要此元数据]、包装价格 点击提交按钮, 条带弹出表单显示,并预先填充电子邮件,用户同意打包每月付款+项目价格,用户输入卡信息, 用户提交条带表单 用户现在被收取第一个月的包裹+项目价格,
请帮忙,谢谢社区 生成计划代码或使用管理面板,并将计划id放入subscription method。。 确保如果您使用管理面板生成了计划id,那么它将仅在live key中运行,并使用代码生成了计划id,同时运行这两个键
$plan = \Stripe\Plan::create([
'product' => {'name' => 'Basic Product'},
'nickname' => 'Basic Monthly',
'interval' => 'month',
'currency' => 'usd',
'amount' => 0,
]);
我想我可以指导你这个过程,你必须遵循一些非常简单的步骤,检查一切是否完美
\Stripe\Stripe::setApiKey(“”);
$plan=\Stripe\plan::create([
'产品'=>{'name'=>'计划名称'},
“昵称”=>“计划代码”,
'间隔'=>'月',
“货币”=>“美元”,
“金额”=>10,
]);
\Stripe\Stripe::setApiKey(“”);
$customer=\Stripe\customer::create([
'电子邮件'=>'customer@example.com',
]);
此调用的响应将为在stripe创建的客户提供一个json
{
"id": "<UNIQUE ID>",
...
}
{
“id”:“,
...
}
您需要在变量或数据库中持久化id\Stripe\Stripe::setApiKey(“”);
$subscription=\Stripe\subscription::create([
'客户'=>'',
'项目'=>[['计划'=>'']],
]);
您可以在gist中找到有关的更多详细信息,您应该实现基本条带收费API流(创建客户、创建收费等),并在付款的返回承诺中调用订阅计划id,将其附加到用户(成功收费) 您不必以编程方式创建此计划(除非您需要为每个客户动态创建唯一的计划),您可以通过slack dashboard的“用户计划”部分来创建此计划。您只需打电话向客户“订阅”您给定的计划即可 首先创建一个用户,成功创建此用户后,“charge”调用将传入此客户的唯一id,稍后当charge成功时(在您成功的回调中,而不是在错误回调中),使用您先前创建的计划id调用subscribe调用 当您使用测试模式并使用此设置付款时,请查看付款详细信息(确保仪表板已切换到测试模式),您将看到此费用,并且用户已将订阅计划附加到该费用,将发生的情况是,stripe将在此订阅期结束后再次尝试收费(您可以通过仪表板、周/月计划等进行设置),最好使用stripe自己的工具进行测试(您不必等待这段时间进行测试,请在相关api文档部分中查找) 如果您在代码方面也需要帮助,请告诉我,但是一旦您了解了我上面解释的这个简单流程,就可以非常直接地遵循api文档 仪表板url:(打开“查看测试数据”以查看您的测试付款详细信息) API调用参考: (您不必通过api执行此操作,只需在仪表板上执行即可,更简单) 看看我测试代码中的代码段,我使用NodeJS,但是您也可以在前端的php项目中使用它,只需在入门文档中查找前端设置条带即可
stripe.customers.create({
description: "NR user twitter: " + req.body.twusername + ", job title being paid for: " + req.body.jobRawTitle,
source: req.body.token,
email: req.body.email
}, function(err, customer) {
if (err) {
// bad things
console.log("DEBUG payment charge error: " + JSON.stringify(err));
} else {
//update user with given Email
// Charge the user's card:
return stripe.charges.create({
amount: 29900, //the last 2 0s are cents
currency: "usd",
customer: customer.id,
description: "Jobs 1 month paid for nextreality job titled:" + req.body.jobRawTitle
}, function(err, charge) {
if (err) {
// bad things
console.log("DEBUG payment charge error: " + JSON.stringify(err) );
console.log("charge: "+ charge);
} else {
// successful charge
return stripe.subscriptions.create({
customer: customer.id,
items: [
{
plan: "jobs_monthly",
},
],
}, function(err, subscription) {
// asynchronously called
console.log("DEBUG payment subscription error: " + err + ' subs:' + JSON.stringify(subscription) );
return Response(req, res, {});
});
}
});
}
});
你想要他们的默认表单还是你自己的自定义表单?他们的默认表单你有没有检查过这个问题-错误消息,错误结果,什么都没有发生?我需要带他们UI的付款弹出窗口,但我需要创建用户、订阅和发票的后端处理,我只是不确定一切是如何联系在一起的。。。
\Stripe\Stripe::setApiKey("<YOUR SECRET KEY>");
$plan = \Stripe\Plan::create([
'product' => {'name' => 'Plan name'},
'nickname' => 'Plan code',
'interval' => 'month',
'currency' => 'usd',
'amount' => 10,
]);
\Stripe\Stripe::setApiKey("<YOUR SECRET KEY>");
$customer = \Stripe\Customer::create([
'email' => 'customer@example.com',
]);
{
"id": "<UNIQUE ID>",
...
}
\Stripe\Stripe::setApiKey("<YOUR SECRET KEY>");
$subscription = \Stripe\Subscription::create([
'customer' => '<UNIQUE ID>',
'items' => [['plan' => '<PLAN ID>']],
]);
stripe.customers.create({
description: "NR user twitter: " + req.body.twusername + ", job title being paid for: " + req.body.jobRawTitle,
source: req.body.token,
email: req.body.email
}, function(err, customer) {
if (err) {
// bad things
console.log("DEBUG payment charge error: " + JSON.stringify(err));
} else {
//update user with given Email
// Charge the user's card:
return stripe.charges.create({
amount: 29900, //the last 2 0s are cents
currency: "usd",
customer: customer.id,
description: "Jobs 1 month paid for nextreality job titled:" + req.body.jobRawTitle
}, function(err, charge) {
if (err) {
// bad things
console.log("DEBUG payment charge error: " + JSON.stringify(err) );
console.log("charge: "+ charge);
} else {
// successful charge
return stripe.subscriptions.create({
customer: customer.id,
items: [
{
plan: "jobs_monthly",
},
],
}, function(err, subscription) {
// asynchronously called
console.log("DEBUG payment subscription error: " + err + ' subs:' + JSON.stringify(subscription) );
return Response(req, res, {});
});
}
});
}
});