Unilateral receiver not allowed in chained payment is restricted – Adaptive Payment DotNet SDK

Hey everyone,

Just an error I ran into today while using the Adaptive Payments SDK for C#/.NET:

Unilateral receiver not allowed in chained payment is restricted

Thankfully this one is fairly simple – one of the receivers hasn’t confirmed their account.

http://stackoverflow.com/a/32816078/522859

This type of fee payer x isn’t recognized by our system – PayPal Adaptive Payments SDK

Hey everyone,

Just another Adaptive Payments SDK error I’ve run into.

Error Id: 560027
This type of fee payer x isn’t recognized by our system

This one is fairly self explanatory, valid values are as follows:

SENDER – Sender pays all fees (for personal, implicit simple/parallel payments; do not use for chained or unilateral payments)
PRIMARYRECEIVER – Primary receiver pays all fees (chained payments only)
EACHRECEIVER – Each receiver pays their own fee (default, personal and unilateral payments)
SECONDARYONLY – Secondary receivers pay all fees (use only for chained payments with one secondary receiver)

This parameter is described in the following documentation: https://developer.paypal.com/docs/classic/api/adaptive-payments/Pay_API_Operation/

Cannot parse *.config file – AdaptivePayments SDK (PayPal)

Hey everyone,

Just working on a small project that uses PayPal’s C# AdaptivePayments SDK. I hit an error while attempting to make the following payment:

var service = new AdaptivePaymentsService();
payResponse = service.Pay(payRequest);
“Cannot parse *.config file. Ensure you have configured the ‘paypal’ section correctly.”

at PayPal.Manager.ConfigManager..ctor()
at PayPal.Manager.ConfigManager.get_Instance()
at PayPal.BasePayPalService..ctor()
at PayPal.AdaptivePayments.AdaptivePaymentsService..ctor()

It turns out that you need to add the following entries to your Web.config:


To get the account information you’ll need to do the following:
– Go to developer.paypal.com
– Login to your sandbox account
– Go to the dashboard
– Select accounts (from the list of all your sandbox accounts)
– Create a new one or select an existing business account
– Click profile
– Click API Credentials

Note that the steps required to get this configuration seem to change all the time. Hopefully this will be enough to get you on the right track.

Request for ConfigurationPermission failed while attempting to access configuration section ‘paypal’ – PayPal & GoDaddy

Hey everyone,

I ran into the following error today while working with PayPal on a GoDaddy hosted server:

Request for ConfigurationPermission failed while attempting to access configuration section ‘paypal’. To allow all callers to access the data for this section, set section attribute ‘requirePermission’ equal ‘false’ in the configuration file where this section is declared.

To fix it, all you need to do is add the requirePermission attribute to the section declaration. Note that this is not where it says paypal but under the configsections heading.


    
    

My Selling Tools Option Missing – PayPal

Hey everyone,

For some reason the “My Selling Tools” option is now missing on my production account. Unfortunately the only way to get around this that I’ve come across is to access the required features directly. For example:

API Access:
https://www.paypal.com/cgi-bin/customerprofileweb?cmd=_profile-api-access

If you’ve got any other links that might be useful please let me know and I’ll add them.

PayPal IPN Response Not Returning a pay_key Value

Hey everyone,

In order to verify that a pay response is legitimate, PayPal provides a unique token for each request. This token can then be matched against payment confirmation requests to ensure that they aren’t being spoofed. The problem I ran into was that even the legitimate IPNs I received did not contain a pay key.

It turns out that PayPal sends two different types of IPNs. The first is configured when making the API request. The second is configured in the PayPal account under “My Account > Profile > Instant PayPal Notification”.

The first type, includes the required PayKey, the second does not. Simply configure your profile details to point to another url and everything should work!

For more info, check out this stackoverflow post: http://stackoverflow.com/a/12031887/522859

Working IPN Handler with Parallel Payments – PayPal Adaptive Payments

Hey everyone,

Just a dummy implementation of a Parallel Payment and an accompanying IPN Handler using the C#/.NET SDK. Feel free to use it however you like.

