如何在c#中的paypal自适应链式支付系统中使用PaymentAction

How to Use PaymentAction in paypal adaptive chained payment system in c#

我正在从事 MVC 项目,我需要在其中使用具有授权和捕获功能的自适应链式支付系统。

现在,我正在关注这个link:-

https://xadaptivepayments.codeplex.com/

此代码适用于在多个帐户中转移付款。但是我不知道如何在它重定向到沙箱帐户进行付款时添加 paymentaction 参数,以便卖家可以捕获付款。

我的代码如下:-

    IPayPalAdaptivePaymentService _paysvc = new PayPalAdaptivePaymentService();
        Uri redirectUrl = new Uri(ConfigurationManager.AppSettings["REDIRECT-URL"]);
        Uri returnUrl = new Uri(ConfigurationManager.AppSettings["PAYPAL-RETURNURI"]);
        Uri cancelUrl = new Uri(ConfigurationManager.AppSettings["PAYPAL-CANCELURI"]);
        string str = "asdsadsadsads";
        string seller = ConfigurationManager.AppSettings["PAYPAL-SELLER"];
        string paymentref = "test123";
        string currency = "USD";
        List<x.paypal.model.Receiver> receivers = new List<x.paypal.model.Receiver>();
        receivers.Add(new x.paypal.model.Receiver { Amount = "3", Email = "payments-facilitator@akaritutoring.com", InvoiceId = str, Description = "test paypal payment" });
        receivers.Add(new x.paypal.model.Receiver { Amount = "7", Email = "yashsharmanice1@gmail.com", InvoiceId = str, Description = "test paypal payment 1" });
         IPayRequest payRequest = new x.paypal.model.PayRequest().CreateRequest().WithPaymentReference(paymentref).WithReturnUri(returnUrl).WithCancelUri(cancelUrl).Currency(currency).ReceiverList(receivers);
         var resp = _paysvc.RequestPayment(payRequest);
         return Redirect("https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_ap-payment&paymentaction=authorization&paykey=" + resp.PayKey);

请帮我解决这个问题。

提前致谢...

actionType决定自适应支付中的支付动作。 Adaptive Payments 中没有 sale,order or auth 等付款操作。 您可以使用 PAY_PRIMARY 的 actionType 来延迟付款,以指定付款给主要收款人而不是次要收款人。

您需要运行 ExecutePaymentAPI 来获取付款

Authorization/Capture 在自适应支付中是不可能的,因为它们都在不同的单独模型中。

但是,您可以在 Adaptive Payments 中实现 Authorization/Capture 的概念,即使用 Preapproval Payments

通过在指定时间段内与您的买家设置特定金额的预先批准,买家可以通过授予您在未来规定的金额向他收取费用的权限来进行预先批准。 (授权)

获得preapproval key后,您现在可以随时向买家收费,类似于Capture的概念。

然后您将通过提供 preapprovalKey 和设置 actionType=PAY 来使用 Pay API operation 向买家收费,并将金额分配给主要和次要收款人。

你说的link很老了,不知道能不能支持上面的场景。您可以尝试研究它以实现上述概念。

如果没有,您可以在此处使用适用于 .NET 的自适应支付 SDK:https://www.nuget.org/packages/PayPalAdaptivePaymentsSDK/