umbraco / Umbraco.Commerce.PaymentProviders.Worldpay

MIT License
0 stars 1 forks source link

"authMode" configured in strange way #5

Closed PeterKvayt closed 1 month ago

PeterKvayt commented 1 month ago

Hi @mattbrailsford !

I was refactoring and notice one interesting moment, would you be so kind to explaim me following.

Here we have following code:

{ "authMode", ctx.Settings.Capture ? "A" : "E" },

This code means that "A" value is capture, "E" - not capture (as I understand - authorize).

If we move on, to method ProcessCallbackAsync and find following line of code:

var paymentStatus = formData["authMode"] == "A" ? PaymentStatus.Authorized : PaymentStatus.Captured;

This code tells us opposite: if "authMode" is "A" - then Authorized, if not - Captured.

I think there is something wrong with last condition. According the docs:

The values are "A" for a full authorisation, or "E" for a pre-authorisation.

Could you please leave your point of view as I see you wrote this package?

PeterKvayt commented 1 month ago

Also I have WorldPay's support response:

Authmode A will automatically process payments from pre-auth through to capture - authmode E will make it orders must be confirmed before they are authorised.

mattbrailsford commented 1 month ago

Hey @PeterKvayt

It looks like the latter conditional is wrong, and as you point out, should probably be the other way around.

I'm happy for this to be included in your ongoing PR.

PeterKvayt commented 1 month ago

@mattbrailsford

Okay, correct me if I wrong, According your previous reply:

It looks like the latter conditional is wrong, and as you point out, should probably be the other way around.

Does it mean that condition from this line

var paymentStatus = formData["authMode"] == "A" ? PaymentStatus.Authorized : PaymentStatus.Captured;

should be inverted:

var paymentStatus = formData["authMode"] == "A" ? PaymentStatus.Captured : PaymentStatus.Authorized;

P.S. Also to make sure, I will ask about this field to WorldPay support and than update this line in my pr

mattbrailsford commented 1 month ago

If this statement is correct

Authmode A will automatically process payments from pre-auth through to capture - authmode E will make it orders must be confirmed before they are authorised.

Then yea, it should be

var paymentStatus = formData["authMode"] == "A" ? PaymentStatus.Captured : PaymentStatus.Authorized;
PeterKvayt commented 1 month ago

@mattbrailsford

I got the support reply:

The Authmode that is used in the payment form will be what is sent, however bare in mind that you can only send the corresponding Authmode anyway - so for example if you're sending Authmode A to use automatic capture, then the Merchant Code our end will be setup to only work with a delay/auto capture. Therefore you can only get a successful order using Authmode = A. (If you were to use Authmode E, then our end will need to be setup to process manual capture only, meaning we will now only accept Authmode = E). Considering these points, it should only be possible to send and receive a single Authmode in the payment form and callback.

Also the docs says:

Specifies the authorisation mode used. The values are "A" for a full auth, or "E" for a pre-auth.

This values are possible response authMode values.

According our investigation and these answers I updated my pr and it is ready to review.