Reputation: 31
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?
Upvotes: 3
Views: 2363
Reputation: 1064
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
Upvotes: 4