Update a Recurring Payment

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 makes method calls utilizing our ruby gem.
Download BluePay gem
Or, download via GitHub

# BluePay Ruby 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.

require_relative "../../lib/bluepay.rb"

ACCOUNT_ID = "Merchant's Account ID Here"
SECRET_KEY = "Merchant's Secret Key Here"

rebill = BluePay.new(
  account_id: ACCOUNT_ID, 
  secret_key: SECRET_KEY, 
  mode: MODE

  first_name: "Bob",
  last_name: "Tester",
  address1: "1234 Test St.",
  address2: "Apt #500",
  city: "Testville",
  state: "IL",
  zip_code: "54321",
  country: "USA",
  phone: "123-123-1234", 
  email: "[email protected]

  cc_number: "4111111111111111", # Customer Credit Card Number
  cc_expiration: "1225", # Card Expiration Date: MMYY
  cvv2: "123" # Card CVV2

  reb_first_date: "2015-01-05", # Rebill Start Date: Jan. 5, 2015
  reb_expr: "1 MONTH", # Rebill Frequency: 1 MONTH
  reb_cycles: "5", # Rebill # of Cycles: 5
  reb_amount: "3.50" # Rebill Amount: $3.50

# Sets a Card Authorization at $0.00
rebill.auth(amount: "0.00")

# Makes the API Request to create a rebill

# If transaction was approved..
if rebill.successful_transaction?

  payment_information_update = BluePay.new(
    account_id: ACCOUNT_ID, 
    secret_key: SECRET_KEY, 
    mode: MODE 

  # Sets an updated credit card expiration date
    cc_expiration: "1229" # Card Expiration

  # Stores new card expiration date
    amount: "0.00",
    trans_id: rebill.get_trans_id # the id of the rebill to update
  # Makes the API Request to update the payment information

  # Creates a request to update the rebill
  rebill_update = BluePay.new(
    account_id: ACCOUNT_ID, 
    secret_key: SECRET_KEY, 
    mode: MODE 

  # Updates the rebill
    rebill_id: rebill.get_rebill_id, # The ID of the rebill to be updated. 
    template_id: payment_information_update.get_trans_id, # Updates the payment information portion of the rebilling cycle with the new card expiration date entered above
    next_date: "2015-03-01", # Rebill Start Date: March 1, 2015
    reb_expr: "1 MONTH", # Rebill Frequency: 1 MONTH
    reb_cycles: "8", # Rebill # of Cycles: 8
    reb_amount: "5.15", # Rebill Amount: $5.15
    next_amount: "1.50" # Rebill Next Amount: $1.50
  # Makes the API Request to update the rebill

  # Reads the response from BluePay
  puts "REBILL STATUS: " + rebill_update.get_rebill_status
  puts "REBILL ID: " + rebill_update.get_reb_id
  puts "REBILL CREATION DATE: " + rebill_update.get_creation_date
  puts "REBILL NEXT DATE: " + rebill_update.get_next_date
  puts "REBILL LAST DATE: " + rebill_update.get_last_date
  puts "REBILL SCHEDULE EXPRESSION: " + rebill_update.get_sched_expression
  puts "REBILL CYCLES REMAINING: " + rebill_update.get_cycles_remaining
  puts "REBILL AMOUNT: " + rebill_update.get_rebill_amount
  puts "REBILL NEXT AMOUNT: " + rebill_update.get_next_amount
  puts rebill.get_message
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.