.net - PayPal - 付款摘要不显示“设置付款选项”设置的项目

标签 .net paypal paypal-adaptive-payments

我正在使用 PayPal SDK for .Net 来处理自适应支付。 我正在尝试使用 SetPaymentOptions 方法来设置我希望在“付款摘要”部分中显示的项目,但是,当我使用从“付款”方法收到的付款 key 将网站重定向到沙箱审批页面时,付款摘要仅显示一行写着“服务商帐户的测试商店”和总金额。

响应返回成功代码,此外我还看到页面上显示了其他参数,例如 BuisnessName(在 DisplayOptions 中)。

以下是我尝试执行的代码(参数被映射到实际帐户、网址、金额等的实际值替换)。 谁能告诉我我做错了什么?

谢谢!

        AdaptivePaymentsService service = new AdaptivePaymentsService();
        RequestEnvelope envelopeRequest = new RequestEnvelope();
        envelopeRequest.errorLanguage = "en_US";

        List<Receiver> listReceiver = new List<Receiver>();
        Receiver receive = new Receiver((decimal)300.15);
        receive.email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c3e292f29253a293e0c212d2520622f2321" rel="noreferrer noopener nofollow">[email protected]</a>";
        listReceiver.Add(receive);
        ReceiverList listOfReceivers = new ReceiverList(listReceiver);

        PayRequest reqPay = new PayRequest(envelopeRequest, "CREATE", "url",
            "USD", listOfReceivers, "url");
        reqPay.sender = new SenderIdentifier();
        reqPay.sender.email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ee9d8b808a8b9cae838f8782c08d8183" rel="noreferrer noopener nofollow">[email protected]</a>";

        PayResponse responsePay = service.Pay(reqPay);

        if (responsePay != null && responsePay.responseEnvelope.ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
        {
            SetPaymentOptionsRequest payOptionsReq = new SetPaymentOptionsRequest();
            payOptionsReq.displayOptions = new DisplayOptions()
            {
                businessName = "My business name"
            };
            payOptionsReq.payKey = responsePay.payKey;
            payOptionsReq.requestEnvelope = envelopeRequest;
            payOptionsReq.receiverOptions = new List<ReceiverOptions>()
                {
                    new ReceiverOptions()
                    {
                        receiver = new ReceiverIdentifier()
                        {
                            email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c6b4a3a5a3afb0a3b486aba7afaae8a5a9ab" rel="noreferrer noopener nofollow">[email protected]</a>"
                        },
                        description = "invoice test",
                        invoiceData = new InvoiceData()
                        {
                            item = new List<InvoiceItem>()
                            {
                                new InvoiceItem()
                                {
                                    identifier = "1",
                                    itemCount = 2,
                                    itemPrice = (decimal)100.0,
                                    name = "test",
                                    price = (decimal)150.0
                                },
                                new InvoiceItem()
                                {
                                    identifier = "2",
                                    itemCount = 1,
                                    itemPrice = (decimal)100.0,
                                    name = "test2",
                                    price = (decimal)150.15
                                }
                            },
                            totalShipping = 0,
                            totalTax = 0
                        }
                    }
                };

            SetPaymentOptionsResponse r = service.SetPaymentOptions(payOptionsReq);

            // ....
        }

最佳答案

我正在使用带有嵌入式结账功能的自适应链式支付。

使用自适应付款时,您无法自定义超出已完成的付款页面。

我花了很多时间与 PayPal 通电话讨论这个话题。您在付款选项中设置的 SenderOptions、ReceiverOptions 和 InvoiceData 信息仅在即时付款通知中可用。好消息是 IPN 很容易实现。

http://www.codeproject.com/Tips/84538/Setting-up-PayPal-Instant-Payment-Notification-IPN

您可以解析 IPN 信息并向买家和卖家发送电子邮件。

如果您希望 PayPal 的电子邮件包含任何其他信息,您只能使用 PaymentRequest 的备注字段。在您的示例中:

reqPay.sender = new SenderIdentifier();
reqPay.sender.email = "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7d4c2c9c3c2d5e7cac6cecb89c4c8ca" rel="noreferrer noopener nofollow">[email protected]</a>";
string memo = "Item: " + item_name + " " + item_price + SOME_NONSENSE_DELIMITER;
requestPay.memo = memo;
PayResponse responsePay = service.Pay(reqPay);

需要 SOME_NONSENSE_DELIMITER 来充当行尾,因为不幸的是,换行符和 html 会被忽略,但至少在 PayPal 与接收者的通信中会显示一些内容。

关于.net - PayPal - 付款摘要不显示“设置付款选项”设置的项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18463476/

相关文章:

c# - 不兼容引用 : System. 管理 4.0.0.0?

php - 我需要哪种 Paypal 服务?

TotalAmount上的php PayPal结帐错误

ios - Paypal 信用卡交易在沙盒模式下不起作用

带有服务器端 Url.Content 的 JavaScript 语法

c# - WPF 和后台 worker 以及调用线程必须是 STA

c# - 如何从属性中创建具有属性的元素

paypal - 如何在 PayPal 沙盒网站上测试 "checkout without a PayPal account"?

PayPal 链式付款错误 520009

PayPal 自适应支付 API - 延迟链支付(PHP、JavaScript)