Search code examples
phpadyen

Adyen - verify payment after successful transaction


I am currently using Web Drop-in. After payment was successfully completed, it returns sessionData and sessionResult.

I want to redirect to a page with the values and verify/validate if the payment was done successfully. I thought sessionResult should be able to validate the payment status with some types of reference number. If I look at the API document as below, it seems like I need to pass details. I am not sure if I am understanding the api docs. How can we validate the payment?

$adyenService = new AdyenCheckout($adyenClient);
$result = $adyenService->paymentsDetails([
    'details' => ['redirectResult' => $sessionData]
]);

https://docs.adyen.com/api-explorer/Checkout/70/post/payments/details


Solution

  • When using the Web Drop-in with /sessions there is no need to make additional calls. If you look at Session Flow vs Advanced Flow page you will see the differences:

    • session: make one call (/sessions) and let the Drop-in take care of the payment execution
    • advanced: make 3 API requests and take control of the payment flow.

    In both cases, the final payment status is delivered to your application with webhooks.

    You should implement the endpoint that receives and processes the webhook payload: this contains all the information you need (status, pspReference, etc..).
    Check out the Adyen PHP sample app that includes a sample implementation of the webhook, using the PHP library.

    This other answer can also help to understand what needs to be done.