-
Notifications
You must be signed in to change notification settings - Fork 141
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
v6 - Synchronous submit with order tracking #2425
Conversation
|
size-limit report 📦
|
Size Change: +5.68 kB (+1%) Total Size: 1.12 MB
ℹ️ View Unchanged
|
Quality Gate failedFailed conditions 71.7% Coverage on New Code (required ≥ 80%) See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
…tures in 3DS2 and Card
onSubmit: (state, component) => { | ||
return makePayment(state.data) | ||
.then(response => { | ||
if (response.action) { | ||
component.handleAction(response.action); | ||
} else if (response?.resultCode && checkPaymentResult(response.resultCode)) { | ||
alert(response.resultCode); | ||
} else { | ||
// Try handling the decline flow | ||
// This will redirect the shopper to select another payment method | ||
component.handleDeclineFlow(); | ||
} | ||
}) | ||
.catch(error => { | ||
throw Error(error); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m1aw It is still using the old syntax for the onSubmit
: handling action part with component.handleAction
; checking the resultCode manually instead of passing back to the library; I believe it also does not trigger the new callbacks onPaymentCompleted/onPaymentFailed. The goal is to make it work with the new syntax at least (onSubmit(state, component, actions)
), so all payment methods follow the new flow.
Perhaps this needs an adjustment like it was done with GooglePay/ApplePay, as it seems that AmazonPay has an special flow to decline the payment (component.handleDeclineFlow
)
Would that be possible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the first part. I have changed it to use actions.resolve
as part of the tests. I will pull those changes in.
On the second part, I have not made modifications to the way AmazonPay onSubmit
works and also the way handleDeclineFlow works.
I thought that was the objective, not make more changes then the ones necessary here. I will take a look to also adjust it, I because I think I misunderstood it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusting the callback to behave in the new way is a necessary one I'd say. We don't want merchants to have to implement two different submit flows depending on the payment method that they use.
Let's then merge this PR as it is blocking other tasks, and then you can iterate on this in a new PR along with the e2e tests.
Summary
onSubmit/onAdditionalDetails requires data to be passed back
The payments response data must be passed back to the lib. Internally we handle the action; trigger the Partial payment flow; or check the payload and decide if the payment is completed or not.
onPaymentCompleted and onPaymentFailed
To have more granular control of what is happening:
onPaymentCompleted
is called when the payment is successfullonPaymentFailed
(new callback) is called when the payment failsPartial payments
onOrderCreated
renamed toonOrderUpdated
to be more conciseonPaymentMethodsRequest
which is triggered when there is a partial order pending. The merchant then can request the new payment methods in order to update the UI accordinglyonAuthorized
onAuthorized now is triggered before the 'onSubmit' . It returns an object with the authorizedEvent (raw data from ApplePay/GooglePay/PayPal) along with the formatted billingAddress and deliveryAddress.
onAuthorized
must be resolved in order to trigger the payment flow (onSubmit)onAuthorized
for Paypal happens before the onAdditionalDetails, as the authorization data is available at that pointApplePay onOrderTracking
Adding support for ApplePay order tracking.
onOrderTrackingRequest
callback is available. If it is, it is called and then the merchant must create and pass the order details back to the Component.AVS improvements for GooglePay and ApplePay
If the information about the billing address and shipping address is available in the GooglePay/Applepay components when the authorization happens, we populate the
state.data
with the billingAddress and deliveryAddress fields. This improves the AVS checks.ApplePay improvements
If the payment fails during the
onSubmit
call, or if the merchant rejects the payment during theonAuthorized
callback, the ApplePay payment overlay will display 'Payment Failed' messageThe error can also be customized in the 'onSubmit' by doing:
or in the
onAuthorized
by doing:GooglePay improvements
If the payment fails during the
onSubmit
call, or if the merchant rejects the payment during theonAuthorized
callback, the GooglePay overlay will display 'Payment Failed' message.The error can also be customized in the 'onSubmit' by doing:
or in the
onAuthorized
by doing:WIP:
onError
callback .(Align with CoreonError
)Tested scenarios
Fixed issue: