Paypal IPN Not Getting Called In Sandbox

SilentJohn
Contributor
Contributor

I can create and execute a payment. I can use the IPN Simulator to simulate an Express Checkout and it works. I cannot connect the 2. I assume it is something I am doing or not doing in the execute payment code. Here is the code:

 

 

<?php
    require "vendor/autoload.php";
    use PayPal\Api\Amount;
    use PayPal\Api\Details;
    use PayPal\Api\Payment;
    use PayPal\Api\PaymentExecution;
    use PayPal\Api\Transaction;

    $apiContext = new \PayPal\Rest\ApiContext(
        new \PayPal\Auth\OAuthTokenCredential(
            '(*ClientID*)',
            '(*ClientSecret*)'
        )
    );

    $paymentId = $_GET['paymentId'];
    $payment = Payment::get($paymentId, $apiContext);

    $execution = new PaymentExecution();
    $execution->setPayerId($_GET['PayerID']);

    $transaction = new Transaction();
    $amount = new Amount();
    $details = new Details();

    $details->setShipping(0)
        ->setTax(0)
        ->setSubtotal(10);

    $amount->setCurrency('USD');
    $amount->setTotal(10);
    $amount->setDetails($details);
    $transaction->setAmount($amount);

    $execution->addTransaction($transaction);

    try {
        $result = $payment->execute($execution, $apiContext);
        return $result;
    } catch (\PayPal\Exception\PayPalConnectionException $ex) {
        // This will print the detailed information on the exception.
        //REALLY HELPFUL FOR DEBUGGING
        echo $ex->getData();
    }
?>

 

 

I have gone over everything many times. All the default settings and such are right. I have run out of things to try.

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.