Tag Archives: Adaptive Payments

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.


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:

<!-- Under configuration > configSections. Add the following entry -->
<section name="paypal" type="PayPal.Manager.SDKConfigHandler, PayPalCoreSDK" requirePermission="false"></section>
<!-- Under configuration. Add the following entry and modify to suit your app -->
      <add name="endpoint" value="https://svcs.sandbox.paypal.com/"/>
      <add name="AdaptivePayments" value="https://svcs.sandbox.paypal.com/"/>
      <add name="connectionTimeout" value="360000"/>
      <add name="requestRetries" value="3"/>
      <add name="IPAddress" value=""/><!-- May need to change this depending on your configuration -->
      <account apiUsername="xxx" apiPassword="xxx" apiSignature="xxx" applicationId="APP-80W284485P519543T"/>

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.

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.

  1. //Handles PayPal IPN
  2.         public String IPN()
  3.         {
  4.             //Post back to either sandbox or live
  5.             string strSandbox = "https://www.sandbox.paypal.com/cgi-bin/webscr";
  6.             //string strLive = "https://www.paypal.com/cgi-bin/webscr";
  7.             HttpWebRequest req = (HttpWebRequest)WebRequest.Create(strSandbox);
  9.             ////Set values for the request back
  10.             req.Method = "POST";
  11.             req.ContentType = "application/x-www-form-urlencoded";
  12.             byte[] param = Request.BinaryRead(Request.ContentLength);
  13.             string strRequest = Encoding.ASCII.GetString(param);
  14.             strRequest += "&cmd=_notify-validate";
  15.             req.ContentLength = strRequest.Length;
  17.             //Send the request to PayPal and get the response
  18.             StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);
  19.             streamOut.Write(strRequest);
  20.             streamOut.Close();
  21.             StreamReader streamIn = new StreamReader(req.GetResponse().GetResponseStream());
  22.             string strResponse = streamIn.ReadToEnd();
  23.             streamIn.Close();
  25.             if (strResponse == "VERIFIED")
  26.             {
  27.                 //check the payment_status is Completed
  28.                 //check that txn_id has not been previously processed
  29.                 //check that receiver_email is your Primary PayPal email
  30.                 //check that payment_amount/payment_currency are correct
  31.                 //process payment
  32.             }
  33.             else if (strResponse == "INVALID")
  34.             {
  35.                 //log for manual investigation
  36.             }
  37.             else
  38.             {
  39.                 //log response/ipn data for manual investigation
  40.             }
  43.             return "";
  44.         }
  46.         //Pay for an order
  47.         public void Pay(int OrderId)
  48.         {
  49.             RequestEnvelope envelopeRequest = new RequestEnvelope();
  50.             envelopeRequest.errorLanguage = "en_US";
  51.             PaySample paySample = new PaySample();
  53.             List<Receiver> listReceiver = new List<Receiver>();
  54.             // Amount to be credited to the receiver's account
  55.             Receiver receiverA = new Receiver(Convert.ToDecimal("4.00"));
  57.             // A receiver's email address
  58.             receiverA.email = "test_buyer1@learnerlessons.com.au";
  59.             listReceiver.Add(receiverA);
  61.             // Amount to be credited to the receiver's account
  62.             Receiver receiverB = new Receiver(Convert.ToDecimal("2.00"));
  64.             // A receiver's email address
  65.             receiverB.email = "test_buyer2@learnerlessons.com.au";
  66.             listReceiver.Add(receiverB);
  68.             ReceiverList receiverList = new ReceiverList(listReceiver);
  70.             PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "http://localhost:53034/orders/cancel", "AUD", receiverList, "http://localhost:53034/orders/return");
  71.             requestPay.reverseAllParallelPaymentsOnError = true;
  72.             requestPay.ipnNotificationUrl = "";
  74.             //Send request to paypal, retrieve payKey
  75.             PayResponse payResponse = paySample.PayAPIOperations(requestPay);
  77.             Response.Redirect("https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_ap-payment&paykey=" + payResponse.payKey);
  78.         }

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:

  1. PayRequest requestPay = new PayRequest(envelopeRequest, "PAY", "http://localhost:53034/orders/cancel", "AUD", receiverList, "http://localhost:53034/orders/return");
  2. 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

Paypal_Adaptive IPN Verification: INVALID – Ruby on Rails

Hey everyone,

I’ve been working with the PayPal_Adaptive gem recently and unfortunately I’ve run into a few issues. The latest of these has been that that my IPN verification was returning an INVALID response from Paypal.

I had made a few modifications to the provided payment_notification.rb file in order to accommodate for a few app specific requirements. This left me having to pass the original data attribute params. Unfortunately this wasn’t identical to the response that PayPal expected, I actually needed to use the following:

#Incorrect usage
#Correct usage

I realised this error after reading Tanel’s post about securing your IPN interactions so make sure you check out his blog if you run into any more problems!


Paypal Platform Ruby SDK – Adaptive Payments

Hey everyone,

This is the SDK for PayPal adaptive payments. I’ve just uploaded it to *hopefully* make it a little easier to find. Please note that it has not been updated recently and that there are a few changes to be made. The StackOverflow post below provides a few examples:

StackOverflow Post:
Adaptive Payments with Ruby

I’ll try to list any others as I come across them, but if you’ve got some of your own please let me know and I’ll try to keep the post up to date.

Download SDK here:
Paypal Platform SDK

Error #1:

Internal Server Error
undefined method `debug_rjs=' for ActionView::Base:Class

Remove the following line from your development.rb config file:

  1. PayPalPlatformRubySDK::Application.configure do
  2.   # Settings specified here will take precedence over those in config/environment.rb
  4.   # In the development environment your application's code is reloaded on
  5.   # every request.  This slows down response time but is perfect for development
  6.   # since you don't have to restart the webserver when you make code changes.
  7.   config.cache_classes = false
  9.   # Log error messages when you accidentally call methods on nil.
  10.   config.whiny_nils = true
  12.   # Show full error reports and disable caching
  13.   config.consider_all_requests_local       = true
  14.   #config.action_view.debug_rjs             = true <---- Comment this line out (no longer supported)
  15.   config.action_controller.perform_caching = false
  17.   # Don't care if the mailer can't send
  18.   config.action_mailer.raise_delivery_errors = false
  20.   # Print deprecation notices to the Rails logger
  21.   config.active_support.deprecation = :log
  23.   # Only use best-standards-support built into browsers
  24.   config.action_dispatch.best_standards_support = :builtin
  25. end

Paypal IPN History:
For some reason the IPN history button often won’t appear in the sandbox, use the following link to view it:

IPN Notifications:
Just a warning for anyone else setting up payments with PayPal, the sandbox IPN is extremely flaky. It has gone down twice in the last six months for weeks at a time, with no warning or error messages. If you’re not receiving the IPN check out the forums to make sure it’s not down.