RecurringBilling Code Examples


This KB entry includes simple sample code for different gateways using RecurringBilling component.

Below are code examples for different gateways supported in the E-Payment Integrator. If you require additional sample code for a gateway please contact support@4dpayments.com.

Gateways

Authorize.Net

Create an ARB (Automatic Recurring Billing) service on Authorize.net:

Recurringbilling recurring = new Recurringbilling(); // Gateway deets recurring.Gateway = RecurringbillingGateways.gwAuthorizeNet; recurring.GatewayURL = "https://apitest.authorize.net/xml/v1/request.api"; recurring.MerchantLogin = "YourLogin"; recurring.MerchantPassword = "YourPassword"; // Customer deets EPCustomer cust = new EPCustomer(); cust.FirstName = "John"; cust.LastName = "Smith"; cust.FullName = "John M. Smith"; cust.Address = "123 Nowhere Ln."; cust.City = "Beverly Hills"; cust.State = "CA"; cust.Zip = "90210"; cust.Country = "USA"; cust.Phone = "555-555-5555"; cust.Email = "jsmith@fake.com"; cust.Id = "123456"; // Card deets CCCard card = new CCCard(); card.Number = "4788250000028291"; // This is just a test card from authorize.net card.ExpMonth = 12; card.ExpYear = 2020; card.EntryDataSource = EntryDataSources.edsManualEntryNoCardReader; // Subscription deets recurring.SubscriptionName = "YourSubscriptionName"; recurring.PaymentSchedule.StartDate = "04/15/2017"; recurring.PaymentSchedule.EndDate = "04/15/2018"; recurring.PaymentSchedule.Frequency = "1"; recurring.PaymentSchedule.FrequencyUnit = "M"; recurring.PaymentSchedule.RecurAmount = "00.01"; recurring.PaymentSchedule.TotalPayments = 12; recurring.Customer = cust; recurring.Card = card; // Create the subscription recurring.CreateSubscription();

Authorize.Net CIM

Create a CIM profile on Authorize.net:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwAuthorizeNetCIM; recurring.GatewayURL = "https://apitest.authorize.net/xml/v1/request.api"; //This is your Authorize.Net UserId / Name recurring.MerchantLogin = "Name"; //This is your Authorize.Net Transaction Key recurring.MerchantPassword = "TransactionKey"; recurring.Card.Number = "5424000000000015"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 21; recurring.Card.CVVData = "999"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Address = "1 Test Street"; recurring.Customer.City = "Test City"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "27717"; recurring.Customer.Country = "USA"; recurring.ShippingInfo.Address = "1st St."; recurring.ShippingInfo.City = "1st City"; recurring.ShippingInfo.State = "NC"; recurring.ShippingInfo.Zip = "98765"; recurring.ShippingInfo.Country = "US"; recurring.TransactionId = "Sample"; recurring.Customer.Id = "123456789"; recurring.CreateSubscription(); Console.WriteLine("Profile Id : " + recurring.Response.SubscriptionId); Console.WriteLine("Profile Payment Id : " + recurring.Config("AuthNetCIMPaymentProfileId")); Console.WriteLine("Profile Shipping Id : " + recurring.Config("AuthNetCIMShippingAddressId"));

BASYS

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); string profileId; string CCInfoID; string contractID; recurring.Gateway = RecurringbillingGateways.gwBASYS; //This is your UserName recurring.MerchantLogin = "UserName"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantID"); //This will create a Customer Profile. recurring.Config("BASYSRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Add Credit Card information. recurring.Config("BASYSRequestType=1"); recurring.Config("BASYSCustomerKey=" + profileId); recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // credit card profile was created successfully CCInfoID = recurring.Config("BASYSCardInfoKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Credit Card Profile : " + CCInfoID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Create Payment Schedule //This will add a Payment Schedule information to an existing profile recurring.Config("BASYSRequestType=3"); recurring.Config("BASYSCustomerKey=" + profileId); //Default -- CC Payment Schedule recurring.Config("BASYSPaymentType=0"); //This is the CCInfoID here: recurring.Config("BASYSCardInfoKey=" + CCInfoID); //This is set by the merchant. recurring.Config("BASYSContractId=12345"); recurring.Customer.FirstName = "John";Pc recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; recurring.PaymentSchedule.RecurAmount = "2.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.EndDate = DateTime.Now.AddMonths(3).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.FrequencyUnit = "Weekly"; recurring.Config("BASYSNextBillingDate=" + DateTime.Now.AddDays(2).ToString("MM/dd/yyyy")); try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // payment schedule was created successfully contractID = recurring.Config("BASYSContractKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Contract ID : " + contractID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; }

Beanstream

Create and update a subscription:

