PayPal Express Checkout with Omnipay not displaying Sandbox account order

I used the Omnipay PayPal_Express checkout script on my site and everything works fine when I pay for the order, except that the order does not appear in the Sandbox PayPal account.

This shows when I use the same script for PayPal_Pro.

My code is as follows:

use Omnipay\Omnipay; // PayPal Express: if(isset($_POST['paypalexpress'])) { $gateway = GatewayFactory::create('PayPal_Express'); $gateway->setUsername('{myusername}'); $gateway->setPassword('{mypassword}'); $gateway->setSignature('{mysignauture}'); $gateway->setTestMode(true); $response = $gateway->purchase( array( 'cancelUrl'=>'http://www.mysite.com/?cancelled', 'returnUrl'=>'http://www.mysite.com/?success', 'amount' => "12.99", 'currency' => 'GBP', 'Description' => 'Test Purchase for 12.99' ) )->send(); $response->redirect(); } 

I created two test accounts in my Sandbox, one for the above API and one that I use for payment. I tried to pay for the test card details and login, but the order details are not displayed in the account.

Can anyone help?

+8
api php paypal omnipay paypal-express
source share
2 answers

It looks like you are missing the completePurchase () part when Paypal returns to your returnUrl. My code assumes that you have order details in the $ order variable, but might look something like this:

 if(isset($_GET['success'])) { $response = $gateway->completePurchase(array( 'transactionId' => $order->transaction, 'transactionReference' => $order->reference, 'amount' => $order->total, 'currency' => $order->currency, ))->send(); if ( ! $response->isSuccessful()) { throw new Exception($response->getMessage()); } } 

Let me know if you need help getting your order details when returning. It can be stored in the session before being redirected or in the database. If you haven’t done this yet, take a look at the sample code: https://github.com/omnipay/example/blob/master/index.php

+11
source share

This will be displayed in a monospaced font. The first four spaces will be deleted, but all other spaces will be retained.

 Markdown and HTML are turned off in code blocks: <i>This is not italic</i>, and [this is not a link](http://example.com) 

To create inline code rather than block, use backlinks:

The $ character is just a shortcut to window.jQuery .

If you want to have a preformatted block in the list, indent by eight spaces:

  • This is plain text.
  • So, but now the code block follows:

     Skip a line and indent eight spaces. That four spaces for the list and four to trigger the code block. 
-2
source share

All Articles