Subscription Billing

In order to setup subscription billing, there a few steps you have to go through.  These are listed below in c# examples.  

1.Setup the Merchant for Subscription Billing.  This is done through the SIS API. See Sign-On Authentication for information on how to get a sessionToken.

		string merchantProfileId = "Joe's Gym";

var merchantProfiles = sisClient.GetMerchantProfilesByProfileId(sessionToken, merchantProfileId);

merchantProfiles.First().RecurringBilling = new RecurringBilling
{
    ApplicationId = "123456",
    AutomaticRetries = true,
    DaysTillRetry = 6,
    EmailNotificationToCustomer = true,
NotifyCustFromEMailAddress = "Notifications@merchant.com",
NotifyMerchToEMailAddress = "Admin@merchant.com", Proration_Downgrades = true,
Proration_Upgrades = true,
SECCode = "POP",
ServiceId_CC = "7DC6200001", } sisClient.SaveMerchantProfiles(sessionToken, serviceId, TenderType.Credit, merchantProfiles);

Note: NotifyCustFromEMailAddress is the email address the RBS generated emails to customers will appear to be from.

Note: NotifyMerchToEMailAddress is the merchant's email address that they want to receive notices from RBS at.

2.Create a Billing Plan (required).  This and all remaing calls are performed through the RBS API. 

		BillingPlan plan = new BillingPlan
{
	Active = true,
	BillingCycleDuration = 1,
	BillingDayOfMonth = 31,
	Description = "Access to weights and cardio, no classes",
	Identifier = "BasicGymPlan",
	NeverExpires = false,
	NumberOfBillingCycles = 10,
	PlanName = "Basic Gym Plan",
	Price = 20m,
	SubFailureOption = Subscription.FailureOption.Cancel,
	TrialDuration = 14
};  

rbsClient.CreateBillingPlan(sessionToken, plan, "Joe's Gym");
	

3.Create Add-Ons (optional)

		Addon addon = new Addon
{
	Active = true,
	Amount = 5m,
	Description = "Two classes per week",
	Name = "Extra Classes",
	NeverExpires = true,
	NumberOfBillingCycles = 0
};

rbsClient.CreateAddon(sessionToken, addon, "Joe's Gym");

4.Create Discounts (optional)

		Discount discount = new Discount
{
	Active = true,
	Amount = 5m,
	Description = "Friend referral discount",
	Name = "Referral",
	NeverExpires = false,
	NumberOfBillingCycles = 3
};

rbsClient.CreateDiscount(sessionToken, Discount, "Joe's Gym");

5.Create a Customer with a Payment Method

Customer customer = new Customer
{
	Email = "John@Johnson.com",
	FirstName = "John",
	LastName = "Johnson",
	Phone = "1231234123",
};

CreditCardInfo cardInfo = new CreditCardInfo
{
	AccountNumber = "4111111111111111",
	CardHolderName = "John Johnson",
	ExpirationDate = "1214"
};

AddressInfo addressInfo = new AddressInfo
{
	City = "Thorn Town",
	Country = "USA",
	PostalCode = "80602",
	State = "CO",
	StreetAddress = "123 Any Street"
};

var customerResponse = rbsClient.CreateCustomerWithCredit(sessionToken, customer, cardInfo, addressInfo, "Joe's Gym");

7.  Finally, create a Subscription

SubscriptionInfo subinfo = new SubscriptionInfo
{
	BillingPlanIdentifier = "BasicGymPlan",
	PaymentMethodIdentifier = customerResponse.PaymentMethodIdentifier
}; rbsClient.CreateSubscription(sessionToken, subInfo, "Joe's Gym");

And that's it!  Your subscription will be billed on the last day of the month as you prescribed.

Keep reading for Additional Subscription Billing Information

 

Updated: 11/30/16 ~DS

Comments