Axi*_*xil 19 python django paypal
我正在使用Django paypalrestsdk for PayPal https://github.com/paypal/PayPal-Python-SDK
我想设置一个月度订阅计划.每个月初,买家将收取100美元的费用.
这是我制作的结算方案代码:
billing_plan = paypalrestsdk.BillingPlan({
"name": "Monthly Billing Plan",
"description": "Monthly Plan",
"merchant_preferences": {
"auto_bill_amount": "yes",
"cancel_url": "http://localhost:8000/payment_billing_agreement_cancel",
"initial_fail_amount_action": "continue",
"max_fail_attempts": "0",
"return_url": "http://localhost:8000/payment_billing_agreement_execute",
"setup_fee": {
"currency": "USD",
"value": "100"
}
},
"payment_definitions": [
{
"amount": {
"currency": "USD",
"value": "100"
},
"cycles": "0",
"frequency": "MONTH",
"frequency_interval": "1",
"name": "Monthly Payment",
"type": "REGULAR"
}
],
"type": "INFINITE"
})
Run Code Online (Sandbox Code Playgroud)
我不清楚它是在月的第一天还是在月的最后一天收费?我应该进行设置,以便立即收费吗?我的意图是收费是在每个月的第一天完成的.
我在买家的沙箱中看到这个:预先批准的付款USD100这是什么意思,他已经收取100美元或预先批准并在当月的最后一天收费?
基于此,它似乎立即收费.这意味着它应该显示200美元吗?(设置+每月但仅显示100美元) https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/subscription_billing_cycles/
到目前为止我用过这个流程:
create billing plan
activate billing plan
create billing agreement
execute billing agreement
Run Code Online (Sandbox Code Playgroud)
(这是正确的吗?它显示预先批准但是这真的是收费,如果不是应该采取什么其他步骤来正确收费)
为了澄清,主要问题是如何使用PayPal设置月度结算(以及设置充电周期,无论是月初还是结束)?(在这个例子中,它使用django python)
更新:
根据推荐@ john-moutafis,我现在设置了100美元,并且定期开始日期设置为1个月后的USD111
billing_agreement = paypalrestsdk.BillingAgreement({
"name": "Monthly Billing Agreement",
"description": "Monthly Payment Agreement",
"start_date": arrow.utcnow().shift(months=+1).datetime.strftime('%Y-%m-%dT%H:%M:%SZ'),
"plan": {
"id": billing_plan.id
},
"payer": {
"payment_method": "paypal"
}
})
Run Code Online (Sandbox Code Playgroud)
这里是paypal截图,为什么没有关于数量的信息,为什么没有重复信息预先批准? https://imgur.com/a/Sp7JdVC
Paypal将自动尝试保持每个月的结算日期相同(如果适用,如链接资源中所述).
您可以通过指定字段来说明此示例中所述的结算协议的开始日期start_date.
这里我使用箭头模块,方便地计算下个月的第一天:
import arrow
billing_plan = paypalrestsdk.BillingPlan({
"name": "Monthly Billing Plan",
"description": "Monthly Plan",
"start_date": arrow.utcnow().shift(months=+1).replace(day=1).isoformat(),
"merchant_preferences": {
...
"setup_fee": {
"currency": "USD",
"value": "100"
}
}
...
})
Run Code Online (Sandbox Code Playgroud)
初始订阅费应由setup_fee现场处理!
问题更新后编辑:
在merchant_preferences你的计划的领域,要设置auto_bill_amount到yes.
通过查看文档,merchant_preferences我们可以看到:
auto_bill_amount枚举指示PayPal是否自动在下一个结算周期中记入未结余额.未结余额是任何先前失败的预定付款总额.价值是:
NO.PayPal不会自动向客户收取未结清的余额.
YES.PayPal自动向客户收取未结余额.可能的值:
YES,NO.默认值:
NO.