我使用 2Cechout 创建了一个沙盒帐户,并按照.NET 教程了解如何创建销售。我似乎找不到任何关于如何使用相同的 api 创建经常性销售的文档。谁能提供一个例子?
问问题
1053 次
1 回答
1
我得到了答案。要通过 Payment API 传递定期销售,您需要完全省略“total”参数,而是使用“charge”数组的子对象传递定期订单项。
从 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);
}
这应该适用于经常性销售。
于 2015-09-10T23:38:09.033 回答