//This is the "merchant_id" recurring.MerchantLogin = "218010000"; //This is the "username" recurring.Config("BeanstreamUsername=nsoftware"); //This is the "password" recurring.MerchantPassword = "password"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Address = "1234 Main St"; recurring.Customer.Zip = "V8T5J1"; recurring.Customer.City = "Victoria"; recurring.Customer.State = "BC"; recurring.Customer.Country = "CA"; recurring.Customer.Email = "Test@test.com"; recurring.Customer.Phone = "9195555555"; recurring.Card.ExpMonth = 1; recurring.Card.ExpYear = 2015; recurring.Card.CVVData = "123"; recurring.Card.Number = "4030000010001234"; recurring.InvoiceNumber = "1234"; recurring.PaymentSchedule.FrequencyUnit = "M"; recurring.PaymentSchedule.Frequency = "1"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId; //When calling UpdateSubscription, CancelSubscription, or GetSubscriptionStatus //this is the Recurring Billing API "passcode" recurring.MerchantPassword = "201f5c38a85647E485BB8eaf17B7ED01"; recurring.Card = new CCCard(); recurring.Customer = new EPCustomer(); recurring.PaymentSchedule = new EPPaymentSchedule(); recurring.PaymentSchedule.RecurAmount = "20.00"; recurring.UpdateSubscription(subId);

Chase/YourPay/FirstData/LinkPoint

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwLinkPoint; recurring.GatewayURL = "staging.linkpt.net:1129"; //Test URL //This is your store number recurring.MerchantLogin = "1909977744"; //The certificate is provided by the gateway recurring.SSLCert = new Certificate(CertStoreTypes.cstPEMKeyFile, "..\\..\\files\\linkpoint.pem", "", "*"); recurring.Card.ExpMonth = 1; recurring.Card.ExpYear = 16; recurring.Card.Number = "4111111111111111"; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.TransactionId = DateTime.Now.Ticks.ToString(); recurring.InvoiceNumber = DateTime.Now.Ticks.ToString(); recurring.SubscriptionDesc = "Test Transaction"; recurring.PaymentSchedule.RecurAmount = "12." + DateTime.Now.Minute.ToString("00"); //Avoid duplicate transactions a bit recurring.PaymentSchedule.TotalPayments = 10; recurring.PaymentSchedule.StartDate = DateTime.Now.ToString("MM/dd/yyyy"); recurring.PaymentSchedule.FrequencyUnit = "M"; recurring.PaymentSchedule.Frequency = "1"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Note: Chase, YourPay, FirstData, and LinkPoint all use the same implementation.

CyberSource

Create a subscription:

recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwCyberSource; recurring.GatewayURL = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/"; //This is your username recurring.MerchantLogin = "nsoft_test1"; //This is your transaction key generated from your merchant account online. //Be sure to generate this for the SOAP API, not the Simple Order API. recurring.MerchantPassword = "ruTCCovVZ2UMbfwG6a...LrS2xuoaubJrwA=="; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Doe"; recurring.Customer.Email = "nobody@cybersource.com"; recurring.Customer.Phone = "408-556-9100"; recurring.Customer.Address = "1295 Charleston Rd."; recurring.Customer.City = "Mountain View"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "94043-1307"; recurring.Customer.Country = "US"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 20; recurring.Card.CVVData = "123"; recurring.InvoiceNumber = "12"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "weekly"; recurring.PaymentSchedule.TotalPayments = 50; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

eProcessing

Create a subscription:

//This is your eProcessingNetwork account number. recurring.MerchantLogin = "080880"; recurring.MerchantPassword = "080880pw"; //Set this value if you have one recurring.AddSpecialField("RestrictKey", "yGqqXJh0Pqnugfr"); recurring.Card.CVVData = "999"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.Number = "4111111111111111"; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.SubscriptionDesc = "Test Transaction"; recurring.SubscriptionName = "TestRecur"; recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.CreateSubscription(); string subID = recurring.Response.SubscriptionId;

eWay

The eWay gateway requires management of the customer profile and subscription profile separately. The “EwayTransactionType” configuration setting determines the type of request that is made. A customer must exist before creating a subscription profile.

Create a Customer:

//Create and Update a customer recurring.Gateway = RecurringbillingGateways.gwEway; recurring.GatewayURL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx"; //This is your eWay username recurring.MerchantLogin = "support@test.com"; //This is your eWay password recurring.MerchantPassword = "password"; //This is your eWay customer Id recurring.Config("EwayCustomerId=91330478"); recurring.Card.Number = "4444333322221111"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Config("EwayTransactionType=1"); //Customer recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.CreateSubscription(); string customerId = recurring.Response.TransactionId; recurring.Customer.LastName = "Smith_Update"; recurring.UpdateSubscription(customerId);

Create a Subscription:

