Paypal REST API payment.create不创建付款
我有一个后端web服务(不是网页),它试图从前端客户端创建付款。在经历了几次之后,我没有在细节和事务列表之间进行数据匹配,我从沙坑中得到了合适的错误消息,解释了什么是错误的,我最终得到了payment.create方法,以便在不引发异常的情况下执行。不幸的是,虽然我可以看到测试web服务和paypal之间存在SSL通信,但当例程返回时,我没有链接,也没有创建状态。我可能完全误解了api的机制,但由于调用中没有任何错误或异常,我有点困惑 以下是我正在使用的代码:Paypal REST API payment.create不创建付款,paypal,Paypal,我有一个后端web服务(不是网页),它试图从前端客户端创建付款。在经历了几次之后,我没有在细节和事务列表之间进行数据匹配,我从沙坑中得到了合适的错误消息,解释了什么是错误的,我最终得到了payment.create方法,以便在不引发异常的情况下执行。不幸的是,虽然我可以看到测试web服务和paypal之间存在SSL通信,但当例程返回时,我没有链接,也没有创建状态。我可能完全误解了api的机制,但由于调用中没有任何错误或异常,我有点困惑 以下是我正在使用的代码: var config =
var config = ConfigManager.Instance.GetProperties();
var clientid = config[BaseConstants.ClientId];
var clientSecret = config[BaseConstants.ClientSecret];
var accessToken = new OAuthTokenCredential(clientid, clientSecret, config).GetAccessToken();
var apiContext = new APIContext(accessToken);
var itemList = new ItemList() { items = new List<Item>() };
using (var context = new PETTEntities3())
{
SubscriptionType subType = context.SubscriptionTypes.FirstOrDefault(s => s.SubscriptionTypeID == Subscription.SubscriptionTypeID);
itemList.items.Add(new Item()
{
name = subType.SubscriptionName,
currency = "NZD",
price = (Subscription.Amount / (decimal)1.15).ToString("0.00"),
quantity = "1",
sku = subType.SubscriptionTypeID.ToString()
});
var payer = new Payer() { payment_method = "paypal" };
var redirectUrls = new RedirectUrls()
{
cancel_url = ConfigurationManager.AppSettings["PaymentConfirmationURL"] + Subscription.PaymentApprovalID,
return_url = ConfigurationManager.AppSettings["PaymentCancellationURL"] + Subscription.PaymentApprovalID
};
var details = new Details()
{
tax = (Subscription.Amount - decimal.Parse((Subscription.Amount / (decimal)1.15).ToString("0.00"))).ToString("0.00"),
subtotal = (Subscription.Amount / (decimal)1.15).ToString("0.00"),
shipping="0"
};
var amount = new Amount()
{
currency = "NZD",
total = Subscription.Amount.ToString("0.00"),
details = details
};
var transactionList = new List<Transaction>();
transactionList.Add(new Transaction()
{
description = "PETT Subscription.",
invoice_number = "PETT1420" + Subscription.SubscriptionID.ToString(),
amount = amount,
item_list = itemList
});
Payment payment = new Payment()
{
intent = "sale",
payer = payer,
transactions = transactionList,
redirect_urls = redirectUrls
};
payment.Create(apiContext);
.... At this point the payment state is still null and no links are present even though I appear to have a successful call with no exceptions.
var config=ConfigManager.Instance.GetProperties();
var clientid=config[BaseConstants.clientid];
var clientSecret=config[BaseConstants.clientSecret];
var accessToken=新的OAuthTokenCredential(clientid、clientSecret、config).GetAccessToken();
var apiContext=新的apiContext(accessToken);
var itemList=new itemList(){items=new List()};
使用(var context=new pettenties3())
{
SubscriptionType子类型=context.SubscriptionTypes.FirstOrDefault(s=>s.SubscriptionTypeID==Subscription.SubscriptionTypeID);
itemList.items.Add(新项()
{
name=subType.SubscriptionName,
货币=“新西兰元”,
价格=(认购金额/(十进制)1.15)。ToString(“0.00”),
quantity=“1”,
sku=subType.SubscriptionTypeID.ToString()子类型
});
var payer=new payer(){payment_method=“paypal”};
var redirectUrls=新的重定向URL()
{
取消\u url=ConfigurationManager.AppSettings[“PaymentConfirmationURL”]+Subscription.PaymentApprovalID,
return\u url=ConfigurationManager.AppSettings[“PaymentCancellationURL”]+Subscription.PaymentApprovalID
};
var details=new details()
{
税=(Subscription.Amount-decimal.Parse((Subscription.Amount/(decimal)1.15).ToString(“0.00”).ToString(“0.00”),
小计=(认购金额/(十进制)1.15)。ToString(“0.00”),
shipping=“0”
};
var金额=新金额()
{
货币=“新西兰元”,
总计=认购金额ToString(“0.00”),
细节=细节
};
var transactionList=新列表();
transactionList.Add(新事务()
{
description=“PETT订阅。”,
发票号=“PETT1420”+Subscription.SubscriptionID.ToString(),
金额=金额,
项目列表=项目列表
});
付款=新付款()
{
intent=“销售”,
付款人=付款人,
事务=事务列表,
重定向\u URL=重定向URL
};
payment.Create(apiContext);
..此时,付款状态仍然为空,没有链接存在,即使我似乎有一个成功的呼叫,没有例外。
对于我所缺少的任何线索或见解,我们将不胜感激。Doh,非常明显。我们没有注意函数签名payment.create,它会返回一个新的付款。这是您需要使用的,而不是用于调用create的付款,例如: Payment paymentouse=付款。创建(apiContext) Paymentouse拥有我想要的所有商品