python每月定时_paypal每月订阅计划设置为每月的第一天,并进行每月定期付款 – django python...

我想设置一个月度订阅计划.

每个月初,买家将收取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"

})

我不清楚它是在月的第一天还是在月的最后一天收费?我应该进行设置,以便立即收费吗?我的意图是收费是在每个月的第一天完成的.

我在买家的沙箱中看到这个:

预先批准的付款100美元

这是什么意思,他已经收取100美元或预先批准并在当月的最后一天收费?

到目前为止我用过这个流程:

create billing plan

activate billing plan

create billing agreement

execute billing agreement

(这是正确的吗?它显示预先批准但是这真的是收费,如果不是应该采取什么其他步骤来正确收费)

为了澄清,主要问题是如何使用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"

}

})

这里是paypal截图,为什么没有关于数量的信息,为什么没有重复信息预先批准?

https://imgur.com/a/Sp7JdVC

解决方法:

您可以通过指定start_datefield来说明this example中所述的结算协议的开始日期.这里我使用arrow模块,方便地计算下个月的第一天:

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"

}

}

...

})

初始订阅费应由setup_fee字段处理!

问题更新后编辑:

在计划的merchant_preferences字段中,您将auto_bill_amount设置为yes.

通过查看documentation on merchant_preferences,我们可以看到:

auto_bill_amount enum

Indicates whether PayPal automatically bills the outstanding balance in the next billing cycle. The outstanding balance is the total amount of any previously failed scheduled payments. Value is:

NO. PayPal does not automatically bill the customer the outstanding >balance.

YES. PayPal automatically bills the customer the outstanding balance.

Possible values: YES, NO.

Default: NO.

标签:python,django,paypal

来源: https://codeday.me/bug/20191007/1866446.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值