//Create a Subscription recurring.Gateway = RecurringbillingGateways.gwEway; recurring.GatewayURL = "https://www.eway.com.au/gateway/rebill/test/manageRebill_test.asmx"; //This is your eWay username recurring.MerchantLogin = "support@nsoftware.com.sand"; //This is your eWay password recurring.MerchantPassword = "Nsoft1111"; //This is your eWay customer Id recurring.Config("EwayCustomerId=91330478"); recurring.Card.Number = "4444333322221111"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Config("EwayTransactionType=0"); //Subscription (Rebill Event) recurring.PaymentSchedule.InitialAmount = "100"; recurring.Config("EwayInitialDate=" + DateTime.Now.AddDays(1).ToString("MM/dd/yyyy")); recurring.PaymentSchedule.RecurAmount = "500"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.EndDate = DateTime.Now.AddYears(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.FrequencyUnit = "Months"; recurring.PaymentSchedule.Frequency = "1"; recurring.TransactionId = customerId; //Previously created customer Id recurring.SubscriptionDesc = "Test"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

GoToBilling

The GoToBilling gateway requires management of the customer, account, and recurring billing profile separately. The “GoToBillingTransactionType” configuration setting determines the type of request that is made. Both a customer and account must exist before creating a subscription profile.

Create a Customer:

//Create and Update Customer recurring.Gateway = RecurringbillingGateways.gwGoToBilling; //This is your 6 digit MID recurring.MerchantLogin = "123456"; //This is your 6 digit PIN recurring.MerchantPassword = "123456"; recurring.Card.Number = "6011000000000012"; recurring.Card.ExpMonth = 4; recurring.Card.ExpYear = 2015; recurring.Card.CVVData = "999"; recurring.Customer.Id = "0000"; recurring.Customer.Address = "123 Nowhere Ln"; recurring.Customer.Zip = "90210"; recurring.Customer.Country = "840"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.Phone = "555-123-4567"; recurring.Customer.FirstName = "FirstName"; recurring.Customer.LastName = "LastName"; recurring.InvoiceNumber = "1234"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.Config("GoToBillingTransactionType=1"); // Customer recurring.SubscriptionName = "CustomerTest"; recurring.CreateSubscription(); string customerId = recurring.Response.SubscriptionId; recurring.Customer.State = "NC"; recurring.Customer.Phone = ""; recurring.UpdateSubscription(customerId);

Create an Account:

//Create an Account recurring.Gateway = RecurringbillingGateways.gwGoToBilling; //This is your 6 digit MID recurring.MerchantLogin = "123456"; //This is your 6 digit PIN recurring.MerchantPassword = "123456"; recurring.Config("GoToBillingTransactionType=2"); // 2 = Account recurring.Customer.Id = customerId; //Previously created customer recurring.CreateSubscription(); string accountId = recurring.Response.SubscriptionId;

Create a Recurring Transaction:

//Create a Recurring Transaction recurring.Gateway = RecurringbillingGateways.gwGoToBilling; //This is your 6 digit MID recurring.MerchantLogin = "123456"; //This is your 6 digit PIN recurring.MerchantPassword = "123456"; recurring.Config("GoToBillingTransactionType=0"); // 0 = Transaction recurring.Customer.Id = customerId; //Previously created customer recurring.TransactionId = accountId; //Previously created account recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.CreateSubscription();

iTransact/NexCommerce

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwITransact; //vendor ID recurring.MerchantLogin = "12345"; recurring.MerchantPassword = ""; //No password required recurring.Card.CVVData = ""; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.Number = "5454545454545454"; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Note: iTransact and NexCommerce use the same implementation.

Litle

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwLitle; recurring.GatewayURL = "https://prelive.litle.com/vap/communicator/online"; //Your Username recurring.MerchantLogin = "TestUser"; //Your Password recurring.MerchantPassword = "password"; //Your Merchant ID recurring.Config("MerchantCode=123456"); recurring.Card.Number = "4012002000060016"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 2025; recurring.Card.CVVData = "123"; recurring.Customer.Address = "123 Nowhere Ln."; recurring.Customer.Zip = "90210"; recurring.PaymentSchedule.InitialAmount = "100"; recurring.InvoiceNumber = "IN123456789"; recurring.AddSpecialField("id", "NS987654321"); recurring.Customer.Id = "Cust31"; recurring.TransactionId = "ANNUAL_PLAN"; recurring.PaymentSchedule.RecurAmount = "4000"; recurring.PaymentSchedule.TotalPayments = 6; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Merchant Partners

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwMerchantPartners; //Merchant ID recurring.MerchantLogin = "DEMO1"; //Merchant PIN recurring.MerchantPassword = "cL68s0srQbrhcPrTnxe9H8NT4rCvKG7x"; //Merchant Sub ID recurring.AddSpecialField("subid", "00002"); recurring.Card.Number = "4003000123456781"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 15; recurring.Card.CVVData = "123"; recurring.Customer.FullName = "John Doe"; recurring.Customer.Address = "123 Nowhere Ln"; recurring.Customer.Zip = "90210"; recurring.Customer.Country = "840"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "2"; recurring.PaymentSchedule.TotalPayments = 12; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Moneris/Moneris USA

