Update a Recurring Payment: Java

This code updates a customer's recurring payment information.

This code uses BluePay's Rebilling Administration Interface.
For documentation on usage of this interface Go to: Library documentation

You can test for both outcomes:

Approved: When you pass odd dollar amounts, this returns an 'Approved' status.
Declined: When you pass even dollar amounts, this returns a 'Declined' status.

The following sample code calls a routine from our Code Library.
Download BluePay.java
Or, download via GitHub

* BluePay Java Sample code.
* This code sample runs a $0.00 Credit Card Auth transaction
* against a customer using test payment information.
* Once the rebilling cycle is created, this sample shows how to
* update the rebilling cycle. See comments below
* on the details of the initial setup of the rebilling cycle as well as the
* updated rebilling cycle.

package rebill;
import bluepay.*;
import java.util.HashMap;

public class Update_Recurring_Payment {

  public static void main(String[] args) {

    String ACCOUNT_ID = "Merchant's Account ID Here";
    String SECRET_KEY = "Merchant's Secret Key Here";
    String MODE = "TEST";

    BluePay rebill = new BluePay(

    // Set Customer Information 
    HashMap<String, String> customerParams = new HashMap<>();
    customerParams.put("firstName", "Bob");
    customerParams.put("lastName", "Tester");
    customerParams.put("address1", "123 Test St.");
    customerParams.put("address2", "Apt #500");
    customerParams.put("city", "Testville");
    customerParams.put("state", "IL");
    customerParams.put("zip", "54321");
    customerParams.put("country", "USA");
    customerParams.put("phone", "123-123-12345");
    customerParams.put("email", "[email protected]");

    // Set Credit Card Information
    HashMap<String, String> ccParams = new HashMap<>();
    ccParams.put("cardNumber", "4111111111111111");
    ccParams.put("expirationDate", "1225");
    ccParams.put("cvv2", "123");

    // Set recurring payment
    HashMap<String, String> rebillParams = new HashMap<>();
    rebillParams.put("firstDate", "2015-01-01"); // Rebill Start Date: Jan. 1, 2015
    rebillParams.put("expr", "1 MONTH"); // Rebill Frequency: 1 MONTH
    rebillParams.put("cycles", "12"); // Rebill # of Cycles: 12
    rebillParams.put("amount", "15.00"); // Rebill Amount: $15.00

    // Sets a Card Authorization at $0.00
    HashMap<String, String> authParams = new HashMap<>();
    authParams.put("amount", "0.00");

    //  Makes the API Request to create a rebill
    try {
    } catch (Exception ex) {
      System.out.println("Exception: " + ex.toString());

    // Creates a payment information update
    BluePay paymentInformationUpdate = new BluePay(

      // Sets an updated credit card expiration date
      HashMap<String, String> ccParams2 = new HashMap<>();
      ccParams2.put("expirationDate", "1229");

      // Stores new card expiration date
      HashMap<String, String> authParams2 = new HashMap<>();
      authParams2.put("amount", "0.00");
      authParams2.put("transactionID", rebill.getTransID()); // the id of the rebill to update

      // Makes the API Request to update the payment information
      try {
      } catch (Exception ex) {
        System.out.println("Exception: " + ex.toString());
      // Creates a request to update the rebill
      BluePay rebillUpdate = new BluePay(

      // Updates the rebill
      HashMap<String, String> rebillUpdateParams = new HashMap<>();
      rebillUpdateParams.put("rebillID", rebill.getRebillingID()); // The ID of the rebill to be updated.
      rebillUpdateParams.put("templateID", paymentInformationUpdate.getTransID()); // Updates the payment information portion of the rebilling cycle with the new card expiration date entered above
      rebillUpdateParams.put("nextDate", "2015-03-01");
      rebillUpdateParams.put("expr", "1 MONTH");
      rebillUpdateParams.put("cycles", "8");
      rebillUpdateParams.put("rebillAmount", "5.15");
      rebillUpdateParams.put("nextAmount", "1.50");

      // Makes the API Request to update the rebill
      try {
      } catch (Exception ex) {
        System.out.println("Exception: " + ex.toString());

      // Reads the response from BluePay
      if (rebill.isSuccessful()) {
        System.out.println("Rebill Status: " + rebillUpdate.getRebillStatus());
        System.out.println("Rebill ID: " + rebillUpdate.getRebillingID());
        System.out.println("Rebill Creation Date: " + rebillUpdate.getRebillCreationDate());
        System.out.println("Rebill Next Date: " + rebillUpdate.getRebillNextDate());
        System.out.println("Rebill Last Date: " + rebillUpdate.getRebillLastDate());
        System.out.println("Rebill Schedule Expression: " + rebillUpdate.getRebillSchedExpr());
        System.out.println("Rebill Cycles Remaining: " + rebillUpdate.getRebillCyclesRemain());
        System.out.println("Rebill Amount: " + rebillUpdate.getRebillAmount());
        System.out.println("Rebill Next Amount: " + rebillUpdate.getRebillNextAmount()
        } else {

Can’t find what you’re
looking for? We can help.

Contact 800-350-2684 for Integration Support.

  • Microsoft Gold Partner Badge
  • 2018 American Business Awards Gold Stevie® Winner Badge for Best Payment and Electronic Commerce Solution
  • 2018 CNP Awards Customer Choice Winner Badge for Best E-Commerce Platform/Gateway
  • Best in Biz Awards 2018 Silver Winner Badge for Business Development Department of the Year
  • TSG Gateway Awards 2019 BluePay
BluePay Processing, LLC is a registered ISO of Wells Fargo Bank, N.A., Concord, CA, 94524 U.S.A.
BluePay Canada ULC, is a Registered ISO/MSP of Peoples Trust Company, Vancouver, Canada.