Create a Recurring Payment

This code steps you through the process of storing a payment method for a customer and using it to set up recurring payments. When this recurring payment information is stored, a $0 authorization is used for the initial transaction. As a result, the customer is not charged until the rebilling cycle begins.

For sample code that charges customers at the same point of establishing rebilling Go to: Run a credit card transaction with recurring payments or ACH processing with recurring payments

The following sample code calls a routine from our Code Library.
Download BluePay.py

Credit Card

##
# BluePay Python Sample code.
#
# This code sample creates a recurring payment charging $15.00 per month for one year.
##

account_id = "Merchant's Account ID Here"
secret_key = "Merchant's Secret Key Here"
mode = "TEST" 

payment = BluePay(
    account_id = account_id,
    secret_key = secret_key,
    mode = mode
)

payment.set_customer_information(
    name1 = "Bob",
    name2 = "Tester",
    addr1 = "123 Test St.",
    addr2 = "Apt #500",
    city = "Testville",
    state = "IL",
    zipcode = "54321",
    country = "USA"
)

payment.set_cc_information(
    card_number = "4111111111111111",
    card_expire = "1215",
    cvv2 = "123"
)

payment.auth(amount = '0.00')

# Set Recurring Payment Information
payment.set_rebilling_information(
  reb_first_date = "2015-01-01", # Rebill Start Date: Jan. 1, 2015
  reb_expr = "1 MONTH", # Rebill Frequency: 1 MONTH
  reb_cycles = "12", # Rebill # of Cycles: 12
  reb_amount = "15.00" # Rebill Amount: $15.00
)

# Makes the API Request
payment.process()

# Read response from BluePay
if payment.is_successful_response():
    print 'Transaction ID: ' + payment.trans_id_response
    print 'Rebill ID: ' + payment.reb_id_response
    print 'Transaction Status: ' + payment.status_response
    print 'Transaction Message: ' + payment.message_response
    print 'Transaction AVS Result: ' + payment.avs_code_response
    print 'Transaction CVV2 Result: ' + payment.cvv2_code_response
    print 'Masked Payment Account: ' + payment.masked_account_response
    print 'Transaction Auth Code: ' + payment.auth_code_response
else:
    print payment.message_response

ACH

##
# BluePay Python Sample code.
#
# This code sample creates a recurring payment charging $15.00 per month for one year.
##

account_id = "Merchant's Account ID Here"
secret_key = "Merchant's Secret Key Here"
mode = "TEST" 

payment = BluePay(
    account_id = account_id,
    secret_key = secret_key,
    mode = mode
)

payment.set_customer_information(
    name1 = "Bob",
    name2 = "Tester",
    addr1 = "123 Test St.",
    addr2 = "Apt #500",
    city = "Testville",
    state = "IL",
    zipcode = "54321",
    country = "USA"
)

# Set ACH Payment Information
payment.set_ach_information(
    routing_number = "123123123", # Routing Number: 123123123
    account_number = "05125121", # Account Number: 0523421
    account_type = "C", # Account Type: Checking
    doc_type = "WEB" # ACH Document Type: WEB
)

payment.auth(amount = '0.00')

# Set Recurring Payment Information
payment.set_rebilling_information(
  reb_first_date = "2015-01-01", # Rebill Start Date: Jan. 1, 2015
  reb_expr = "1 MONTH", # Rebill Frequency: 1 MONTH
  reb_cycles = "12", # Rebill # of Cycles: 12
  reb_amount = "15.00" # Rebill Amount: $15.00
)

# Makes the API Request
payment.process()

# Read response from BluePay
if payment.is_successful_response():
    print 'Transaction ID: ' + payment.trans_id_response
    print 'Rebill ID: ' + payment.reb_id_response
    print 'Transaction Status: ' + payment.status_response
    print 'Transaction Message: ' + payment.message_response
    print 'Masked Payment Account: ' + payment.trans_id_response
    print 'Customer Bank: ' + payment.bank_name_response
else:
    print payment.message_response
BluePay Processing, LLC is a registered ISO of Wells Fargo Bank, N.A., Walnut Creek, CA, U.S.A.
BluePay Canada ULC, is a Registered ISO/MSP of Peoples Trust Company, Vancouver, Canada.