Create a subscription:

//isUSA is a boolean value that determine whether to use the USA environment or the Canadian environment bool isUSA = true; Recurringbilling recurring = new Recurringbilling(); if (isUSA) { recurring.Gateway = RecurringbillingGateways.gwMonerisUSA; //Test URL recurring.GatewayURL = "https://esplusqa.moneris.com/gateway_us/servlet/MpgRequest"; //Your store_id recurring.MerchantLogin = "monusqa005"; //your api_token recurring.MerchantPassword = "qatoken"; } else { recurring.Gateway = RecurringbillingGateways.gwMoneris; //Test URL recurring.GatewayURL = "https://esqa.moneris.com/gateway2/servlet/MpgRequest"; //Your store_id recurring.MerchantLogin = "store5"; //your api_token recurring.MerchantPassword = "yesguy"; } recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.Number = "5454545454545454"; recurring.Card.CVVPresence = CCCVVPresences.cvpNotProvided; recurring.InvoiceNumber = DateTime.Now.Ticks.ToString(); recurring.Customer.Id = "987654321"; recurring.AddSpecialField("start_now", "true"); recurring.PaymentSchedule.InitialAmount = "5.00"; recurring.PaymentSchedule.RecurAmount = "10.00"; //Test environment will not approve anything over $11.00 recurring.PaymentSchedule.FrequencyUnit = "month"; recurring.PaymentSchedule.Frequency = "1"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(5).ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

MyVirtualMerchant

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwMyVirtualMerchant; //Merchant ID recurring.MerchantLogin = "123456"; //PIN recurring.MerchantPassword = "654321"; //User ID recurring.Config("MyVirtualMerchantUserId=123456"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Address = "123 Nowhere Ln"; recurring.Customer.Zip = "90210"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.State = "CA"; recurring.Customer.Country = "USA"; recurring.Customer.Email = "x@y.com"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 1; recurring.Card.ExpYear = 15; recurring.Card.CVVData = "999"; recurring.TransactionId = "1234"; recurring.InvoiceNumber = "123456"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "MONTHLY"; recurring.PaymentSchedule.StartDate = "03/07/2014"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

NetworkMerchants/Payscape/TransNational/Verifi

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwNetworkMerchants; //This is your username recurring.MerchantLogin = "demo"; //This is your password recurring.MerchantPassword = "password"; recurring.MerchantLogin = "demo"; recurring.MerchantPassword = "password"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 17; recurring.Card.CVVData = "123"; recurring.Customer.Address = "123 Nowhere Ln"; recurring.Customer.Zip = "90210"; recurring.Customer.Country = "840"; recurring.SubscriptionName = "monthly"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Note: NetworkMerchants, Payscape, TransNational, and Verifi all use the same implementation.

Orbital

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwOrbital; recurring.GatewayURL = "https://orbitalvar1.paymentech.net/authorize"; //Your Merchant ID recurring.MerchantLogin = "123456789012"; //Your BIN number recurring.MerchantPassword = "000002"; recurring.Card.Number = "4012888888881"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 14; recurring.Card.CVVData = "123"; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.Address2 = "Suite 123"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.SubscriptionDesc = "Test Transaction"; recurring.PaymentSchedule.RecurAmount = "100"; recurring.PaymentSchedule.StartDate = "04/12/2014"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.Frequency = "1 * ?"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

PayFlow Pro

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPayFlowPro; recurring.GatewayURL = "https://pilot-payflowpro.paypal.com"; //test URL //Your Merchant ID recurring.MerchantLogin = "userid"; //Your Password recurring.MerchantPassword = "password"; //The ID of your PayPal Reseller recurring.AddSpecialField("PARTNER", "PayPal"); recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.Number = "4222222222222"; recurring.SubscriptionName = "CustomerTest1"; recurring.PaymentSchedule.InitialAmount = "1.00"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Payments Gateway/ACH Payments

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPaymentsGateway; recurring.GatewayURL = "https://www.paymentsgateway.net/cgi-bin/posttest.pl"; //Test URL //Your Merchant ID recurring.MerchantLogin = "123456"; //Your Password recurring.MerchantPassword = "abc123"; recurring.Card.Number = "4200000000000000"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.InvoiceNumber = "123456789"; recurring.PaymentSchedule.InitialAmount = "1.00"; recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

PayTrace

