**ORIGINAL QUESTION**

Using the functions in [paypalplatform.php](https://github.com/iamezell/spotaplace-public/blob/master/php/paypalplatform.php), I have the following code which works fine:

```
$resArray = CallPaymentDetails( ... );
// $resArray = CallPay ( ... );

```

The following also works fine:

```
// $resArray = CallPaymentDetails( ... );
$resArray = CallPay ( ... );

```

But this does *not* work:

```
$resArray = CallPaymentDetails( ... );
$resArray = CallPay ( ... );

```

The error happens on the second line, i.e. `$resArray = CallPay ( ... );` and the error message is:

```
'error(0).message' => string 'The trackingId some_string_here is invalid'

```

I can't see anything wrong with the `trackingId` and I can't seem to work out why `CallPay` works if `CallPaymentDetails` is not used before it.

After some debugging, I can see that the following line from [paypalplatform.php](https://github.com/iamezell/spotaplace-public/blob/master/php/paypalplatform.php) is the line which captures the error message:

```
$response = curl_exec($ch);

```

but I can't step through that line to see why it's causing an error. Anyone know that's going on?

---

**UPDATE - FULL CODE**

```
<?php
    error_reporting( E_ALL | E_STRICT );
    ini_set('display_errors', 1);

    require_once ("paypalplatform.php");

    $payKey = "existing payKey goes here";
    $transactionId = "";
    $trackingId = "";

    // if( user has already tried paying where the payment failed, get old $payKey and use in CallPaymentDetails() ) = true {
        $resArray = CallPaymentDetails( $payKey, $transactionId, $trackingId );
    // }

    var_dump($resArray);

    unset($resArray);

    $actionType = "PAY";
    $cancelUrl = "http://" . $_SERVER["SERVER_ADDR"] . "/cancel.php";
    $returnUrl = "http://" . $_SERVER["SERVER_ADDR"] . "/success.php";
    $currencyCode = "GBP";
    $receiverEmailArray = array( 'company email goes here' );
    $receiverAmountArray = array( '2' );
    $receiverPrimaryArray = array();
    $senderEmail = "";
    $feesPayer = "";
    $ipnNotificationUrl = "";
    $memo = "";
    $pin = "";
    $preapprovalKey = "";
    $reverseAllParallelPaymentsOnError = "";
    $trackingId = generateTrackingID();
    $receiverInvoiceIdArray = array( $trackingId );

    $resArray = CallPay ( $actionType, $cancelUrl, $returnUrl, $currencyCode, 
        $receiverEmailArray, $receiverAmountArray, $receiverPrimaryArray,
        $receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl, $memo, 
        $pin, $preapprovalKey, $reverseAllParallelPaymentsOnError, 
        $senderEmail, $trackingId );

    var_dump($resArray);
?>

```

The $payKey variable right at the top needs to be entered in and $receiverEmailArray also needs to be entered in.