C# Paypal REST API-返回url无法使用ASP.NET核心
我正在ASP.NET内核中尝试使用Paypal REST API进行支付处理。我正在成功创建付款并获得批准链接。我使用此链接将我的用户重定向到Paypal以获得批准。问题是支付审批Paypal未重定向回返回\u url 我的请求机构C# Paypal REST API-返回url无法使用ASP.NET核心,c#,asp.net-core,paypal,C#,Asp.net Core,Paypal,我正在ASP.NET内核中尝试使用Paypal REST API进行支付处理。我正在成功创建付款并获得批准链接。我使用此链接将我的用户重定向到Paypal以获得批准。问题是支付审批Paypal未重定向回返回\u url 我的请求机构 {"intent": "sale", "payer": {"payment_method": "paypal"}, "transactions&
{"intent": "sale", "payer": {"payment_method": "paypal"},
"transactions": [{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"handling_fee": "1.00",
"shipping_discount": "-1.00",
"insurance": "0.01"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE"
},
"soft_descriptor": "ECHI5786786",
"item_list": {
"items": [{
"name": "hat",
"description": "Brown color hat",
"quantity": "5",
"price": "3",
"tax": "0.01",
"sku": "1",
"currency": "USD"
}, {
"name": "handbag",
"description": "Black color hand bag",
"quantity": "1",
"price": "15",
"tax": "0.02",
"sku": "product34",
"currency": "USD"
}],
"shipping_address": {
"recipient_name": "Hello World",
"line1": "4thFloor",
"line2": "unit#34",
"city": "SAn Jose",
"country_code": "US",
"postal_code": "95131",
"phone": "011862212345678",
"state": "CA"
}
}
}],
"note_to_payer": "Contact us for any questions on your order.",
"redirect_urls": {
"return_url": "https://app.zoomtalktext.com/Accounts/ExecutepaypalPayment",
"cancel_url": "https://app.zoomtalktext.com/Accounts/Error"
}
}
回复wuith链接
{
"id": "PAYID-L63ONQQ6KC693998G275374V",
"intent": "sale",
"state": "created",
"payer": {
"payment_method": "paypal"
},
"transactions": [
{
"amount": {
"total": "30.11",
"currency": "USD",
"details": {
"subtotal": "30.00",
"tax": "0.07",
"shipping": "0.03",
"insurance": "0.01",
"handling_fee": "1.00",
"shipping_discount": "-1.00"
}
},
"description": "This is the payment transaction description.",
"custom": "EBAY_EMS_90048630024435",
"invoice_number": "48787589673",
"soft_descriptor": "ECHI5786786",
"payment_options": {
"allowed_payment_method": "INSTANT_FUNDING_SOURCE",
"recurring_flag": false,
"skip_fmf": false
},
"item_list": {
"items": [
{
"name": "hat",
"sku": "1",
"description": "Brown color hat",
"price": "3.00",
"currency": "USD",
"tax": "0.01",
"quantity": 5
},
{
"name": "handbag",
"sku": "product34",
"description": "Black color hand bag",
"price": "15.00",
"currency": "USD",
"tax": "0.02",
"quantity": 1
}
],
"shipping_address": {
"recipient_name": "Hello World",
"line1": "4thFloor",
"line2": "unit#34",
"city": "SAn Jose",
"state": "CA",
"postal_code": "95131",
"country_code": "US",
"phone": "011862212345678"
}
},
"related_resources": []
}
],
"note_to_payer": "Contact us for any questions on your order.",
"create_time": "2020-11-19T21:42:25Z",
"links": [
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L63ONQQ6KC693998G275374V",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-6TL51655R1984981G",
"rel": "approval_url",
"method": "REDIRECT"
},
{
"href": "https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L63ONQQ6KC693998G275374V/execute",
"rel": "execute",
"method": "POST"
}
]
}
批准后就留在那里
我的返回url代码
[HttpGet]
[Route("ExecutepaypalPayment")]
public IActionResult ExecutepaypalPayment(string paymentID,string payerID)
{
string AuthToken = GetAuthToken();
var client = new RestClient("https://api-m.sandbox.paypal.com/v1/payments/payment/"+paymentID+ "/execute");
client.Timeout = -1;
var requestNew = new RestRequest(Method.POST);
requestNew.AddHeader("Content-Type", "application/json");
requestNew.AddHeader("authorization", "Bearer " + AuthToken);
string param = "{payer_id\":" +payerID+"\"}";
requestNew.AddParameter("application/json", param, ParameterType.RequestBody);
IRestResponse responseNew = client.Execute(requestNew);
return Redirect("https://app.zoomtalktext.com/buy-credits/credits/addcredit");
}
这看起来不像是一个完整的批准,而且您在页面或控制台上没有显示任何错误。如果您正在使用ASP.NET Core MVC中的Orders v2 REST API查看PayPal签出的最新解决方案,请查看演示>>>