Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to obtain Transaction ID of successful payment #249

Open
HaikuOezu opened this issue Apr 7, 2021 · 5 comments
Open

How to obtain Transaction ID of successful payment #249

HaikuOezu opened this issue Apr 7, 2021 · 5 comments

Comments

@HaikuOezu
Copy link

HaikuOezu commented Apr 7, 2021

I'm terribly sorry for asking here as this is not exactly a bug but I've searched far and wide and I just cannot find the answer to a simple question and it's driving me crazy.

I'm using omnipay-paypal to take payments, it's a very simple flow that uses the PayPal_Rest gateway to call purchase() and then completePurchase().

$response = $gateway->purchase([
      'returnUrl' => route('payment-received'),
      'cancelUrl' => route('profile'),
      'currency' => 'EUR',
      'amount' => $price,
      'description' => $description
    ])->send();
$response = $gateway->completePurchase([
      'transactionReference' => $request->paymentId,
      'PayerID' => $request->PayerID
    ])->send();

    if ($response->isSuccessful()) {
      if ($response->isRedirect()) {
        $response->redirect(); // this will automatically forward the customer
      }
      // Do stuff (save the order on DB etc)
    }

It works - the payment is processed and confirmed. However, in order to cross reference payments with our PayPal account I'd like to store the PayPal Transaction ID (the one you see on paypal.com) and I cannot for the life of me understand how.

All I get is the Payment ID which looks something like PAYID-XXXXXXXXX, I would like the 16 digit reference instead. How would I achieve that considering the payment has gone through? Is that even possible with the PayPal REST API?

@iamjohnseun
Copy link

I am also experiencing the same issue
$response->isSuccessful()
always returns false and there is no way to link a transaction to the data saved on paypal for the captured transaction for local database storage purposes.

@dseeger
Copy link

dseeger commented Jul 18, 2022

It is possible to get the transaction reference.

if ($response->isSuccessful()) {
    $reference = $response->getTransactionReference();

That reference is not the same as the one displayed on paypal.com but the payment can still be found with it if you enter it in the search field.

EDIT: Fixed the below mentioned typo

@HaikuOezu
Copy link
Author

HaikuOezu commented Jul 18, 2022

@dseeger
I'm getting Call to undefined method Omnipay\PayPal\Message\RestResponse::getTransactionRefernce() when I try that

EDIT: Didn't notice the typo in your code lol, this actually works well enough for me - thank you!

@judgej
Copy link
Member

judgej commented Jul 18, 2022

getTransactionReference() - is that the spelling you used?

@HaikuOezu
Copy link
Author

@judgej yeah I copy pasted the original comment which had a spelling mistake on "Reference" lol. Once I fixed that it worked just fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants