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 calls a routine from our Code Library.
Download BluePay.cs
Or, download via GitHub

* BluePay C#.NET 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.
using System;
using BluePayLibrary;

namespace Rebill
    class CancelRecurringPayment
        public static void Main()
            string accountID = "Merchant's Account ID Here";
            string secretKey = "Merchant's Secret Key Here";
            string mode = "TEST";

            BluePay rebill = new BluePay

                firstName: "Bob",
                lastName: "Tester",
                address1: "1234 Test St.",
                address2: "Apt #500",
                city: "Testville",
                state: "IL",
                zip: "54321",
                country: "USA",
                phone: "123-123-12345",
                email: "[email protected]"
                ccNumber: "4111111111111111",
                ccExpiration: "1225",
                cvv2: "123"

            // Sets recurring payment
                rebFirstDate: "2015-01-01", // Rebill Start Date: Jan. 1, 2015
                rebExpr: "1 MONTH", // Rebill Frequency: 1 MONTH
                rebCycles: "12", // Rebill # of Cycles: 12
                rebAmount: "15.00" // Rebill Amount: $15.00

            // Sets a Card Authorization at $0.00
            rebill.Auth(amount: "0.00");

            // Makes the API Request

            // If transaction was approved..
            if (rebill.IsSuccessfulTransaction())

                BluePay rebillCancel = new BluePay

                // Find the rebill by ID and cancel rebilling cycle

                // Makes the API Request

                // Reads the responses from BluePay
                Console.WriteLine("Rebill Status: " + rebillCancel.GetStatus());
                Console.WriteLine("Rebill ID: " + rebillCancel.GetRebillID());
                Console.WriteLine("Rebill Creation Date: " + rebillCancel.GetCreationDate());
                Console.WriteLine("Rebill Next Date: " + rebillCancel.GetNextDate());
                Console.WriteLine("Rebill Schedule Expression: " + rebillCancel.GetSchedExpr());
                Console.WriteLine("Rebill Cycles Remaining: " + rebillCancel.GetCyclesRemain());
                Console.WriteLine("Rebill Amount: " + rebillCancel.GetRebillAmount());
Can’t find what you’re
looking for? We can help.

Contact 800-350-2684 for Integration Support.

  • Microsoft Gold Partner Badge
  • Susan G. Komen for the Cure Supporter
  • 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
  • 2017 TSG Gateway Awards Winner Badge for Best Onboarding Process
  • Best in Biz Awards 2018 Silver Winner Badge for Business Development Department of the Year
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.