PHP adaptive payments

109 Views Asked by At

I'm trying to use Paypal parallel payments with an iOS app and after I found out that the iOS sdk does't support adaptive payments, I decided I would just pass data to a php file and let that handle the parallel payments for me, but I am completely new to PHP. I've managed to create a PHP project, install composer, and used it to add "paypal/adaptivepayments-sdk-php":"2.*" to my project. I'm trying to use their documentation to create payments, but I'm a little lost. Here is my code so far :

    <?php

require_once __DIR__ . '/vendor/autoload.php';


// Sets config file path(if config file is used) and registers the classloader

// Array containing credentials and confiuration parameters. (not required if config file is used)
// Array containing credentials and confiuration parameters. (not required if config file is used)
$config = array(
    'mode' => 'sandbox',
    'acct1.UserName' => 'jb-us-seller_api1.paypal.com',
    'acct1.Password' => 'WX4WTU3S8MY44S7F'
    );

$service = new AdaptivePaymentsService($config);

$payRequest = new PayRequest();
// Add optional params
if($_POST["feesPayer"] != "") {
    $payRequest->feesPayer = $_POST["feesPayer"];
}

$response = $service->Pay($payRequest);
if(strtoupper($response->responseEnvelope->ack) == 'SUCCESS') {
    // Success
}

It keeps returning the following error:

Fatal error: Uncaught exception 'PPInvalidCredentialException' with message 'Invalid userId ' in /Users/charlie/PhpstormProjects/AdaptivePaymentsTesting/vendor/paypal/sdk-core-php/lib/PPCredentialManager.php:120

Anyone have any ideas or suggestions?

0

There are 0 best solutions below