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

问题描述

我使用 Django paypalrestsdk 来支付 PayPalhttps://github.com/paypal/PayPal-Python-SDK

I am using Django paypalrestsdk for PayPalhttps://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 USD100What 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/经典/paypal-payments-standard/integration-guide/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).

您可以按照 这个例子,通过指定一个start_date字段.
这里我使用了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 不会自动向客户收取未结余额 >余额.
.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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 06:38