Create a Customer Account:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPayTrace; recurring.GatewayURL = "https://paytrace.com/api/default.pay"; //Merchant ID recurring.MerchantLogin = "demo123"; //Password recurring.MerchantPassword = "demo123"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 1; recurring.Card.ExpYear = 15; recurring.Card.CVVData = "999"; recurring.Timeout = 600; recurring.Customer.Address = "8320"; recurring.Customer.Zip = "85284"; recurring.Config("PayTraceTransactionType=0"); // 0 = Customer recurring.CreateSubscription(); string custId = recurring.Response.TransactionId;

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPayTrace; recurring.GatewayURL = "https://paytrace.com/api/default.pay"; //Merchant ID recurring.MerchantLogin = "demo123"; //Password recurring.MerchantPassword = "demo123"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 1; recurring.Card.ExpYear = 15; recurring.Card.CVVData = "999"; recurring.Timeout = 600; recurring.Customer.Address = "8320"; recurring.Customer.Zip = "85284"; recurring.Config("PayTraceTransactionType=1"); // 1 = Recurring Billing recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.Frequency = "1"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddMonths(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.TotalPayments = 12; recurring.TransactionId = custId; //Customer ID created above recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

PayWiser

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); string RecurringPlanId; string CardToken; recurring.Gateway = RecurringbillingGateways.gwPayWiser; recurring.GatewayURL = "https://gateway.paywiser.eu/PaymentGatewayTest/PayWiserPG/"; //This is your API Key recurring.MerchantLogin = "YourAPIKey"; // Create Recurring Plan recurring.Config("PayWiserRequestType=0"); //These are required fields recurring.SubscriptionDesc = "Test Monthly Recurring Plan"; recurring.AddSpecialField("StatementText", "Test"); recurring.AddSpecialField("StatementDescription", "Test Statement Description"); recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.TotalPayments = 10; recurring.AddSpecialField("IsRecurring", "false"); recurring.AddSpecialField("MaxRetryCount", "0"); recurring.Config("PayWiserPaymentHour=10"); recurring.AddSpecialField("RenewYearly", "false"); //This should be unique for each transaction recurring.TransactionId = "1111111"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //Recurring Plan was created successfully RecurringPlanId = recurring.Response.SubscriptionId; Console.WriteLine("Recurring Plan Id: " + RecurringPlanId); } else { //There was an issue. throw new Exception(recurring.Response.ErrorText); } } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw; } //Next Step is to Tokenize the Credit Card recurring.Config("PayWiserRequestType=1"); //This will generate a Token recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; recurring.Card.CVVData = "999"; //This should be unique for each transaction recurring.TransactionId = "1111112"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //Token was created successfully CardToken = recurring.Config("PayWiserCardToken"); Console.WriteLine("Card Token: " + CardToken); } else { //There was an issue. throw new Exception(recurring.Response.ErrorText); } } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw; } //Create Recurring Payment recurring.Config("PayWiserRequestType=2"); //This will start Recurring Payment recurring.Config("PayWiserCardToken=" + CardToken); recurring.Config("PayWiserRecurringPlanId=" + RecurringPlanId); recurring.PaymentSchedule.StartDate = recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"); recurring.PaymentSchedule.TrialPayments = 1; recurring.PaymentSchedule.RecurAmount = "200"; recurring.AddSpecialField("AdjustPlanWithStartDate", "false"); //This should be unique for each transaction recurring.TransactionId = "1111113"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //Recurring Payment was started successfully Console.WriteLine("Recurring Reference Id: " + recurring.TransactionId); } else { //There was an issue. throw new Exception(recurring.Response.ErrorText); } } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw; }

PhoeniXGate

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); string profileId; string CCInfoID; string contractID; recurring.Gateway = RecurringbillingGateways.gwPhoeniXGate; //This is your UserName recurring.MerchantLogin = "UserName"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantID"); //This will create a Customer Profile. recurring.Config("PhoeniXGateRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Add Credit Card information. recurring.Config("PhoeniXGateRequestType=1"); recurring.Config("PhoeniXGateCustomerKey=" + profileId); recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // credit card profile was created successfully CCInfoID = recurring.Config("PhoenixGateCardInfoKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Credit Card Profile : " + CCInfoID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Create Payment Schedule //This will add a Payment Schedule information to an existing profile recurring.Config("PhoeniXGateRequestType=3"); recurring.Config("PhoeniXGateCustomerKey=" + profileId); //Default -- CC Payment Schedule recurring.Config("PhoeniXGatePaymentType=0"); //This is the CCInfoID here: recurring.Config("PhoeniXGateCardInfoKey=" + CCInfoID); //This is set by the merchant. recurring.Config("PhoeniXGateContractId=12345"); recurring.Customer.FirstName = "John";Pc recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; recurring.PaymentSchedule.RecurAmount = "2.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.EndDate = DateTime.Now.AddMonths(3).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.FrequencyUnit = "Weekly"; recurring.Config("PhoeniXGateNextBillingDate=" + DateTime.Now.AddDays(2).ToString("MM/dd/yyyy")); try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // payment schedule was created successfully contractID = recurring.Config("PhoenixGateContractKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Contract ID : " + contractID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; }

