I created a sandbox account with 2Chechout and followed the .NET tutorial on how to create a sale. I cannot seem to find any documentation on how to create a recurring sale using the same api. Can anyone provide an example?
I got the answer. To pass in a recurring sale via the Payment API, you will need to omit the "total" parameter entirely, and instead pass in recurring lineitems using a sub-object of the "charge" array.
Example edited from 2Checkout:
TwoCheckoutConfig.SellerID = "901248156";
TwoCheckoutConfig.PrivateKey = "8CE03B2D-FE41-4C53-9156-52A8ED5A0FA3";
// TwoCheckoutConfig.Sandbox = true; #Uncomment to use Sandbox
try
{
var Billing = new AuthBillingAddress();
Billing.addrLine1 = "123 test st";
Billing.city = "Columbus";
Billing.zipCode = "43123";
Billing.state = "OH";
Billing.country = "USA";
Billing.name = "Testing Tester";
Billing.email = "example@2co.com";
Billing.phoneNumber = "5555555555";
var LineItem = new AuthLineitem();
LineItem.duration = "Forever";
LineItem.name = "Recurrencing Item Name";
LineItem.price = (decimal)10.00;
LineItem.productId = "12345";
LineItem.quantity = 1;
LineItem.startupFee = (decimal)10.00;
LineItem.recurrence = "1 Month";
LineItem.tangible = "N";
LineItem.type = "product";
var LineItems = new List<AuthLineitem>();
LineItems.Add(LineItem);
var Customer = new ChargeAuthorizeServiceOptions();
//Customer.total = (decimal)1.00; --> omit this
Customer.currency = "USD";
Customer.merchantOrderId = "123";
Customer.billingAddr = Billing;
Customer.token = Request["token"];
Customer.lineItems = LineItems; // --> add this
var Charge = new ChargeService();
var result = Charge.Authorize(Customer);
Console.Write(result);
}
catch (TwoCheckoutException e)
{
Console.Write(e);
}
This should work for recurring sales.