2
votes

I'm working with Adaptive Payments using PayPal SDK for .Net. I'm trying to use SetPaymentOptions method to set the items I wish to display in the Payment Summary section, however, when I redirect the site to the sandbox approval page using the pay key I received from the Pay method, the payment summary only shows one row that says "faciliator account's Test Store" and the total amount.

The response returns a success code, plus I see that other parameters, such as BuisnessName (in DisplayOptions) are showing up on the page.

Following is the code I'm trying to execute (the parameters are replaced by real values that map to actual accounts, urls, amounts, etc.). Can anybody tell me what I'm doing wrong?

Thanks!

        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 = "[email protected]";
        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 = "[email protected]";

        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 = "[email protected]"
                        },
                        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);

            // ....
        }
1
Did you ever have any luck implementing this? I'm not having any luck getting the invoice items to show up, and would like to know if you could share any success/results you've had.MatthewT
I gave up the adaptive payments all together, and using express checkout instead.hillasm

1 Answers

2
votes

I am using adaptive chained payments with embedded checkout.

When using adaptive payments, you cannot customize payment pages beyond what you have already done.

I have spent quite a lot of time on the phone with PayPal on this topic. SenderOptions, ReceiverOptions and InvoiceData information that you set in Payment Options are only available in Instant Payment Notifications. The good news is that IPN is easy to implement.

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

You can parse the IPN info and send emails to your buyer and seller.

If you want PayPal's emails to include any additional information, you are limited to the memo field of the PaymentRequest. In your example:

reqPay.sender = new SenderIdentifier();
reqPay.sender.email = "[email protected]";
string memo = "Item: " + item_name + " " + item_price + SOME_NONSENSE_DELIMITER;
requestPay.memo = memo;
PayResponse responsePay = service.Pay(reqPay);

SOME_NONSENSE_DELIMITER is needed to act as an end-of-line because, unfortunately, line feeds and html are ignored, but at least something shows up in PayPal's correspondence to the receiver that way.