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

# 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 "bluepay"

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: "1215", # 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
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.