Planet Payment

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPlanetPayment; recurring.GatewayURL = "https://uap.txngw.com"; //Your Company Key recurring.MerchantLogin = "8990"; //your PIN recurring.MerchantPassword = "1234"; //Your terminal ID recurring.Config("TerminalId=6177"); recurring.Card.Number = "4000009999999991"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 17; recurring.Card.CVVData = "907"; recurring.Customer.FullName = "J.J.J. Smith"; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Address = "123 Nowhere Ln"; recurring.Customer.Zip = "90210"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.State = "CA"; recurring.Customer.Country = "US"; recurring.Customer.Email = "x@y.com"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.FrequencyUnit = "MONTHLY"; recurring.PaymentSchedule.Frequency = "1"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.Config("PlanetPaymentFrequencyDate=" + DateTime.Now.AddDays(2).Day.ToString()); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

PlugNPay

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwPlugNPay; //Your Merchant ID recurring.MerchantLogin = "pnpdemo2"; //Your Password recurring.MerchantPassword = "55pnpdemo55"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.CVVData = ""; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.Country = "USA"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = "02/08/2014"; recurring.SubscriptionName = "testrecur1"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

QuickBooks Merchant Services (QBMS)

Create a wallet:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwQBMS; recurring.GatewayURL = "https://merchantaccount.ptc.quickbooks.com/j/AppGateway"; //Your App Login recurring.MerchantLogin = "qbms_demo_april_2014.domain.com"; //Your Connection ID recurring.MerchantPassword = "connection_id"; recurring.Customer.Address = "123 Nowhere Ln."; recurring.Customer.Zip = "90210"; recurring.Customer.Id = "123456789"; recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 2025; recurring.Card.CVVData = "123"; recurring.Config("QBMSTransactionType=0"); //Wallet recurring.CreateSubscription(); string walletId = recurring.Response.TransactionId;

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); recurring.Gateway = RecurringbillingGateways.gwQBMS; recurring.GatewayURL = "https://merchantaccount.ptc.quickbooks.com/j/AppGateway"; //Your App Login recurring.MerchantLogin = "qbms_demo_april_2014.domain.com"; //Your Connection ID recurring.MerchantPassword = "connection_id"; recurring.Customer.Address = "123 Nowhere Ln."; recurring.Customer.Zip = "90210"; recurring.Config("QBMSTransactionType=1"); //Scheduled Billing recurring.Customer.Id = "123456789"; recurring.TransactionId = walletId; //Wallet ID created above recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.Frequency = "0 0 0 10 * ?"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Repay

Create a subscription:

Recurringbilling recurring = new Recurringbilling(); string profileId; string CCInfoID; string contractID; recurring.Gateway = RecurringbillingGateways.gwRepay; //This is your UserName recurring.MerchantLogin = "UserName"; //This is your Password recurring.MerchantPassword = "Password"; //This is your Merchant ID recurring.Config("MerchantCode=YourMerchantID"); //This will create a Customer Profile. recurring.Config("RepayRequestType=0"); recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { //profile was created successfully profileId = recurring.Response.SubscriptionId; } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Profile Id: " + profileId); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Add Credit Card information. recurring.Config("RepayRequestType=1"); recurring.Config("RepayCustomerKey=" + profileId); recurring.Card.Number = "4788250000028291"; recurring.Card.ExpMonth = 12; recurring.Card.ExpYear = 18; try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // credit card profile was created successfully CCInfoID = recurring.Config("RepayCardInfoKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Credit Card Profile : " + CCInfoID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; } //Create Payment Schedule //This will add a Payment Schedule information to an existing profile recurring.Config("RepayRequestType=3"); recurring.Config("RepayCustomerKey=" + profileId); //Default -- CC Payment Schedule recurring.Config("RepayPaymentType=0"); //This is the CCInfoID here: recurring.Config("RepayCardInfoKey=" + CCInfoID); //This is set by the merchant. recurring.Config("RepayContractId=12345"); recurring.Customer.FirstName = "John";Pc recurring.Customer.LastName = "Smith"; recurring.Customer.Id = "1001"; recurring.Customer.Address = "123 Main St"; recurring.Customer.City = "MyCity"; recurring.Customer.State = "NC"; recurring.Customer.Zip = "12345"; recurring.PaymentSchedule.RecurAmount = "2.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(1).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.EndDate = DateTime.Now.AddMonths(3).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.FrequencyUnit = "Weekly"; recurring.Config("RepayNextBillingDate=" + DateTime.Now.AddDays(2).ToString("MM/dd/yyyy")); try { recurring.CreateSubscription(); if (recurring.Response.Approved) { // payment schedule was created successfully contractID = recurring.Config("RepayContractKey"); } else { //There was an issue. throw new Exception(recurring.Response.Text); } Console.WriteLine("Contract ID : " + contractID); } catch (Exception ex) { Console.WriteLine("Request: " + recurring.Config("RawRequest")); Console.WriteLine("***************"); Console.WriteLine("Response: " + recurring.Response.Data); throw ex; }

