You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(stored-payment-methods): add support for showing, storing, paying and deleting payment methods (#452)
* feat(saved-payment-methods): add initial implementation
* chore(saved-payment-methods): add todo comment
* chore(processor): wip
* chore(processor): refactor create-payment.converter.ts
* feat(processor): add token webhook header hmac auth. Update enabler/processor dtos to match
* feat(processor): tokenization processor and converter
* feat(processor): add validation that (adyen) token belongs to the given customer on the cart
* feat(saved-payments-method): add delete functionality for the drop-in component
* feat(saved-payment-methods): change type for saving drafts
* chore(saved-payment-methods); add todo comment
* chore(processor): update todos comment
* chore(processor): add link to docs for hmac auth hooks
* chore(enabler): update doc
* chore(enabler): remove todo comment
* chore(processor): update todo
* chore(processor): update todo
* chore(processor): update todo
* feat(processor): improve deletion flow of saved payment method
* feat(processor): stop displaying spm in drop-in if no pm exists in ct
* chore(processor): get display info during runtime from adyen
* chore(processor): remove logoUrl since that is not available from displayOptions
* feat(enabler): add the web-component stored components builders
* chore(processor): rename variable
* chore(processor): process env for hmac key explicit undefined check
* chore(processor): remove log attribute value
* chore(enabler): align with poc value
* chore(processor): update session
* chore(enabler): update todo comment ticket number
* chore(processor): add notification handler related tests
* chore(processor): update unit-tests
* feat(processor): implement unit-tests for create-payment.converter for saved payments mapping
* feat(processor): add unit-tests for getSavedPaymentMethods
* chore(processor): prep unit-tests for deleteSavedPaymentMethod
* feat(processor): add unit-tests for delete saved payment method
* chore(enabler): remove sleep
* chore(enabler): update todo comment for remove functionality for web-component
* chore(processor): update notification tokenisation handler.
* fix(processor): fix unit-test
* fix(processor): anon carts for fetching config
* chore(enabler): bump adyen-web
* fix(enabler): fix submit standard component in index.html
* feat(processor): use a HTTP POST instead of DELETE to not have the tokenId in the access-logs
* feat(enabler): implement delete stored payment method for stored-card component
* chore(processor): explicit log details when processing recurring notifications
* chore(processor): update logging
* chore(processor): bump adyen api-library to 28.1.0
* chore(enabler/processor): rename everything to StoredPaymentMethods
* chore(processor/enabler): add todo comments
* chore(processor): bump @commercetools/connect-payments-sdk to 0.24.0 to have access to the latest features
* chore(readme.md): update to include the new .env values
* chore(readme.md): remove duplicate value
* chore(processor/enabler): add todo comments for pr feedback
* feat(processor/enabler): fetch the stored payment methods during config init if feature is enabled
* chore(enabler/processor): use CT payment method ID for the delete api
* chore(processor): seperate out the deleteStoredPaymentMethod so that its no longer implicitly depending on a cart
* chore(processor): remove cart mocks for deleteStoredPaymentMethods since it not required
* chore(enabler): add initial empty array value for storedPaymentMethodsList
* chore(processor): improve readability of the getStoredPaymentMethods by splitting it up
* chore(enabler/processor): remove the name property from the stored-payment-method model
* chore(enabler/processor): change the type of expireMonth and expireYear to number
* chore(enabler): add testing functionality for storing and paying with spm to index.html
* chore(enabler): add delete spm for index.html
* chore(enabler/processor): add mapping for Brand attribute on spm
* chore(comment): remove comment for other ticket
* chore(enabler): update typing and remove corresponding todo
* chore(processor): update readme.md
* chore(processor): in the create-session request only set the store payment method data if the cart has a customerId set and the feature is enabled
* chore(enabler/processor): add further mapping for brands
* chore(readme.md): update readme.md with further details about enabling and getting started with spm
* chore(readme.md): update header
* chore(readme.md): update listing bullet
* chore(readme.md): mention it's disabled by default
* chore(processor): log specific notificaiton object instead of the entire thing
* chore(readme.md): update readme.md with explicit mention that changing the paymentInterface or interfaceAccount after creating payment-methods will not return old results
-[Setting up stored payment methods](#setting-up-stored-payment-methods)
18
+
-[CT payment-methods and Adyen tokens](#ct-payment-methods-and-adyen-tokens)
19
+
-[Development](#development) - [Configuration steps](#configuration-steps) - [1. Environment Variable Setup](#1-environment-variable-setup) - [2. Spin Up Components via Docker Compose](#2-spin-up-components-via-docker-compose)
20
+
<!--toc:end-->
21
+
2
22
This repository provides a [connect](https://docs.commercetools.com/connect) for integration to Adyen payment service provider (PSP).
3
23
4
24
## Features
25
+
5
26
- Typescript language supported.
6
27
- Uses Fastify as web server framework.
7
28
- Uses [commercetools SDK](https://docs.commercetools.com/sdk/js-sdk-getting-started) for the commercetools-specific communication.
8
29
- Uses [connect payment SDK](https://github.com/commercetools/connect-payments-sdk) to manage request context, sessions and JWT authentication.
9
30
- Includes local development utilities in npm commands to build, start, test, lint & prettify code.
10
31
11
32
## Overview
12
-
The adyen-integration connector contains two modules :
33
+
34
+
The adyen-integration connector contains two modules :
35
+
13
36
- Enabler: Acts as a wrapper implementation in which frontend components from Adyen embedded. It gives control to checkout product on when and how to load the connector frontend based on business configuration. In cases connector is used directly and not through Checkout product, the connector library can be loaded directly on frontend than the PSP one.
14
-
- Processor : Acts as backend services which is middleware to integrate with Adyen platform. It is mainly responsible for managing transactions with Adyen and updating payment entity in composable commerce. `connect-payment-sdk` will be offered to be used in connector to manage request context, sessions and other tools necessary to transact.
37
+
- Processor : Acts as backend services which is middleware to integrate with Adyen platform. It is mainly responsible for managing transactions with Adyen and updating payment entity in composable commerce. `connect-payment-sdk` will be offered to be used in connector to manage request context, sessions and other tools necessary to transact.
4. The processor transforms the received request and send them to Ayden platform.
49
72
5. Adyen processes the payment operations and return the response to processor.
50
73
6. The processor handles the payment persistence to composable commerce, and return the result to front-end.
51
-
7. commercetools Checkout handles the order management in composable commerce once it receives the result from the processor.
74
+
7. commercetools Checkout handles the order management in composable commerce once it receives the result from the processor.
52
75
53
76
## Prerequisite
77
+
54
78
#### 1. commercetools composable commerce API client
79
+
55
80
Users are expected to create API client responsible for payment management in composable commerce project. Details of the API client are taken as input as environment variables/ configuration for connect such as `CTP_PROJECT_KEY` , `CTP_CLIENT_ID`, `CTP_CLIENT_SECRET`. For details, please read [Deployment Configuration](./README.md#deployment-configuration).
56
81
In addition, please make sure the API client should have enough scope to be able to manage payment. For details, please refer to [Running Application](./processor/README.md#running-application)
57
82
58
83
#### 2. various URLs from commercetools composable commerce
84
+
59
85
Various URLs from commercetools platform are required to be configured so that the connect application can handle session and authentication process for endpoints.
60
86
Their values are taken as input as environment variables/ configuration for connect with variable names `CTP_API_URL`, `CTP_AUTH_URL` and `CTP_SESSION_URL`.
61
87
62
88
#### 3. Adyen account credentials
89
+
63
90
Various account data provided by Adyen are necessary to be configured so that the requests from the connect application can be authenticated by Adyen platform within the integration.
64
91
Their values are taken as input as environment variables/ configuration for connect with variable names `ADYEN_API_KEY`, `ADYEN_NOTIFICATION_HMAC_KEY`, `ADYEN_MERCHANT_ACCOUNT`, `ADYEN_CLIENT_KEY`, `ADYEN_LIVE_URL_PREFIX` and `ADYEN_ENVIRONMENT`.
65
92
66
93
## Development Guide
94
+
67
95
Regarding the development of enabler module, please refer to the following documentations:
96
+
68
97
-[Development of Enabler](./enabler/README.md)
69
98
70
99
Regarding the development of processor module, please refer to the following documentations:
100
+
71
101
-[Development of Processor](./processor/README.md)
72
102
73
103
#### Connector in commercetools Connect
104
+
74
105
Use public connector listed in connect marketplace. If any customization done, follow guidelines [here](https://docs.commercetools.com/connect/getting-started) to register the connector for private use.
75
106
76
107
#### Deployment Configuration
108
+
77
109
In order to deploy your customized connector application on commercetools Connect, it needs to be published. For details, please refer to [documentation about commercetools Connect](https://docs.commercetools.com/connect/concepts)
78
110
In addition, in order to support connect, the adyen payment integration connector has a folder structure as listed below
111
+
79
112
```
80
113
├── enabler
81
114
│ ├── src
@@ -89,6 +122,7 @@ In addition, in order to support connect, the adyen payment integration connecto
89
122
```
90
123
91
124
Connect deployment configuration is specified in `connect.yaml` which is required information needed for publishing of the application. Following is the deployment configuration used by enabler and processor modules
125
+
92
126
```
93
127
deployAs:
94
128
- name: enabler
@@ -154,6 +188,15 @@ deployAs:
154
188
- key: ADYEN_PAYMENT_COMPONENTS_CONFIG
155
189
description: Adyen payment components configuration in JSON String format. For example: {"paypal":{"blockPayPalVenmoButton":false}}. Please refer to the Adyen documentation for more details.
156
190
required: false
191
+
- key: ADYEN_STORED_PAYMENT_METHODS_ENABLED
192
+
description: If set to "true" then the stored payment methods feature is enabled. Default value is "false".
description: Adyen HMAC tokenization webhooks key. This will be used if provided, otherwise the ADYEN_NOTIFICATION_HMAC_KEY will be used. (Please use the dummy placeholder value during the installation process. Once the webhook configuration in Adyen is complete and HMAC known, replace this placeholder with the actual value and redeploy.)
212
+
required: false
167
213
- key: ADYEN_APPLEPAY_OWN_CERTIFICATE
168
214
description: Apple Pay own certificate
169
215
required: false
170
216
171
217
```
172
218
173
219
Here you can see the details about various variables in configuration
220
+
174
221
-`CTP_PROJECT_KEY`: The key of commercetools composable commerce project.
175
222
-`CTP_CLIENT_ID`: The client ID of your commercetools composable commerce user account. It is used in commercetools client to communicate with commercetools composable commerce via SDK. Expected scopes are: `manage_payments``manage_orders``view_sessions``view_api_clients``manage_checkout_payment_intents``introspect_oauth_tokens`.
176
223
-`CTP_CLIENT_SECRET`: The client secret of commercetools composable commerce user account. It is used in commercetools client to communicate with commercetools composable commerce via SDK.
@@ -179,7 +226,7 @@ Here you can see the details about various variables in configuration
179
226
-`CTP_SESSION_URL`: The URL for session creation in commercetools platform. Connectors relies on the session created to be able to share information between enabler and processor. The default value is `https://session.europe-west1.gcp.commercetools.com`.
180
227
-`CTP_JWKS_URL`: The URL which provides JSON Web Key Set. Default value is `https://mc-api.europe-west1.gcp.commercetools.com/.well-known/jwks.json`.
181
228
-`CTP_JWT_ISSUER`: The issuer inside JSON Web Token which is required in JWT validation process. Default value is `default: https://mc-api.europe-west1.gcp.commercetools.com`
182
-
-`ADYEN_ENVIRONMENT`: The indicator of adyen environment. Default value is `TEST`. It can be configured either as `LIVE` or `TEST`.
229
+
-`ADYEN_ENVIRONMENT`: The indicator of adyen environment. Default value is `TEST`. It can be configured either as `LIVE` or `TEST`.
183
230
-`ADYEN_MERCHANT_ACCOUNT`: The name of adyen merchant account.
184
231
-`ADYEN_CLIENT_KEY`: Client key provided by Adyen for client-side authentication. For details, please refer to [Adyen client-side authentication](https://docs.adyen.com/development-resources/client-side-authentication).
185
232
-`ADYEN_LIVE_URL_PREFIX`: It represents live endpoint prefix used by Adyen platform. It is only required for Adyen live environment. For details, please refer to [Adyen live endpoints](https://docs.adyen.com/development-resources/live-endpoints/).
@@ -191,11 +238,45 @@ Here you can see the details about various variables in configuration
191
238
-`ADYEN_APPLEPAY_OWN_MERCHANT_DOMAIN`: The merchant domain verified in the Apple portal. Only needed if using an own certificate. Do not add the https protocol.
192
239
-`ADYEN_APPLEPAY_OWN_DISPLAY_NAME`: A string of 64 or fewer UTF-8 characters containing the canonical name for your store, suitable for display. This needs to remain a consistent value for the store and shouldn’t contain dynamic values such as incrementing order numbers. Only needed if using an own certificate.
193
240
-`ADYEN_SHOPPER_STATEMENT`: The text to be shown on the shopper's bank statement. For more information, see [Adyen's reference](https://docs.adyen.com/api-explorer/Checkout/71/post/payments#request-shopperStatement).
241
+
-`ADYEN_STORED_PAYMENT_METHODS_ENABLED`: Indicates if the stored payment methods feature is enabled or not. Must be a string value of "true" or "false". Default it's "false".
242
+
-`ADYEN_STORED_PAYMENT_METHODS_PAYMENT_INTERFACE`: A string value which is used to set the corresponding "paymentInterface" value on the CT payment-methods. If this value gets changed then previously created payment-methods won't be retrieved and would need to be manually migrated over.
243
+
-`ADYEN_STORED_PAYMENT_METHODS_INTERFACE_ACCOUNT`: A string value which is used to set the corresponding "interfaceAccount" value on the CT payment-methods. If this value gets changed then previously created payment-methods won't be retrieved and would need to be manually migrated over.
244
+
-`ADYEN_NOTIFICATION_HMAC_TOKENIZATION_WEBHOOKS_KEY`: A specific hmac key for the tokenization webhooks from Adyen. If not provided then the existing "ADYEN_NOTIFICATION_HMAC_KEY" env value is used.
245
+
246
+
## Feature
247
+
248
+
### stored payment methods
249
+
250
+
The feature stored payment methods allows the payment details to be tokenised to the next time the customers goes through Checkout they won't have to re-enter the payment details.
251
+
252
+
Currently supported payment-methods for storing: (for both web-components and drop-ins)
253
+
254
+
-`card`
255
+
256
+
#### Setting up stored payment methods
257
+
258
+
1. update the env configuration
259
+
1. set `ADYEN_STORED_PAYMENT_METHODS_ENABLED` to `true`. By default it is not enabled.
260
+
2. set `ADYEN_STORED_PAYMENT_METHODS_PAYMENT_INTERFACE` to any string value.
261
+
3. optionally set `ADYEN_STORED_PAYMENT_METHODS_INTERFACE_ACCOUNT` to any string value.
262
+
4. for the tokenization notifications choose between using a new HMAC key by setting `ADYEN_NOTIFICATION_HMAC_TOKENIZATION_WEBHOOKS_KEY` or if unset the connector will use the HMAC key of `ADYEN_NOTIFICATION_HMAC_KEY`
263
+
2. create a new CT API client which the additional scope of `manage_payment_methods` and update the corresponding env values. The connector health check will fail if the feature is enabled but the configured API client is missing this scope.
264
+
3. create a new webhook in Adyen of type `Recurring tokens life cycle events` with the event to be send of `recurring.token.created`.
265
+
1. the destination must be to `<processorUrl>/notifications/tokenization`
266
+
2. choose either the existing hmac key or generate a new one
267
+
4. ensure that before Checkout is instantiated the `cart.customerId` is set to the correct customer. The Adyen connector uses this for all interactions.
268
+
269
+
#### CT payment-methods and Adyen tokens
270
+
271
+
When a payment method is tokenized for the first time Adyen will send a new notification stating that the payment method has been tokenized. The processor handles the notification by creating a new payment-method in CT. The payment-method is attached to the `cart.customerId` as well as the `paymentInterface` and `interfaceAccount` are set based on the previously configured env values.
272
+
273
+
The next time the same customer goes through Checkout (either using drop-ins or web-components) they will see the stored payment method as a option to pay with.
194
274
195
275
## Development
276
+
196
277
In order to get started developing this connector certain configuration are necessary, most of which involve updating environment variables in both services (enabler, processor).
197
278
198
-
####Configuration steps
279
+
### Configuration steps
199
280
200
281
#### 1. Environment Variable Setup
201
282
@@ -206,13 +287,15 @@ cp .env.template .env
206
287
```
207
288
208
289
#### 2. Spin Up Components via Docker Compose
290
+
209
291
With the help of docker compose, you are able to spin up all necessary components required for developing the connector by running the following command from the root directory;
210
292
211
293
```bash
212
294
docker compose up
213
295
```
214
296
215
297
This command would start 3 required services, necessary for development
Copy file name to clipboardExpand all lines: connect.yaml
+13Lines changed: 13 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -62,6 +62,16 @@ deployAs:
62
62
- key: ADYEN_PAYMENT_COMPONENTS_CONFIG
63
63
description: 'Adyen payment components configuration in JSON String format. For example: {"paypal":{"blockPayPalVenmoButton":false}}. Please refer to the Adyen documentation for more details.'
64
64
required: false
65
+
- key: ADYEN_STORED_PAYMENT_METHODS_ENABLED
66
+
description: If set to "true" then the stored payment methods feature is enabled. Default value is "false".
description: The payment method interface account value used in the commerceotools payment methods.
73
+
required: false
74
+
65
75
securedConfiguration:
66
76
- key: CTP_CLIENT_SECRET
67
77
description: commercetools client secret
@@ -72,6 +82,9 @@ deployAs:
72
82
- key: ADYEN_NOTIFICATION_HMAC_KEY
73
83
description: Adyen HMAC key (Please use the dummy placeholder value during the installation process. Once the webhook configuration in Adyen is complete and HMAC known, replace this placeholder with the actual value and redeploy.)
description: Adyen HMAC tokenization webhooks key. This will be used if provided, otherwise the ADYEN_NOTIFICATION_HMAC_KEY will be used. (Please use the dummy placeholder value during the installation process. Once the webhook configuration in Adyen is complete and HMAC known, replace this placeholder with the actual value and redeploy.)
87
+
required: false
75
88
- key: ADYEN_APPLEPAY_OWN_CERTIFICATE
76
89
description: Apple Pay own certificate in base 64 format
0 commit comments