Cancel a Recurring Payment

This code cancels a customer's recurring payments.

You can only cancel future recurring payments. If a payment has already been settled, you must issue a refund instead.
For that Go to: Reverse a sale

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

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, sets up
# a rebilling cycle, and also shows how to cancel that rebilling cycle.
# See comments below on the details of the initial setup of the
# rebilling cycle.

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

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

rebill =
  account_id: ACCOUNT_ID, 
  secret_key: SECRET_KEY, 
  mode: MODE

  first_name: "Bob",
  last_name: "Tester",
  address1: "123 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-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

# 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?
  rebill_cancel =
    account_id: ACCOUNT_ID, 
    secret_key: SECRET_KEY, 
    mode: MODE

  # Find rebill by id and cancel rebilling cycle

  # Makes the API request to cancel the rebill

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