paypal每月订阅计划设置为每月的第一天,并进行每月定期付款 - django python

时间:2018-04-21 15:18:02

标签: python django paypal

我正在使用Django paypalrestsdk进行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"
})

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

我在买家的沙箱中看到这个: 预先批准的付款100美元 这是什么意思,他已经收取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

(这是正确的吗?它显示预先批准但是这真的是收费,如果没有采取其他措施来正确收费)

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

1 个答案:

答案 0 :(得分:6)

Paypal会自动尝试将每个月的结算日期保持不变(如果适用,as stated in the linked resource)。

您可以通过指定start_date字段来说明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 枚举

     

表示PayPal是否自动在下一个结算周期中记入未结余额。未结余额是任何先前失败的预定付款总额。价值是:

     

NO。 PayPal不会自动向客户收取未结余额>余额      的 YES。 PayPal会自动向客户收取未结余额。

     

可能的值:YESNO

     

默认值:NO

相关问题