Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

paypal monthly subscription plan settings for first day of the month and making monthly recurring payment - django python

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

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.

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?

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)

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)

UPDATE:

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

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

like image 857
Axil Avatar asked Apr 21 '18 15:04

Axil


People also ask

What is the billing cycle for PayPal?

Each billing cycle is one month.

What happens if you cancel a subscription on PayPal?

Cancelation and Membership StatusCancelation will not affect the current membership for the already paid 12-month term. Non-PayPal membership payments made through other means (beanstream, cheque etc.) will NOT be renewed automatically. They will need to be renewed manually.


1 Answers

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

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

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


EDIT after question update:

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 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.

like image 114
John Moutafis Avatar answered Oct 07 '22 15:10

John Moutafis