Question

I'm working on an App where a user A can buy up to 10 items from different sellers, so I need to send money to different users at the same time and I'm trying to use Paypal Chained Payments.

Right now I'm just playing around with Classic API (Adaptive payments) but I'm just wondering why I'm always getting this error:

 "The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified"

I already specified a primary receiver and I'm still getting that error.

I found these examples: https://paypal-sdk-samples.herokuapp.com/adaptive_payments/pay and I tried to do a chained payment:

This is my pay request:

require 'paypal-sdk-adaptivepayments'
@api = PayPal::SDK::AdaptivePayments::API.new

# Build request object
@pay = @api.build_pay({
  :actionType => "PAY",
  :cancelUrl => "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/pay",
  :currencyCode => "USD",
  :feesPayer => "PRIMARYRECEIVER",
  :ipnNotificationUrl => "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/ipn_notify",
  :receiverList => {
    :receiver => [{
      :amount => 1.0,
      :email => "platfo_1255612361_per@gmail.com",
      :primary => true }] },
  :returnUrl => "https://paypal-sdk-samples.herokuapp.com/adaptive_payments/pay",
  :sender => {
    :useCredentials => true } })

# Make API call & get response
@pay_response = @api.pay(@pay)

And this is the response

{
  :responseEnvelope => {
    :timestamp => "2013-11-20T05:16:31-08:00",
    :ack => "Failure",
    :correlationId => "b002d0e27fd33",
    :build => "7935900" },
  :error => [{
    :errorId => 580023,
    :domain => "PLATFORM",
    :subdomain => "Application",
    :severity => "Error",
    :category => "Application",
    :message => "The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified",
    :parameter => [{
      :value => "feesPayer" },{
      :value => "PRIMARYRECEIVER" }] }] }

Thanks in advance!

Was it helpful?

Solution

taking a look at your call, you're indeed specifying a primary receiver. however, for chained payment, you will have to specify a secondary receiver.

I just ran a quick test with the following paramters:

actionType = PAY  
requestEnvelope.errorLanguage = en_US  
cancelUrl = http://abortURL  
returnUrl = http://returnURL  
ipnNotificationUrl = http://ipnURL  
applicationId = Test  
memo = Test   
currencyCode = USD  
receiverList.receiver(0).email = test@test.com  
receiverList.receiver(0).amount = 5.00  
receiverList.receiver(0).primary = true  
feesPayer = PRIMARYRECEIVER

and got the result:

responseEnvelope.timestamp=2013-11-20T05:41:56.751-08:00  
responseEnvelope.ack=Failure  
responseEnvelope.correlationId=b61a6b31ea2ab  
responseEnvelope.build=7935900  
error(0).errorId=580023  
error(0).domain=PLATFORM  
error(0).subdomain=Application  
error(0).severity=Error  
error(0).category=Application  
error(0).message=The fee payer PRIMARYRECEIVER can only be used if a primary receiver is specified  
error(0).parameter(0)=feesPayer  
error(0).parameter(1)=PRIMARYRECEIVER

However, once I change the FeesPayer to EACHRECEIVER, I get the error message that is causing the chained payment to fail in the first place:

responseEnvelope.timestamp=2013-11-20T05:48:09.202-08:00  
responseEnvelope.ack=Failure  
responseEnvelope.correlationId=987210ec4d03a  
responseEnvelope.build=7935900  
error(0).errorId=579008  
error(0).domain=PLATFORM  
error(0).subdomain=Application  
error(0).severity=Error  
error(0).category=Application  
error(0).message=You must specify only one primary receiver and at least one secondary receiver  
error(0).parameter(0)=1

I hope this helps.

Please refer to the PayPal Adaptive Payments SDK available under http://paypal.github.io/#adaptive-payments for some additional examples and inspiration

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top