django-oscar-paypal icon indicating copy to clipboard operation
django-oscar-paypal copied to clipboard

Add support for recurring payments

Open codeinthehole opened this issue 12 years ago • 10 comments
trafficstars

In PayPal Express, you can create recurring billing profiles, which is something we should support.

Tasks:

  • [ ] Extend the SetExpressCheckout call to allow recurring billing params
  • [ ] Create a gateway function for CreateRecurringPaymentsProfile
  • [ ] Create a gateway function for SetCustomerBillingAgreement.
  • [ ] Create a gateway function for ManageRecurringPaymentsProfileStatus

codeinthehole avatar Apr 18 '13 16:04 codeinthehole

Is there any updates on this feature? I'm trying to determine if I should try to implement it myself or wait for the official version.

eukreign avatar Jun 13 '13 21:06 eukreign

I haven't really done any work on it other than a simple POC commit: https://github.com/tangentlabs/django-oscar-paypal/commit/e239980938b91bf811fdbf8d36c942f80df25852

Someone else from Tangent is definitely working on this at the moment though as we have a client who needs subscription products that require recurring payments. However, I'm not sure how long it would take for that work to make it into this extension. @a-musing-moose - can you offer any further advice?

So my advice would probably be to fork the extension and implement the recurring logic yourself (so you're not waiting for us). I'd happily review your work and merge it if you submit a PR afterwards.

codeinthehole avatar Jun 14 '13 08:06 codeinthehole

@eukreign As @codeinthehole says I have been working on a little on this over the past few days. I have a very basic working branch now: https://github.com/a-musing-moose/django-oscar-paypal/commit/ad54d265aa72488eccc2fcffa825b0688b61783d

There are no real test or documentation for it yet I'm afraid and some pretty limiting restrictions.

What is does allow:

  • The creation of a single recurring payment for an item
  • An extensible method for determining if a product should have a recurring payment

Restrictions:

  • Your basket must contain a single item, with a quantity of 1. Nothing else.

The way paypal recurring payments work (at least in express checkout) is that a separate recurring payment needs to be set up for each product purchased. This is somewhat different to how normal payments are constructed. You also need to call CreateRecurringPaymentProfile for each of these payments. You also need to perform a DoExpressCheckoutPayment if there are any normal payments in the basket as well. i.e. you end up with multiple transactions at the end of the process.

So full support is a fairly complex proposal. For the project I am currently working on, and the time frame I have, this is not possible. Hence compromising on a limited implementation.

Within the project that is using the recurring payments I am extending the basket app to include additional logic. Namely, that whenever a product with a recurring profile is added to the basket. That basket is first cleared so that the recurring product is the only one in it. I am also added logic to only allow a quantity of 1.

If you are still interested in using the modification I have made thus far then I should also explain the PAYPAL_RECURRING_PREDICATE settings. This is the method by which we determine if a product has a recurring profile. It specifies the full path to a function. e.g.:

PAYPAL_RECURRING_PREDICATE = 'myapp.mymodule.get_recurring_profile'

This function is passed a product and returns either None if the product does not have a recurring profile. Or a dictionary in the following form for one that does:

{
    'billing_description': 'a description - $10 per month',
    'billing_frequency': 1,
    'billing_period': 'Month',
}  

Since you do not pass the actual amount to paypal until the CreateRecurringPaymentProfile call right at the end. It is recommended that the billing description contains not only the product description but all the cost, and recurring profile.

billing_period can be 'Day', 'Week', 'Month', 'SemiMonth', 'Year' and billing_frequency is an integer value. So the above example is every 1 month.

There is one additional part I have yet to implement. Which is IPN support. Instant Payment Notifications are sent out for recurring payments. One for the initial set and then one for every successful payment after that, or if the customer cancels the payment. That I'm afraid is still an exercise for the user.

Hit me up if you have any further question. Either here or on the mailing list.

a-musing-moose avatar Jun 15 '13 23:06 a-musing-moose

You guys are awesome, thank you for the explanation.

I am using PayPal Payments Advanced which requires tokens and CC input being hosted by them.

I'll make pull requests if I'm able to generalize my implementation.

One problem I've found with the hosted pages and tokens is that they do not support creating Recurring transactions.

I found a stackoverflow post which explains the problem and provides a possible solution: http://stackoverflow.com/questions/13629023/secure-tokens-for-paypal-recurring-payments

I will try to see if that solution could be generalized.

eukreign avatar Jun 21 '13 03:06 eukreign

What happen with this?

SalahAdDin avatar Aug 14 '16 01:08 SalahAdDin

Can I also ask if there are there any plans to implement this?

DanSmall avatar Nov 13 '16 01:11 DanSmall

Any updates on this Issue?

nhondong avatar Jul 30 '21 17:07 nhondong

I guess it died.

Any updates on this Issue?

SalahAdDin avatar Aug 01 '21 11:08 SalahAdDin

Please someone add subscription modul for oscar.

pije76 avatar Sep 23 '21 06:09 pije76

Meanwhile, 11y, waiting.

j2l avatar Jan 17 '24 11:01 j2l