简体   繁体   English

ASP.Net核心:PayPal结账端点

[英]ASP.Net Core: PayPal checkout endpoint

I've been searching the internet about how I can add a PayPal payment endpoint in an ASP.Net Core website but unfortunately all available recourses suggest either using the PayPal SDK library which is not supported by .Net core, or providing extremely long, useless and incomplete stories with a lot of missing parts such as the actual URL (or possible example) of the API to which I have post the payment request. 我一直在互联网上搜索如何在ASP.Net Core网站上添加PayPal支付终端,但不幸的是,所有可用的资源都建议使用.Net核心不支持的PayPal SDK库,或提供极长,无用的还有不完整的故事,其中包含许多缺失的部分,例如我发布付款请求的API的实际网址(或可能的示例)。

All I'm asking for in this question is just basic information such as the actual URL of the API to which I have to communicate as well as the parameters I have to pass to that API and an example of the response I may get (not looking for an implementation). 我在这个问题中要求的只是基本信息,例如我必须与之通信的API的实际URL以及我必须传递给该API的参数以及我可能获得的响应示例(不是寻找实施)。 I have been unable to find this information. 我一直无法找到这些信息。

You need to pass the variables in the following format: 您需要以以下格式传递变量:

private void PayPal()
{
    string _MerchantEmail = "youremailwithpaypal@domain.com";
    string _ReturnURL = "https://www.yourwebsite.com/paymentsuccess";
    string _CancelURL = "https://www.yourwebsite.com/paymentfailed";
    string _CurrencyCode = "USD";
    int _Amount = 100;
    string _ItemName = "itme1"; //We are using this field to pass the order number
    int _Discount = 10;
    double _Tax = 1.5;
    string _PayPalURL = $"https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business={_MerchantEmail}&return={_ReturnURL}&cancel_return={_CancelURL}&currency_code={_CurrencyCode}&amount={_Amount}&item_name={_ItemName}&discount_amount={_Discount}&tax={_Tax}";

    Response.Redirect(_PayPalURL);
}

You might also need a callback URL for PayPal IPN to verify the payments status. 您可能还需要PayPal IPN的回调网址来验证付款状态。 But for your question above this should work as we are already using this code in our website. 但是对于上面的问题,这应该可行,因为我们已经在我们的网站上使用此代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM