Search code examples
activemerchantpayflowpro

Repeated charging with Payflow Pro


This is probably more question for technical support of Payflow Pro, but anyway. We are trying to implement repeated charging of one credit card by Payflow Pro payment with ActiveMerchant. We need the customer to give the credit card info once and then be charged every month for variable amounts. However, there does not seem to be any explicit STORE method in the Payflow API even though it has to be somehow possible as the RECURRING billing is part of the standard. Are we missing something and there are methods for that or we have to use some workaround?


Solution

  • Ok, figured it out myself in the end, just FYI: this has nothing to do with the recurring payments. You can simply "STORE" credit card by issuing and voiding some small amount transaction and then later, instead of puting credit card details, you put the returned request.token (or 'pn_ref' in payflow terms).

    Something like this should work

    module ActiveMerchant #:nodoc:
      module Billing #:nodoc:
         class PayflowGateway
    
           def store(credit_card, options = {})
             stored = purchase( 1, credit_card)
             return stored unless stored.success?
    
             # we may charge some money we should not but I guess there is
             # no better way for now
             voided = void(stored.authorization)
             return voided unless voided.success?
    
            return stored
          end
    
        end
      end
    end