当月第一天的Paypal每月订阅计划设置并进行每月定期付款-Django Python [英] paypal monthly subscription plan settings for first day of the month and making monthly recurring payment - django python

查看:134
本文介绍了当月第一天的Paypal每月订阅计划设置并进行每月定期付款-Django Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Django paypalrestsdk用于PayPal https://github.com/paypal/PayPal-Python-SDK

I am using Django paypalrestsdk for PayPal https://github.com/paypal/PayPal-Python-SDK

我想设置一个月度订阅计划. 每月的每个月初,买方都将被收取100美元.

And I would like to setup a monthly subscription plan. Every beginning of the month, the buyer will be charged USD100.

这是我制定的帐单计划代码:

This is my billing plan code I have made:

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"
})

我不清楚是在当月的第一天还是当月的最后一天充电?我应该准备好设置以便立即收费吗?我的意图是在每月的第一天进行充电.

It is not clear to me if it is charging on the first day of the month or the last day of the month? Should I have the setup so it's charged immediately? My intention is charging is done on the first day of the month.

我在买方的沙箱中看到了这一点: 预先付款USD100 这是什么意思,他是在当月的最后一天已经收取了100美元的费用,还是已预先批准并收取了费用?

I am seeing this in the sandbox of the buyer: Preapproved payment USD100 What does this mean, is he charged already USD100 or preapproved and charged on the last day of the month?

基于此,似乎立即对其进行了收费.意思是应该显示200美元吧? (设置+每月,但仅显示100美元) https://developer.paypal.com/docs/经典/贝宝付款标准/集成指南/subscription_billing_cycles/

Based on this, it seems like its charged right away. meaning it should show USD200 right? (setup + monthly but its showing only USD100) https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/subscription_billing_cycles/

到目前为止,我已经使用了以下流程:

I've used this flow so far:

create billing plan
activate billing plan
create billing agreement 
execute billing agreement

(这是正确的吗?它显示了预先批准的信息,但确实收费了,如果没有请采取其他步骤对其进行正确收费)

(is this correct? it shows pre-approved but is this really charged, if not what other steps should be taken to charge it properly)

为澄清起见,主要问题是如何使用PayPal设置每月结算(以及设置计费周期(无论是月初还是月末)? (在此示例中,其使用django python)

To clarify, the main question is how do you set up monthly billing with PayPal (and to set the charging cycle, whether it's beginning of the month or end)? (in this example, its using django python)

更新:

根据@ john-moutafis的建议,我现在已经设置了100美元,并且将重复开始日期设置为1个月后的111美元

On a recommendation @john-moutafis, I'ved now have setup USD100, and recurring start date is set 1 month later for 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

Here is paypal screenshots, why is there no info on amount and why is it preapproved without recurring info ? https://imgur.com/a/Sp7JdVC

推荐答案

Paypal会自动尝试使每个月的结算日期保持相同(在适用的情况下,

Paypal will automatically try to keep the billing date the same for every month (where applicable, as stated in the linked resource).

您可以按照 arrow 模块,方便地计算下一天的第一天月份:

You can state the starting date of a billing agreement as stated in this example, by specifying a start_datefield.
Here I use the arrow module, to conveniently calculate the first day of the next month:

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字段中处理!

The initial subscription fee should be handled by the setup_fee field!

问题更新后进行

在计划的merchant_preferences字段上,将auto_bill_amount设置为yes.
通过查看merchant_preferences上的文档我们可以看到:

On the merchant_preferences field of your plan, you are setting auto_bill_amount to yes.
By taking a look at the documentation on merchant_preferences we can see that:

auto_bill_amount 枚举

指示PayPal是否在下一个计费周期中自动对未结余额进行计费.未偿余额是任何先前未完成的预定付款的总额.值是:

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不会自动向客户收取未付帐款.
YES. PayPal会自动向客户收取未结余额.

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

可能的值:YESNO.

默认值:NO.

这篇关于当月第一天的Paypal每月订阅计划设置并进行每月定期付款-Django Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