Getting order id in a payment plugin to use while processing the payment.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
Hi.
I am writing a custom payment plugin where the user gets sent an invoice to the bank where he can pay it at his convenience. The problem that I am having is that I want to get the order id from his order to send with the payment as additional information but, as far as I understand it, the order is not created until after the ProcessPayment method is finished.

How would I go about getting the information about the order so that I can use it in the payment process?

Regards
Simmi
4 years ago
No the order is created before the payment plugin is called to make the transaction in PostProcessPayment

For example see https://github.com/nopSolutions/nopCommerce/blob/develop/src/Plugins/Nop.Plugin.Payments.PayPalStandard/PayPalStandardPaymentProcessor.cs

You can access the order in PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)

And get the order Id

postProcessPaymentRequest.Order.OrderId
4 years ago
Yidna wrote:
No the order is created before the payment plugin is called to make the transaction in PostProcessPayment

Not according to what I see when I debug the application. Then ProcessPayment is called after you place the order, sometime after that the order is written to the database, and then the order is accessible in the PostProcessPayment.


Yidna wrote:
You can access the order in PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)

And get the order Id

postProcessPaymentRequest.Order.OrderId

Yes, I can. That is too late for what I am thinking about though.

I need to associate the order ID with the payment that gets sent to the bank.
4 years ago
ProcessPayment vs. PostProcessPayment  :  don't confuse the Controller with the Processor.

See the PayPalStandard plugin source code for an example.
4 years ago
New York wrote:
ProcessPayment vs. PostProcessPayment  :  don't confuse the Controller with the Processor.

See the PayPalStandard plugin source code for an example.


Both of those methods are defined in the IPaymentMethod interface.

I am not sure what, or if, I am confusing together. Can you elaborate?
4 years ago
Simmisj wrote:
Not according to what I see when I debug the application. ProcessPayment is called after you place the order, sometime after that the order is written to the database, and then the order is accessible in the PostProcessPayment.

Yes this is correct

So there are two types of payment methods:
2 Party - you enter the credit card details or info in nopCommerce. Then it processes the payment in the background with the merchant and you don't see the merchant website ie. Square, PayPal Direct, etc

3 Party - the order is created and saved, then order details (number and total, etc) are posted to the third party website URL and you see the merchant website and enter the credit card details in their website i.e. PayPal Standard

ProcessPayment is called in both instances before the order is saved in the database
PostProcessPayment is called after the order is saved and in the case where the payment method is 3-party it posts  to the third-party URL and display the merchant website or do something.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.