Asp.net mvc Paypal REST API-在支付过程中传递参数
我正在使用Paypal的.NETSDK将Paypal直接支付集成到我的ASP.NETMVC5项目中。以下是步骤:Asp.net mvc Paypal REST API-在支付过程中传递参数,asp.net-mvc,paypal,Asp.net Mvc,Paypal,我正在使用Paypal的.NETSDK将Paypal直接支付集成到我的ASP.NETMVC5项目中。以下是步骤: 我调用PayPal.Api.Payment.Create(APIContext)重定向到PayPal站点,并使用一个成功的url 在与成功url对应的回调操作中,调用PayPal.Api.Payment.Execute(APIContext,ExecutionContext) 我需要的是在调用Payment.Create()时将新订单的id传递给Paypal,并在Payment.Ex
可能吗?非常感谢。基于SDK和API帮助页面,我将利用事务中的
发票号
属性,您将发送到支付。创建()
结束点。此事务将是PayPal返回的响应的一部分,这意味着您可以从API获取订单号(现在称为发票号)
在下面找到这一行:invoice\u number=您的订单号
您的PayPal请求:()
var apiContext=Configuration.GetAPIContext();
//交易定义了付款合同——付款的目的和履行人。
var事务=新事务()
{
金额=新金额(){…},
description=“这是付款交易描述。”,
item_list=new ItemList(){…},
//在这里设置您的订单号
发票号=您的订单号
};
//一种资源,表示为付款提供资金的付款人。
var payer=new payer(){…};
//支付资源;使用上述类型和意图创建一个“销售”或“授权”`
var付款=新付款()
{
intent=“销售”,
付款人=付款人,
事务=新列表(){transaction}
};
this.flow.AddNewRequest(“创建信用卡支付”,支付);
//使用有效的APIContext创建付款
var createdPayment=payment.Create(apiContext);
来自PayPal()的响应:
嘿,汤米,谢谢你的建议,传递其他参数,比如发送订单的用户的应用程序用户名,怎么样?
var apiContext = Configuration.GetAPIContext();
// A transaction defines the contract of a payment - what is the payment for and who is fulfilling it.
var transaction = new Transaction()
{
amount = new Amount(){...},
description = "This is the payment transaction description.",
item_list = new ItemList(){...},
//SET YOUR ORDER NUMBER HERE
invoice_number = YOUR_ORDER_NUMBER
};
// A resource representing a Payer that funds a payment.
var payer = new Payer(){...};
// A Payment resource; create one using the above types and intent as `sale` or `authorize`
var payment = new Payment()
{
intent = "sale",
payer = payer,
transactions = new List<Transaction>() { transaction }
};
this.flow.AddNewRequest("Create credit card payment", payment);
// Create a payment using a valid APIContext
var createdPayment = payment.Create(apiContext);