6

I get a 520009 error (Account xx@xx.com is restricted) when trying to make a parallel payment. My code worked fine using the sandbox but I switched to the live endpoint and it began failing. The account in question is a valid paypal account and I am using "feespayer=SENDER". Am I missing something? Shouldn't the pay call go through even if the payee is a basic account? Why would this occur?

Here is my code for reference

function deposit($config) {
    try {
        if (isset($config['return_url']))
            $this->return_url = $config['return_url'];
        else
            return 'Return URL should be set';

        if (isset($config['return_url']))
            $this->cancel_url = $config['cancel_url'];
        else
            return 'Cancel URL should be set';

        if (isset($config['email']))
            $this->sender_email = $config['email'];
        else
            return 'Email should be defined';

        if (isset($config['amount']))
            $this->amount = $config['amount'];
        else
            return 'Amount should be defined';

        $returnURL = $this->return_url;
        $cancelURL = $this->cancel_url;
        $currencyCode = 'USD';
        $memo = 'Deposit to ' . $this->ci->config->item('site_name');
        $feesPayer = 'SENDER';


        $payRequest = new PayRequest();
        $payRequest->actionType = "PAY";
        $payRequest->cancelUrl = $cancelURL;
        $payRequest->returnUrl = $returnURL;
        $payRequest->clientDetails = new ClientDetailsType();
        $payRequest->clientDetails->applicationId = $this->ci->config->item('application_id');
        $payRequest->clientDetails->deviceId = $this->ci->config->item('device_id');
        $payRequest->clientDetails->ipAddress = $this->ci->input->ip_address();
        $payRequest->currencyCode = $currencyCode;
        //$payRequest->senderEmail = $this->sender_email;
        $payRequest->requestEnvelope = new RequestEnvelope();
        $payRequest->requestEnvelope->errorLanguage = "en_US";

        $receivers = array();

        $receiver = new receiver();
        $receiver->email = $this->ci->config->item('moneyfan_account');
        $receiver->amount = $this->amount;
        $receiver->primary = 'false';

        $receivers[] = $receiver;

        $payRequest->receiverList = $receivers;
        $payRequest->feesPayer = $feesPayer;
        $payRequest->memo = $memo;

        $ap = new AdaptivePayments();
        $response = $ap->Pay($payRequest);            
        if (strtoupper($ap->isSuccess) == 'FAILURE') {


            $this->ci->session->set_userdata('FAULTMSG', $ap->getLastError());
            return json_encode(array('status' => 'false', 'msg' => $ap->getLastError()->error->errorId .' : '. $ap->getLastError()->error->message));
            //redirect(site_url('home/api_error'));
        } else {
            $this->ci->session->set_userdata('payKey', $response->payKey);
            if ($response->paymentExecStatus == "COMPLETED") {
                redirect($returnURL);
            } else {
                $token = $response->payKey;
                $payPalURL = PAYPAL_REDIRECT_URL . '_ap-payment&paykey=' . $token;
                return json_encode(array('status' => 'true', 'msg' => $payPalURL));
                //header("Location: " . $payPalURL);
            }
        }
    } catch (Exception $ex) {

        $fault = new FaultMessage();
        $errorData = new ErrorData();
        $errorData->errorId = $ex->getFile();
        $errorData->message = $ex->getMessage();
        $fault->error = $errorData;
        $this->ci->session->set_userdata('FAULTMSG', $fault);
        redirect(site_url('home/api_error'));
    }
}
Avinash
  • 790
  • 2
  • 11
  • 26

2 Answers2

7

No! You cannot do that with a basic account.

For API to work you need to have a VERIFIED Business Account.

In their API it says:

NOTE:
The application owner must have a PayPal Business account.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
1

There are two sources of reference for the PayPal API: cms.paypal.com pages like the one referenced by Mihai Iorga, and www.x.com pages like this one: https://www.x.com/developers/paypal/documentation-tools/going-live-with-your-application

On x.com, it says you must have a verified business account, even though it is unclear from cms.paypal.com that this is the case.

guyrt
  • 927
  • 7
  • 12