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 makes use of various headers and source files.
Download bluepay-cpp.zip
Or, download via GitHub

Credit Card

//
// BluePay C++ Sample code.
//
// This code sample creates a recurring payment charging $15.00 per month for one year.

#include "Create_Recurring_Payment_CC.h"
#include "BluePay.h"
using namespace std;

void createRecurringPaymentCC(){

    string accountId = "Merchant's Account ID Here";
    string secretKey = "Merchant's Secret Key Here";
    string mode = "TEST";

    BluePay rebill(
        accountId,
        secretKey,
        mode
    );

    rebill.setCustomerInformation(
        "Bob", // First Name
        "Tester", // Last Name
        "1234 Test St.", // Address1
        "Apt #500", // Address2
        "Testville", // City
        "IL", // State
        "54321", // Zip
        "USA", // Country
        "1231231234", // Phone Number
        "[email protected]" // Email Address
      );

    rebill.setCCInformation(
        "4111111111111111", // Card Number
        "1215", // Card Expire
        "123" // Card CVV2
    );

    rebill.setRebillingInformation(
        "15.00", // Rebill Amount
        "2015-01-01", // Rebill Start Date
        "1 MONTH", // Rebill Frequency
        "12" // Rebill number of Cycles
    );

    // Auth Amount: $0.00
    rebill.auth("0.00");
   
    // Makes the API Request with Blue
    rebill.process();

    // Reads the responses from BluePay if transaction was approved
    if (rebill.isSuccessfulTransaction()){
        cout << string("Transaction ID: ") + rebill.getTransId() + "\n";
        cout << string("Rebill ID: ") + rebill.getRebillId() + "\n";
        cout << string("Transaction Status: ") + rebill.getResult() + "\n";
        cout << string("Transaction Message: ") + rebill.getMessage() + "\n";
        cout << string("AVS Result: ") + rebill.getAvs() + "\n";
        cout << string("CVV2 Result: ") + rebill.getCvv2() + "\n";
        cout << string("Masked Payment Account: ") + rebill.getMaskedPaymentAccount() + "\n";
        cout << string("Card Type: ") + rebill.getCardType() + "\n";
        cout << string("Authorization Code: ") + rebill.getAuthCode() + "\n";
    }
    else {
        cout << string("Error: ") + rebill.getMessage();
    }

}

ACH

//
// BluePay C++ Sample code.
//
// This code sample creates a recurring payment charging $15.00 per month for one year.

#include "Create_Recurring_Payment_ACH.h"
#include "BluePay.h"
using namespace std;

void createRecurringPaymentACH(){
    string accountId = "Merchant's Account ID Here";
    string secretKey = "Merchant's Secret Key Here";
    string mode = "TEST";

    BluePay rebill(
        accountId,
        secretKey,
        mode
    );

    rebill.setCustomerInformation(
        "Bob", // First Name
        "Tester", // Last Name
        "123 Test St.", // Address1
        "Apt #500", // Address2
        "Testville", // City
        "IL", // State
        "54321", // Zip
        "USA", // Country
        "1231231234", // Phone Number
        "[email protected]" // Email Address
      );

    rebill.setACHInformation(
        "123123123", // Routing Number
        "0523421", // Account Number
        "C", // Account Type: Checking
        "WEB" // ACH Document Type: WEB
    );

    rebill.setRebillingInformation(
        "15.00", // Rebill Amount
        "2015-01-01", // Rebill Start Date
        "1 MONTH", // Rebill Frequency
        "12" // Rebill # of Cycles
    );

    // Auth Amount: $0.00
    rebill.auth("0.00");
   
    // Makes the API Request with Blue
    rebill.process();

    // Reads the responses from BluePay if transaction was approved
    if (rebill.isSuccessfulTransaction()){
        cout << string("Transaction ID: ") + rebill.getTransId() + "\n";
        cout << string("Rebill ID: ") + rebill.getRebillId() + "\n";
        cout << string("Transaction Status: ") + rebill.getResult() + "\n";
        cout << string("Transaction Message: ") + rebill.getMessage() + "\n";
        cout << string("Masked Payment Account: ") + rebill.getMaskedPaymentAccount() + "\n";
        cout << string("Bank Name: ") + rebill.getBank() + "\n";
    }
    else {
        cout << string("Error: ") + rebill.getMessage();
    }  
}
Can’t find what you’re
looking for? We can help.

Contact 800-350-2684 for Integration Support.

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.