Payum / Payum

PHP Payment processing library. It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts etc.
https://payum.gitbook.io/payum
MIT License
1.85k stars 341 forks source link

Question : Don't receive any status when capture back #855

Open martygraphy opened 4 years ago

martygraphy commented 4 years ago

Hi, I'm currently developing a custom Ogone gateway (because Ogone Ets Bundle is no longer functional on Symfony 4).

Everything works until I complete my transaction on Ogone. I pass the url capture back after redirection from Ogone to my application, however I don't receive any status. So it creates me a new capture when it should not. Is this a parameter to be passed or is this an Ogone issue?

Any help you can give me would be greatly appreciated.

Marc

Great-Antique commented 4 years ago

I pass the url capture back after redirection from Ogone to my application, however I don't receive any status.

For Paypal Payum works as follows:

  1. Your app redirects you to Paypal
  2. You authorize payment at Paypal
  3. Paypal redirects you to your app
  4. Your app receives status of your payment (resolved by token in URL) from Paypal and if it's authorized app tries to capture the payment. And then redirects you to some page (succes, etc.)

You don't need any status in URL, you ask Paypal for it.

Don't know how Ogone works, but if your app has to capture payment after authorization - you don't need any status provided in URL by payment system. So if you can capture - you capture.

So it creates me a new capture when it should not.

Are those payments not captured in Ogone?

martygraphy commented 4 years ago

Hi @Great-Antique , Thank you for your response.

I don't have to capture the payment directly. Ogone can give me the answer to the transaction, several weeks after the creation of the transaction.

You don't need any status in URL, you ask Paypal for it.

You mean that the application makes another request to know the status of the paypal payment?

Aren't the payments captured in Ogone?

Ogone creates a transaction for me, it sets a status pending validation but will not return the information to me after the redirection.

So how can I let payum know that I want to switch to done if I don't have any new information?

Marc

Great-Antique commented 4 years ago

@martygraphy

I had an experience only with Paypal Express Checkout and custom SafeCharge gateway.

I don't have to capture the payment directly. Ogone can give me the answer to the transaction, several weeks after the creation of the transaction.

It's weird if payment is not captured at Ogone. There should be some status mapping from Ogone to Payum. Maybe it's not correctly mapped?

You mean that the application makes another request to know the status of the paypal payment?

In Paypal Express Checkout intergration - yes, it makes request to synchronize payment details (and map status from details to Payum status) every time you redirected after checkout&pay and on every notifying from Paypal in background. So you don't need to do anything with input parameters (URL, POST). Just sync details & handle difference (between old details and new ones).

Ogone creates a transaction for me, it sets a status pending validation but will not return the information to me after the redirection.

If Ogone don't send you status (or other details) in URL (or POST) - you can get payment by URL for sure and then ask for status by some API. If it's 'pending' - you should map it to correct Payum status, show 'Pending page' and wait for a server-server notification from Ogone when transaction will be processed/validated. But then, again, if they don't provide details in notification URL - you, again, can get payment from URL and ask Ogone.

So how can I let payum know that I want to switch to done if I don't have any new information?

You will receive notification from payment system. There are (at least for Paypal Express Checkout) two tokens: one for handle redirect from payment system and one for handling notifications. Each has own URL. So you will receive (I hope they notify customers) notification to notify token's URL. And then you can ask for details by API (I hope they have API) and decide if the transaction is ready to be captured or already captured. If yes - mark payment model as captured/done.

P.S. This is my vision of how Payum is working. We've integrated our application in this way but with Paypal. But I think that this part should be very similar.

martygraphy commented 4 years ago

Thank you very much @Great-Antique , for this answer it is much clearer!
Last little question :)

Just sync details & handle difference (between old details and new ones).

I've been looking into this syncing thing, but I see that the Class Sync is empty. ( I don't see any paypal configuration at this level )

And my gateway doesn't recognize it, is there a configuration for the gateway to support Sync?

King Regards

Great-Antique commented 4 years ago

1) Class Sync is a request. It's handled by an action class. In case of Paypal ExpressCheckout it's PaymentDetailsSyncAction. This action throw GetTransactionDetails request which is handled by GetTransactionDetailsAction and do API request to get relevant details of payment/transcation. Sync request is thrown by Paypal ExpressCheckout's NotifyAction which handles Notify request. This Notify request is thrown by NotifyController from Payum Symfony Bundle. I think you must have similar to NotifyAction and PaymentDetailsSyncAction classes in Ogone gateway.

2) To capture a payment there is CaptureController (Pay attention to this line) and some action like CaptureAction in which you deal with new details (like a status), and some action like DoCaptureAction in which you DO capture and throw GetTransactionDetails request (which handles by GetTransactionDetailsAction updates your model by new details like mentioned above in "1").

Also, don't forget to dig into Payum Bundle's tab in Symfony Profiler. There is some useful information about those requests and actions. I don't think that Payum's architecture is easy-to-understand but if you have a time to dig in some of existing gateway - you will probably can build your own gateway without changing anything in Payum. I think it's more easy-to-integrate than easy-to-understand flow :) especially without bird-view diagrams and detailed integration (or custom gateway) tutorials. I've spend a lot of time to build my custom SafeCharge gateway but in the end it's easy to install, configure and use.

martygraphy commented 4 years ago

Hello @Great-Antique , Thank you for this additional information and for taking the time to answer me! I'll try to set it up! :)