This is a follow on from a previous post, focusing on recuring payments.

I just wondered what the plans were with recurring payments? I read a bit about them in previous posts, but am unclear about a few things:

Firstly, where do they take place? Is it something Payments API deals with, is it something built into the payment providers - eg paypal/realex, or is it something built into the front end payment modules - eg webform pay/donations module?

Secondly, is it like a payment that just keeps happening again month after month, or is it a special kind of payment that has to have some kind of aggreement with the customer (like a direct debit in the UK)

Thirdly, how would it get recorded into the payment reports in Drupal?

To my mind this is a more important feature than the others mentioned in the previous post because i'm guessing are quite a few people looking for a lightweight alternative to Ubercart for subscriptions and recurring donations.

Many thanks for the module and the hard work, Joe

Comments

joecanti’s picture

Hi,

I've been looking into this in a bit more depth, more specifically for the Realex payment gateway.
The workflow looks like this:

- Customer hits 'buy' and enters details.
- 1st XML token sent to Realex containing the card details, which are then stored with realex.
- 2nd XML token sent to Realex containing transaction information.
- Realex send xml back containing success/failure details.
- Your website then re-sends the second token monthly (or quarterly etc), and realex replies.

Please could you let me know which bits the pay module deals with and which bits the payment gateway deals with?

I would imagine it is the Pay or Webform Pay module which has to trigger the Pay-Realex module to resend the second XML file. I'm not sure whether this is in line with other gateway recurring methods or not.

Any info on this much appreciated,

Many thanks, Joe

univate’s picture

I maintain uc_recurring which adds recurring functionality to ubercart. I am interested in seeing better abstraction to payment gateways but not sure that having pay or webform_pay modules triggering the recurring payments is going to be the best way to go. This might be better handled in a separate module - pay_recurring.

There are various different methods that gateways can provide recurring functionality, but generally they are divided into to classes:
1) Hosted - where you send the details of the payment and recurring interval and the gateways does everything. In some cases gateways will send back notifications on renewal attempts so you can respond to these events (e.g. Paypal WPS subscriptions, Authorize.net ARB)

2) Triggered/tokenized - these are gateways where you just send the payment details, credit cards and a token is returned. When a payment needs to be processed you can use this token to trigger payments.

There is a third:
3) Store credit cards details yourself and use the normal (requires addition PCI compliance), in reality one of the better way to implement this would be to setup your own tokenized system (as in 2 above) separate from the normal web database and have a secure method to trigger payments. That way you can restrict access to the sensitive details.

The first step in pay is having a method for gateways to expose what functionality they implement. One option could be through the use of PHP interfaces:

/**
 * A recurring interface for gateways that support the ability to setup a recurring payment.
 */
interface pay_recurring() {
  public function setup_recurring();
}

/**
 * A tokenized payment is one where we can store a token and charge payments when we like.
 * 
 * This type of gateway also allows supporting general recurring functionality so we can extend that interface.
 */
interface pay_tokenized extends pay_recurring() {
  public function token_payment();
}


class MyGateway extends pay_method implements pay_tokenized {
  public function setup_recurring() {
    /* create a token for future payments */
  }
  public function token_payment($amount) {
     /* charge a payment using the stored token */
  }
}


/* In our application code we just wrap specific function in conditional statements */
if ($gatway instanceof pay_tokenized) {
  $gateway->charge_token(100);
}

/* so in billing application could do something like */
global $user;
$payment_method = pay_load_payment_details($user); // attempt to find a payment method for that user
if ($payment_method instanceof pay_tokenized) { // check that we can process a payment
  $gateway->charge_token(100);  // charge the payment
}
else {
  // throw an error.
}

This is not just limited to recurring payments, any payment feature can be implemented this way, where an interface is created to define a set of methods required to use that features. So this could be done for "refunds".

NewZeal’s picture

Version: 6.x-1.0-alpha6 » 6.x-1.1

I am looking at creating a pay_recurring module, to go with a module that I maintain: http://drupal.org/project/listing . If anyone has any code already started then it would be appreciated if you could send it along.

Thanks

stella’s picture

I'd like to implement a recurring feature for the Realex payment gateway (pay_realex module), but am unsure how to proceed. It uses the tokenised method as described in comment #2 above.

I agree that the module providing the payment form (e.g. webform_pay) should not be responsible for triggering the recurring payment. However, unsure whether it should be the Pay module that is responsible or the payment gateway module. Maybe the Pay module should provide the framework, but allow each payment gateway module to implement their own variation as required?

I'm happy to work on a patch for this if we could agree on how best to go about it.

thehong’s picture

Version: 6.x-1.1 » 7.x-1.x-dev
Issue summary: View changes