//Handles PayPal IPN
        public String IPN()
        {
            //Post back to either sandbox or live
            string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
            //string strLive = "https://www.paypal.com/cgi-bin/webscr";
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);

            ////Set values for the request back
            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            byte[] param = Request.BinaryRead(Request.ContentLength);
            string strRequest = Encoding.ASCII.GetString(param);
            strRequest += "&cmd=_notify-validate";
            req.ContentLength = strRequest.Length;

            //Send the request to PayPal and get the response
            StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
            streamOut.Write(strRequest);
            streamOut.Close();
            StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
            string strResponse = streamIn.ReadToEnd();
            streamIn.Close();

            if (strResponse == "VERIFIED")
            {
                //check the payment_status is Completed
                //check that txn_id has not been previously processed
                //check that receiver_email is your Primary PayPal email
                //check that payment_amount/payment_currency are correct
                //process payment
            }
            else if (strResponse == "INVALID")
            {
                //log for manual investigation
            }
            else
            {
                //log response/ipn data for manual investigation
            }


            return "";
        }

        //Pay for an order
        public void Pay(int OrderId)
        {
            RequestEnvelope envelopeRequest = new RequestEnvelope();
            envelopeRequest.errorLanguage = "en_US";
            PaySample paySample = new PaySample();
           
            List listReceiver = new List();
            // Amount to be credited to the receiver's account
            Receiver receiverA = new Receiver(Convert.ToDecimal("4.00"));

            // A receiver's email address
            receiverA.email = "test_buyer1@learnerlessons.com.au";
            listReceiver.Add(receiverA);

            // Amount to be credited to the receiver's account
            Receiver receiverB = new Receiver(Convert.ToDecimal("2.00"));

            // A receiver's email address
            receiverB.email = "test_buyer2@learnerlessons.com.au";
            listReceiver.Add(receiverB);

            ReceiverList receiverList = new ReceiverList(listReceiver);

            PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "http://localhost:53034/orders/cancel", "AUD", receiverList, "http://localhost:53034/orders/return");
            requestPay.reverseAllParallelPaymentsOnError = true;
            requestPay.ipnNotificationUrl = "http://123.123.123.123/Orders/IPN";

            //Send request to paypal, retrieve payKey
            PayResponse payResponse = paySample.PayAPIOperations(requestPay);

            Response.Redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + payResponse.payKey);
        }

Configuring Custom Settings – PayPal C# SDK

Hey everyone,

I’ve been mucking around with the C# SDK for PayPal Adaptive Payments. Unfortunately the docs aren’t too great and the samples are a little confusing until you get your head around them.

One of the main issues I’ve had is working out how to configure payment request settings i.e. reverseAllparallelPaymentsOnError.

To do this, simple utilise the PayRequest class:

PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "http://localhost:53034/orders/cancel", "AUD", receiverList, "http://localhost:53034/orders/return");
requestPay.reverseAllParallelPaymentsOnError = true;

Application ID – PayPal Sandbox

Hey everyone,

Just setting up an app that using the .NET Adaptive Payments SDK. Looking through the sandbox I was able to find the api signature, password and username but not the application ID (My Account > Overview > Account Information > API Access).

It turns out that ALL sandbox apps share the same ID:

Application ID: APP-80W284485P519543T

How to Block PayPal eCheque Payments

Hey everyone,

Just a quick post on how to block eCheque payments. These are payments that take up to seven days to process and be approved. The site I am currently working on is in no position to reserve services for such a long period of time, so the request has been made to block non-instant payment methods.

In the sandbox environment, you just need to do the following:

  • Login to your applications PayPal account at sandbox.paypal.com
  • Press the My Account tab
  • Select profile (just underneath my account)
  • Under selling preferences, click Payment Receiving Preferences
  • Under Block the following payments, check ‘Payments by eCheque on your website. Note: You may not block echeque payments on eBay’

The credit card statement name can also be set here. Let me know if you have any trouble.

Cheers,
Chris