Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Omnipay / Paypal Gateway - Transaction shows as success whereas Paypal Sandbox account do not show debt/credit of the transaction

1) I am triying for a while to get Omnipay / Paypal to work. My issue is I get "ACK = Success" but when going into the Sandbox test accounts, neither the buyer nor seller shows the transaction as booked.

2) I also got the feeling not all APIs are correctly transferred to Paypal (e.g. Brandname shows correctly using Angell library but with Omnipay it doesn't take the variable.

Anybody who can help on those two issues.? - See my code below. I checked other articles here, they don't solve my problem.

<?php
//
// Input Variables
//


// Config
$domain = "http://localhost";
$directory = "http://localhost/omnipay/";
$returnURL = $directory."success.php";      
$cancelURL = $directory."cancel.php";   
$landingpage = "Billing";                                               

$brandname = "TEST COMPANY";;   
$customerservicenumber  = "";

// Purchase Data
$invoiceNumber = "0000200202023939";        
$currencyCode = "USD";

// PRODUCT DATA 

$subscriptionName = "XXX";                          
$subscriptionDesc = "ZZZ";  
$subscriptionAmt = "5.00";                      



require 'vendor/autoload.php';

use Omnipay\Omnipay;


$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('XXX');
$gateway->setPassword('XXX');
$gateway->setSignature('XXX');
$gateway->setTestMode(true);

$response = $gateway->purchase(
    array(
        // Settings
        'brandname' =>  '',
            'customerservicenumber'=> '',           
    'cancelURL' =>  $cancelURL,
    'returnURL' =>  $returnURL,
            'reqconfirmshipping' => '0',
            'noshipping' => '1',                            

    'allownote' =>  '0',    

    // Buyer data
    'email' =>  $email,                         
    'description'=> $subscriptionDesc,
    'amount'=>  $subscriptionAmt,
    'currency'=>    $currencyCode,
     )  
)->send();

$response->redirect();

?>

success.php is the same script, except for the end

....

)->send();
$data = $response->getData();

//echo '<pre>'; print_r($data);

if($data['ACK'] == "Success"){
echo "ACK = Success!!!!!!";
}
?>

As said, I always got ACK = Success at the end, but the amounts are not deducted from the Sandbox user accounts. So something is wrong. Any idea?

like image 811
Plugins and Snippets Avatar asked Dec 06 '25 02:12

Plugins and Snippets


1 Answers

It looks like you're not completing the purchase. Your success.php should have something that looks like:

$response = $gateway->completePurchase($params)->send();

Before you redirect off to Paypal save your transaction parameters in a session variable and then use them to complete the purchase when Paypal returns. Check out the example code for more details: https://github.com/omnipay/example/blob/master/index.php#L181

like image 182
beech Avatar answered Dec 11 '25 14:12

beech



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!