SkipJack

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwSkipjack; //This is your HTML Serial Number recurring.MerchantLogin = "000000000000"; //This is your Developer Serial Number recurring.Config("TerminalId=987654321098"); recurring.Card.Number = "4242424242424242"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Customer.Address = "1234 Nowhere Ln"; recurring.Customer.City = "Beverly Hills"; recurring.Customer.Country = "US"; recurring.Customer.Email = "nobody@server.com"; recurring.Customer.FirstName = "John"; recurring.Customer.Id = "CUSTOMER1"; recurring.Customer.LastName = "Smith"; recurring.Customer.Phone = "555-555-5555"; recurring.Customer.State = "CA"; recurring.Customer.Zip = "90210"; recurring.InvoiceNumber = "12345"; recurring.PaymentSchedule.RecurAmount = "10.00"; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(5).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.Frequency = "3"; // 3 = Monthly recurring.PaymentSchedule.TotalPayments = 12; recurring.SubscriptionName = "Item1"; recurring.SubscriptionDesc = "Item1"; recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

Square

The RecurringBilling component is used to create, retrieve, update, and delete Square customer profiles, and to create and delete cards on those profiles.

Recurringbilling rb = new Recurringbilling(); rb.Gateway = RecurringbillingGateways.gwSquare; // This your access token. rb.MerchantLogin = "YOUR ACCESS TOKEN"; // First, create a profile. // Note that the customer's names, email, and phone are set using the Customer fields... rb.Customer.FirstName = "Fake"; rb.Customer.LastName = "Person"; rb.Config("CompanyName=CoolWidgets"); rb.AddSpecialField("nickname", "Fakie"); rb.Customer.Email = "fake@fake.com"; rb.Customer.Phone = "1234567890"; // ...but their physical address details are set using the ShippingInfo fields! rb.ShippingInfo.Address = "456 WhereAmI Dr"; rb.ShippingInfo.Address2 = "Apt 0"; rb.ShippingInfo.City = "Secret"; rb.ShippingInfo.State = "NC"; rb.AddSpecialField("address.administrative_district_level_2", "Cool County"); rb.ShippingInfo.Zip = "77777"; rb.ShippingInfo.Country = "US"; // The SquareRequestType configuration setting controls whether the CreateSubscription() // and CancelSubscription() methods operate against an overall customer profile (0), or // a card saved to a customer profile (1). The default is 0 (customer profile); we set it // explicitly here for the purpose of the example. rb.Config("SquareRequestType=0"); rb.CreateSubscription(); // Now that the profile was created, we can get the customer Id associated with it. string customerId = rb.Customer.Id; // Let's recreate the RecurringBilling component before continuing, to simulate // a real-world scenario where a customer profile is already created. rb = new Recurringbilling(); rb.Gateway = RecurringbillingGateways.gwSquare; rb.MerchantLogin = "YOUR ACCESS TOKEN"; // Now, imagine we want to update some part of a customer's information. It is important // that we retrieve the latest customer profile details first, otherwise when we send // the update request, we would end up removing any empty fields! // (A side note: Square does not allow updating cards, only customer details. You can // only create and delete cards.) // Let's retrieve the customer we created earlier. First, we set the customer Id value... rb.Customer.Id = customerId; // ...then we call GetSubscriptionStatus(). (The method argument is ignored.) rb.GetSubscriptionStatus(""); // Now that the RecurringBilling component is populated with the latest customer profile // information, we can change what we want to change, and then call UpdateSubscription() // to send the update request. rb.ShippingInfo.Address2 = ""; rb.UpdateSubscription(""); // Now, let's try adding a card to the profile. Similar to when using the ICharge component, // Square will not accept raw card details, only a card nonce created using a Square payment // form. We'll use a test card nonce from https://docs.connect.squareup.com/testing/test-values rb.Config("CardToken=fake-card-nonce-ok"); // Use the Customer fields to fill in the card's billing information. (Note that the FirstName // and LastName fields themselves are technically ignored, but if you don't specify a value for // the FullName field, the RecurringBilling component will automatically create one by joining // the values specified for FirstName and LastName.) rb.Customer.FullName = "Fake Person"; rb.Customer.Address = "123 Nowhere Ln"; rb.Customer.Address2 = "Apt 999"; rb.Customer.City = "Chapel Hill"; rb.Customer.State = "NC"; rb.AddSpecialField("billing_address.administrative_district_level_2", "Orange County"); rb.Customer.Zip = "94103"; // ("94103" must be the billing zip when using the fake card nonce.) rb.Customer.Country = "US"; // Remember, we have to set SquareRequestType to 1 to create or delete cards. rb.Config("SquareRequestType=1"); rb.CreateSubscription(); // Now, you can store the card Id. When using the ICharge component, it's possible to use a // combination of the customer Id plus a customer card Id as a payment method (instead of a // card nonce). See https://4dpayments.com/kb/epayment-gateway-code-examples/#square for more details. string custCardId = rb.Config("SquareCustomerCardId"); // Now, let's retrieve the overall profile again. rb.Customer.Id = customerId; rb.GetSubscriptionStatus(""); // In addition to the customer's basic information, this will now also return the information // of all of the cards that are saved to the customer profile. The SquareCustomerCardCount // configuration setting reflects the number of cards saved to the profile... Console.WriteLine("There are " + rb.Config("SquareCustomerCardCount") + " cards on the profile"); // ...and the SquareCustomerCardIndex configuration setting controls which card's details the // RecurringBilling component is currently populated with. Our profile only has one card on it // (and the index will automatically be set to 0 if there are any cards), but we'll set this // explicitly for the purpose of the example. rb.Config("SquareCustomerCardIndex=0"); // To have the component reset the fields used to reflect retrieved card data (see the docs for // the RecurringBilling component for information on which fields those are), just set the index // to -1: rb.Config("SquareCustomerCardIndex=-1"); // Now, let's reset the RecurringBilling component again. rb = new Recurringbilling(); rb.Gateway = RecurringbillingGateways.gwSquare; rb.MerchantLogin = "YOUR ACCESS TOKEN"; // This time, we'll delete the card (that we added previously) from the profile. rb.Customer.Id = customerId; rb.Config("SquareCustomerCardId=" + custCardId); rb.Config("SquareRequestType=1"); // So we will delete the card, not the profile! rb.CancelSubscription(""); // Now, let's delete the whole profile. (Note that, if there were any cards on the profile, this // would delete them too. In our example there are no cards though.) rb.Customer.Id = customerId; rb.Config("SquareRequestType=0"); rb.CancelSubscription("");

