-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix notification payment lookup (#1049)
* Modify notification handler to get payment by pspReference or merchantReference * Set pspReference as payment key if it is returned after making payment * Refactor the setKey update action * Add setKey action in submit payment details handler * Fix style * Fix style * Fix unit test for make payment handler * Fix unit test for make payment handler with splits * Fix unit test for submit payment details handler * Fix integration test * Fix paypal e2e test * Fix paypal e2e test * Fix integration test for notification module * Fix unit test for notification module * Fix multitenancy test * Update extension/src/paymentHandler/make-payment.handler.js Co-authored-by: Lam Tran <[email protected]> * Revert "Update extension/src/paymentHandler/make-payment.handler.js" This reverts commit f89ebd8. * Remove unnecessary waiting time in Paypal pop-up * Improve the boolean comparison * Fix style * Remove unnecessary merchantReference checking * Use merchant reference and original reference in notification module * Fix paypal e2e test * Remove unnecessary checking for update payment key in notification module * Revert "Use merchant reference and original reference in notification module" This reverts commit 66e60fe. * Remove deprecated test case * Fix loggings * Fix integration test for cancel authorized payment * Fix documentation * Split the ADR * Modify ADR * Update ADR * Modify ADR * Modify ADR * Modify ADR * Modify ADR * Modify ADR * Modify ADR * Modify ADR * Revert "Modify ADR" This reverts commit dcbc579. * Modify ADR * Update docs/adr/0011-matching-adyen-notification.md Co-authored-by: Lam Tran <[email protected]> * Fix affirm payment e2e test Co-authored-by: King-Hin Leung <> Co-authored-by: Lam Tran <[email protected]>
- Loading branch information
1 parent
dbd47fb
commit 7d66a2a
Showing
21 changed files
with
374 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 11. Matching Adyen Notification with commercetools payment. | ||
|
||
Date: 2023-01-03 | ||
|
||
## Status | ||
|
||
[Accepted](https://github.com/commercetools/commercetools-adyen-integration/pull/1049) | ||
|
||
## Context | ||
|
||
The Adyen notification needs to be matched by its commercetools payment equivalent. | ||
We are using the payment key for the `merchantReference` and fetching the commercetools payment object with query `key="${merchantReference}"`. | ||
Since [v9.10.0](https://github.com/commercetools/commercetools-adyen-integration/releases/tag/v9.10.0), we have introduced custom reference for refund. | ||
Payment key could be the custom field in payment transaction defined by user, therefore payment is no longer always able to be obtained by merchant reference as key. | ||
|
||
The alternative for that is to use `pspReference` as payment `key` field. | ||
|
||
## Decision | ||
|
||
- We will use `originalReference` (or `pspReference` if `originalReference` does not exist) or `merchantReference` as payment key for matching payment for notification. | ||
- For web component version 4, `pspReference` can be obtained from `makePaymentResponse` in extension module. It is used to update as payment key. Therefore we can match the payment by `pspReference` given in notification. | ||
- For web component version 5, `pspReference` is first provided in notification with AUTHORIZATION event. It is different from web component version 4, in which `pspReference` has already been provided from Adyen API response in extension module, and used to update as payment key. Therefore we still need `merchantReference` for payment lookup in this scenario. | ||
Once payment is found, update the payment key with `pspReference` obtained in notification. | ||
- For events other than AUTHORIZATION, such as REFUND, CAPTURE, CANCEL, we use `originalReference` from notification, which is the original `pspReference` obtained in AUTHORIZATION notification. | ||
- The notification will use the CTP payment key to fetch payment. It first check if `originalReference` exists. If yes, | ||
it finds the payment by `key` where `key in (${merchantReference}, ${originalReference})`), otherwise it finds the payment by `key` where `key in (${merchantReference}, ${pspReference})`. | ||
After that it finds the corresponding transaction in this payment by `interactionId` where `interactionId=${pspReference}`. | ||
|
||
For details, please refer to the [code snippet](https://github.com/commercetools/commercetools-adyen-integration/blob/dcbc5794cd4c470d1cf5a8c23623214671bf1849/notification/src/handler/notification/notification.handler.js#L52) | ||
|
||
## Consequences | ||
- It is possible to lookup payment for different transaction throughout the whole payment process | ||
- The payment key with `pspReference` (or `originalReference`) is also unique for all payments. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.