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
This repository provides a [connect](https://docs.commercetools.com/connect)template for payment integration connector. This boilerplate code acts as a starting point for integration with external payment service provider.
3
+
This repository provides a [connect](https://docs.commercetools.com/connect) for integration to Braintree payment service provider (PSP).
4
4
5
-
## Template Features
5
+
## Features
6
6
7
7
- Typescript language supported.
8
8
- Uses Fastify as web server framework.
9
9
- Uses [commercetools SDK](https://docs.commercetools.com/sdk/js-sdk-getting-started) for the commercetools-specific communication.
10
10
- Uses [connect payment SDK](https://github.com/commercetools/connect-payments-sdk) to manage request context, sessions and JWT authentication.
11
11
- Includes local development utilities in npm commands to build, start, test, lint & prettify code.
12
12
13
+
## Important Notes
14
+
15
+
### Merchant Account Configuration
16
+
- Each connect deployment supports only one Braintree merchant account with single specific currency.
17
+
- Cart currency is validated against the Braintree merchant account currency during:
18
+
- Payment session initialization
19
+
- Payment creation
20
+
21
+
### Payment Status Updates
22
+
Our payment connector submits requests for various payment operations to Braintree. Since the payment capture and refund operations are asynchronous in Braintree (Payment reversal is also asynchronous in case the payment has been captured), the most up-to-date status of these operations reside in the Braintree platform, not in commercetools payment transactions.
23
+
24
+
**Note for Merchants**:
25
+
- The transaction status in commercetools payment indicates whether payment capture/refund requests can be delivered to to Braintree platform.
26
+
- Merchants are suggested to send request directly to the Braintree platform in case it is necessaary to know the latest capture/refund processing status.
27
+
13
28
## Prerequisite
14
29
15
30
#### 1. commercetools composable commerce API client
@@ -22,42 +37,22 @@ In addition, please make sure the API client should have enough scope to be able
22
37
Various URLs from commercetools platform are required to be configured so that the connect application can handle session and authentication process for endpoints.
23
38
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`.
24
39
25
-
## Getting started
26
-
27
-
The template contains two modules :
40
+
3. Braintree account credentials
41
+
Various account data provided by Braintree are necessary to be configured so that the requests from the connect application can be authenticated by Braintree platform within the integration. Their values are taken as input as environment variables/ configuration for connect with variable names `BRAINTREE_MERCHANT_ID`, `BRAINTREE_MERCHANT_ACCOUNT_ID`, `BRAINTREE_PUBLIC_KEY`, `BRAINTREE_PRIVATE_KEY`.
28
42
29
-
- Enabler: Acts as a wrapper implementation in which frontend components from PSPs 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.
30
-
- Processor : Acts as backend services which is middleware to 3rd party PSPs to be responsible for managing transactions with PSPs 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.
43
+
## Development Guide
44
+
Regarding the development of enabler module, please refer to the following documentations:
45
+
-[Development of Enabler](./enabler/README.md)
31
46
32
47
Regarding the development of processor module, please refer to the following documentations:
33
-
34
-
### Currencies
35
-
36
-
A special note regarding the usage of currencies and working with them. commercetools provides monetary values in cent amounts which adheres to the <https://en.wikipedia.org/wiki/ISO_4217> standard.
37
-
38
-
This means that for the currency `EUR` the minor units will be expressed with fraction digits of 2. I.e. a value of 1 euro and 50 cents will be expressed as `150`. Some currencies have 0 or even 4 fraction digits.
39
-
40
-
It's important to note that individual PSP could differ from this standard and/or require special attention when passing data between the connector and psp. So it's important to convert properly on the input and output layer when interacting with PSP.
41
-
42
-
commercetools provides the library [connect-payments-sdk](https://github.com/commercetools/connect-payments-sdk) which includes various utility function to help with these conversions.
43
-
44
48
-[Development of Processor](./processor/README.md)
45
49
46
-
#### 1. Develop your specific needs
47
-
48
-
To proceed payment operations via external PSPs, users need to extend this connector with the following task
49
-
50
-
- API communication: Implementation to communicate between this connector application and the external system using libraries provided by PSPs. Please remember that the payment requests might not be sent to PSPs successfully in a single attempt. It should have needed retry and recovery mechanism.
51
-
52
-
#### 2. Register as connector in commercetools Connect
53
-
54
-
Follow guidelines [here](https://docs.commercetools.com/connect/getting-started) to register the connector for public/private use.
55
-
56
-
## Deployment Configuration
50
+
#### Connector in commercetools Connect
51
+
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.
57
52
53
+
#### Deployment Configuration
58
54
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)
59
-
In addition, in order to support connect, the tax integration connector template has a folder structure as listed below
60
-
55
+
In addition, in order to support connect, the Braintree payment integration connector has a folder structure as listed below
61
56
```
62
57
├── enabler
63
58
│ ├── src
@@ -70,8 +65,7 @@ In addition, in order to support connect, the tax integration connector template
70
65
└── connect.yaml
71
66
```
72
67
73
-
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
74
-
68
+
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
75
69
```
76
70
deployAs:
77
71
- name: enabler
@@ -84,9 +78,6 @@ deployAs:
84
78
- key: CTP_PROJECT_KEY
85
79
description: commercetools project key
86
80
required: true
87
-
- key: CTP_CLIENT_ID
88
-
description: commercetools client ID with manage_payments, manage_orders, view_sessions, view_api_clients, manage_checkout_payment_intents & introspect_oauth_tokens scopes
description: Braintree environment (sandbox or production)
112
+
required: true
110
113
securedConfiguration:
111
114
- key: CTP_CLIENT_SECRET
112
115
description: commercetools client secret
113
116
required: true
117
+
- key: BRAINTREE_PUBLIC_KEY
118
+
description: Braintree public key
119
+
required: true
120
+
- key: BRAINTREE_PRIVATE_KEY
121
+
description: Braintree private key
122
+
required: true
123
+
114
124
```
115
125
116
126
Here you can see the details about various variables in configuration
117
-
118
127
-`CTP_PROJECT_KEY`: The key of commercetools composable commerce project.
119
-
-`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``manage_types``view_types`.
128
+
-`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`.
120
129
-`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.
121
130
-`CTP_AUTH_URL`: The URL for authentication in commercetools platform. It is used to generate OAuth 2.0 token which is required in every API call to commercetools composable commerce. The default value is `https://auth.europe-west1.gcp.commercetools.com`. For details, please refer to documentation [here](https://docs.commercetools.com/tutorials/api-tutorial#authentication).
122
131
-`CTP_API_URL`: The URL for commercetools composable commerce API. Default value is `https://api.europe-west1.gcp.commercetools.com`.
123
132
-`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`.
124
-
-`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`
125
-
-`CTP_JWT_ISSUER`: The issuer inside JSON Web Token which is required in JWT validation process. Default value is `https://mc-api.europe-west1.gcp.commercetools.com`
133
+
-`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`.
134
+
-`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`
135
+
-`BRAINTREE_ENVIRONMENT`: The indicator of Braintree environment. Default value is `SANDBOX`. It can be configured either as `PRODUCTION` or `SANDBOX`.
136
+
-`BRAINTREE_MERCHANT_ID`: A unique identifier for the entire gateway account. This value is required to send API calls to the Braintree gateway.
137
+
-`BRAINTREE_MERCHANT_ACCOUNT_ID`: The merchant account ID is a unique identifier for a specific merchant account in your Braintree gateway, and is used to specify which merchant account to use when creating a transaction. Remember that each connect deployment supports only 1 merchant account.
138
+
-`BRAINTREE_PUBLIC_KEY`: This is the user-specific public identifier for Braintree. Each user associated with their Braintree gateway will have their own public key.
139
+
-`BRAINTREE_PRIVATE_KEY`: This is the user-specific private identifier. Each user associated with their Braintree gateway will have their own private key.
126
140
127
141
## Development
128
-
129
142
In order to get started developing this connector certain configuration are necessary, most of which involve updating environment variables in both services (enabler, processor).
130
143
131
144
#### Configuration steps
@@ -139,15 +152,13 @@ cp .env.template .env
139
152
```
140
153
141
154
#### 2. Spin Up Components via Docker Compose
142
-
143
155
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;
144
156
145
157
```bash
146
158
docker compose up
147
159
```
148
160
149
161
This command would start 3 required services, necessary for development
0 commit comments