TransFirst Classic (formerly PRIGate)

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwPRIGate; //This is your merchant number (assigned by TransFirst) recurring.MerchantLogin = "12345678"; //This is your TransFirst Security Key recurring.MerchantPassword = "ABCDE12345"; recurring.Card.Number = "371449635392376"; recurring.Card.ExpMonth = 01; recurring.Card.ExpYear = 2015; recurring.Customer.Address = "123 Main"; recurring.Customer.Zip = "97229"; recurring.PaymentSchedule.RecurAmount = "1.00"; recurring.InvoiceNumber = DateTime.Now.Ticks.ToString(); recurring.SubscriptionDesc = "Test transaction"; recurring.PaymentSchedule.Frequency = "Monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.ToString("MM/dd/yy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

TransFirst (Transaction Central/Merchant Anywhere)

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwTransactionCentral; //This is your account number (assigned by TransFirst) recurring.MerchantLogin = "00000"; //This is your password recurring.MerchantPassword = "ABCDE12345FGHIJ"; // This is the only card data that is valid for testing. It fails but allows you to verify parsing the request. recurring.Card.Number = "4111111111111111"; recurring.Card.ExpMonth = 01; recurring.Card.ExpYear = 2015; recurring.Card.CVVData = "999"; recurring.Customer.Address = "123 Main"; recurring.Customer.Zip = "97229"; recurring.PaymentSchedule.RecurAmount = random.Next(1, 100).ToString() + ".00"; recurring.InvoiceNumber = DateTime.Now.Ticks.ToString(); recurring.SubscriptionDesc = "Test transaction"; recurring.PaymentSchedule.Frequency = "M"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.ToString("MM/dd/yyyy"); recurring.CreateSubscription(); string subId = recurring.Response.SubscriptionId;

USA ePay

Create a subscription:

recurring.Gateway = RecurringbillingGateways.gwUSAePay; //This is your UMKey/source key recurring.MerchantLogin = "_Fc5a9...1OR7A"; //MerchatPassword is not used recurring.MerchantPassword = ""; recurring.Card.EntryDataSource = EntryDataSources.edsManualEntryTrack1Capable; recurring.Card.Number = "4005562233445564"; recurring.Card.ExpMonth = 2; recurring.Card.ExpYear = 15; recurring.Card.CVVData = ""; recurring.Customer.FirstName = "John"; recurring.Customer.LastName = "Smith"; recurring.PaymentSchedule.Frequency = "monthly"; recurring.PaymentSchedule.TotalPayments = 12; recurring.PaymentSchedule.StartDate = DateTime.Now.AddDays(2).ToString("MM/dd/yyyy"); recurring.PaymentSchedule.RecurAmount = "9.99"; recurring.PaymentSchedule.InitialAmount = "10.00"; recurring.CreateSubscription();

We appreciate your feedback. If you have any questions, comments, or suggestions about this entry please contact our support team at support@4dpayments.com.