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
1. Front end can be any module which is supported by Commercetools. Refer [create payment](./docs/Creating-a-Payment.md) to know more about the fields that needs to be passed when a payment is created for each of the payment method.
25
-
2. With help of the [Commercetools HTTP API Extensions](https://docs.commercetools.com/http-api-projects-api-extensions), provided payment data is sent to the plugin.
25
+
2. With help of the [Commercetools HTTP API Extensions](https://docs.commercetools.com/api/projects/api-extensions), provided payment data is sent to the plugin.
26
26
3. The plugin authenticates and processes provided payload passed by the front end, exchanges it with Cybersource API, and provides **Synchronous** response back to the Commercetools caller. Based on the result, front end either creates an order or continues with further payment steps.
27
27
Note that order creations or modifications should be part of the front end business logic.
28
28
29
29
Please see the [Overview](./docs/Overview.md) for a high-level overview of the plugin.
30
30
31
31
## Plugin
32
32
33
-
The plugin is a publicly exposed service that acts as a middleware between the Commercetools platform and Cybersource. Once [Commercetools HTTP API Extensions](https://docs.commercetools.com/http-api-projects-api-extensions) is [configured](./docs/API-Extension-Setup.md#a-namerunningscriptarunning-extension-setup-script) to call Cybersource plugin, for every payment create or update request and customer update request, a Cybersource plugin will be remotely called by the Commercetools platform.
33
+
The plugin is a publicly exposed service that acts as a middleware between the Commercetools platform and Cybersource. Once [Commercetools HTTP API Extensions](https://docs.commercetools.com/api/projects/api-extensions) is [configured](./docs/API-Extension-Setup.md#a-namerunningscriptarunning-extension-setup-script) to call Cybersource plugin, for every payment create or update request and customer update request, a Cybersource plugin will be remotely called by the Commercetools platform.
34
34
35
35
- Follow [Setup Guide](./docs/Setup.md) for getting started with the integration of Commercetools with the plugin.
36
36
- Follow [Usage Guide](./docs/Usage.md) to see more information about the payment services.
There are a number of configuration variables that need to be defined before running the plugin. These can be set as environment variables inside the .env file present in the root directory of the plugin.
10
10
11
+
For multiple environments you should use unique values per environment.
11
12
For multiple environments you should use unique values per environment.
Variables that begin with 'CT' prefix are Commercetools project specific properties.
16
17
@@ -31,31 +32,34 @@ Variables that begin with 'CT' prefix are Commercetools project specific propert
31
32
| PAYMENT_GATEWAY_3DS_RETURN_URL | URL that the issuing bank will redirect to the customer for payer Authentication | Used only if payment.paymentMethodInfo.method == creditCardWithPayerAuthentication |
32
33
| PAYMENT_GATEWAY_ENABLE_DEBUG | Boolean value - true or false | Flag for enabling or disabling logging of requests that is send to Cybersource. Case sensitive |
33
34
| PAYMENT_GATEWAY_APPLE_PAY_MERCHANT_ID | Your Apple Pay merchant Id | Provided by Apple |
34
-
| PAYMENT_GATEWAY_APPLE_PAY_CERTIFICATE_PATH | Path where the Apple Pay certificate is stored | Used only if payment.paymentMethodInfo.method == applePay|
35
+
| PAYMENT_GATEWAY_APPLE_PAY_CERTIFICATE_PATH | Path where the Apple Pay certificate is stored | Used only if payment.paymentMethodInfo.method == applePay. Ensure that the path given is globally accessible if plugin is hosted using any serverless deployments|
35
36
| PAYMENT_GATEWAY_APPLE_PAY_KEY_PATH | Path where the Apple Pay key is stored | Used only if payment.paymentMethodInfo.method == applePay |
36
37
| PAYMENT_GATEWAY_ENABLE_RATE_LIMITER | Boolean value - true or false | Enable to restrict the number of cards a customer can save within the give time limit. Case sensitive |
37
38
| PAYMENT_GATEWAY_LIMIT_SAVED_CARD_RATE | Numeric value | Provide the number of attempts in below specified time period (this time frame includes Success & Failures). By default this value is set to 10, applicable only if rate limiter is enabled |
38
39
| PAYMENT_GATEWAY_SAVED_CARD_LIMIT_FRAME | Numeric value between 1-24 | Provide the number of hours that saved card attempts are counted (Max of 24 hours). By default this value is set to 1, applicable only if rate limiter is enabled |
39
40
| PAYMENT_GATEWAY_DECISION_SYNC | Boolean value - true or false | Flag for enabling or disabling Decision sync. Case sensitive |
40
41
| PAYMENT_GATEWAY_RUN_SYNC | Boolean value - true or false | Flag for enabling or disabling Run sync. Case sensitive |
41
-
|AWS_ACCESS_KEY_ID_VALUE| AWS Access Key ID | Provided by AWS in [AWS-Serverless-Deployment\#AWSSecurityCredentials](AWS-Serverless-Deployment.md#AWSSecurityCredentials). Required when deploying on AWS lambda|
42
-
|AWS_SECRET_KEY_VALUE| AWS Secret Key | Provided by AWS in [AWS-Serverless-Deployment\#AWSSecurityCredentials](AWS-Serverless-Deployment.md#AWSSecurityCredentials). Required when deploying on AWS lambda|
43
-
|AWS_REGION_NAME| AWS Region Name | Provided by AWS. Required when deploying on AWS lambda|
42
+
|AWS_ACCESS_KEY_ID| AWS Access Key ID | Provided by AWS in [AWS-Serverless-Deployment\#AWSSecurityCredentials](AWS-Serverless-Deployment.md#AWSSecurityCredentials). Required when running Docker container in AWS |
43
+
|AWS_SECRET_ACCESS_KEY| AWS Secret Key | Provided by AWS in [AWS-Serverless-Deployment\#AWSSecurityCredentials](AWS-Serverless-Deployment.md#AWSSecurityCredentials). Required when running Docker container in AWS|
44
+
|AWS_REGION| AWS Region Name | Provided by AWS. Required when running Docker container in AWS|
44
45
| PAYMENT_GATEWAY_ENABLE_CLOUD_LOGS | Boolean value - true or false | Set the value to true to get AWS Cloudwatch logs. Case sensitive. |
46
+
| PAYMENT_GATEWAY_ENABLE_SERVERLESS_DEPLOYMENT | Boolean value - true or false | Set the value to true when the plugin is hosted using any serverless deployments.
45
47
| CT_PROJECT_KEY | Project key for your Commercetools project | Created in <ahref="Key-Creation.md">Key Creation</a> |
46
48
| CT_CLIENT_ID | Client Id of your Commercetools Payment API key | Created in <ahref="Key-Creation.md">Key Creation</a> |
47
49
| CT_CLIENT_SECRET | Client secret of your Commercetools Payment API key | Created in <ahref="Key-Creation.md">Key Creation</a> |
48
50
| CT_AUTH_HOST | Commercetools auth server URL | Created in <ahref="Key-Creation.md">Key Creation</a> |
49
51
| CT_API_HOST | Commercetools API server URL | Created in <ahref="Key-Creation.md">Key Creation</a> |
50
52
51
-
# <aname="Deployment"></a>Deployment
53
+
# Deployment
52
54
53
55
The Commercetools - Cybersource plugin is a typescript project which is built using cybersource-rest-client npm package and other several node packages.
54
56
55
57
> **_NOTE:_** You can view the loggers in src/loggers folder of the plugin if there are any information or errors found while processing the payments or configuring the plugin.
56
58
57
59
If you want serverless deployment of the plugin on AWS Lambda, refer [AWS-Serverless-Deployment\#AWSDeploymentSteps](AWS-Serverless-Deployment.md#AWSDeploymentSteps)
58
60
61
+
If you want serverless deployment of the plugin on AWS Lambda, refer [AWS-Serverless-Deployment\#AWSDeploymentSteps](AWS-Serverless-Deployment.md#AWSDeploymentSteps)
62
+
59
63
## Example deployment steps
60
64
61
65
The steps involved in deploying the Commercetools - Cybersource plugin in development environment are the following:
The Serverless Framework is a command-line tool that uses easy and approachable YAML syntax to deploy your code. A service is configured via `serverless.yml` file where you define your functions, the events that trigger them, and the AWS resources to deploy. Each service configuration is managed in the serverless.yml file.
35
-
36
-
The main responsibilities of this file are:
37
-
38
-
- Declare a serverless service
39
-
- Define the cloud provider where the service will be deployed
40
-
- Define one or more functions
41
-
- Define the events that trigger each function (e.g. HTTP requests)
42
-
- Define a set of AWS resources to create
43
-
- Allow events listed in the events section to automatically create the resources required for the event upon deployment
44
-
- Allow flexible configuration using variables
45
-
46
-
Any service configuration will be done in `serverless.yml` file. You can see the name of the service, here you can provide your service name. The function inside the functions definition, it should point to `build/main/index.handler` since in index file we are wrapping our API for serverless use.
34
+
The Serverless Framework is a command-line tool that uses easy and approachable YAML syntax to deploy your code. A service is configured via `serverless.yml` file where you define your functions, the events that trigger them, and the AWS resources to deploy. Each service configuration is managed in the serverless.yml file. You can see the name of the service and here you can provide your service name as per your convenience. The function inside the functions definition, it should point to `build/main/index.handler` since in index file we are wrapping our API for serverless use.
47
35
48
36
Specify the event along with the path which will trigger the handler function.
37
+
The serverless.yml file should looks like as follows:
49
38
50
39
functions:
51
40
HandlerFunction:
@@ -73,32 +62,33 @@ In order to get logs in AWS Cloudwatch, you need to provide following permission
73
62
Resource:
74
63
- arn:aws:logs:*:*:*
75
64
65
+
Inside provider, you need to provide timeout for your API gateway as 20 second
66
+
67
+
timeout: 20
68
+
76
69
> **_NOTE:_** Make sure to have correct indentation for each line in `serverless.yml` file. (Refer [Serverless.yml Reference](https://www.serverless.com/framework/docs/providers/aws/guide/serverless.yml))
77
70
78
71
## Loggers in AWS Cloudwatch
79
72
80
-
You can see all your logs in AWS Cloudwatch, for that you need to perform below steps.
73
+
You can see all your logs in AWS Cloudwatch, for that you need to pass the value as `true` for the ENV variable `PAYMENT_GATEWAY_ENABLE_CLOUD_LOGS` in .env file.(Refer [API-Extension-Setup](API-Extension-Setup.md))
81
74
82
-
- Provide your AWS Access Key ID ,Secret Key and AWS Region Name in .env file. (Refer [API-Extension-Setup](API-Extension-Setup.md))
83
-
- Pass the value as `true` for the ENV variable `PAYMENT_GATEWAY_ENABLE_CLOUD_LOGS` in .env file.(Refer [API-Extension-Setup](API-Extension-Setup.md))
84
-
85
-
## <aname="AWSDeploymentSteps"></a>Steps to Deploy Plugin on AWS Lambda
75
+
## Steps to Deploy Plugin on AWS Lambda
86
76
87
77
1. Navigate to the root directory and run the following command to include the npm dependencies
88
78
89
79
npm install
90
80
91
81
> **_NOTE:_** This is not necessary if the dependencies are already available in <b>node_modules</b> repository
92
82
93
-
2. Populate AWS security credentials (Refer [AWS Security Credentials](#AWSSecurityCredentials)) and run the following command
83
+
2. Populate AWS security credentials (Refer [AWS Security Credentials](#aws-security-credentials)) and run the following command
3. Remove .gitignore file and and run the following command
98
88
99
89
Serverless create -t aws-nodejs
100
90
101
-
4. Above command will add one file in the root directory i.e. serverless.yml . Populate the required values in this file. (Refer [Serverless Framework Services](#ServerlessFrameworkServices))
91
+
4. Above command will add one file in the root directory i.e. serverless.yml . Populate the required values in this file. (Refer [Serverless Framework Services](#serverless-framework-services))
102
92
103
93
5. To deploy a service, run the below command in the same directory as serverless.yml i.e. root directory
104
94
@@ -108,12 +98,12 @@ You can see all your logs in AWS Cloudwatch, for that you need to perform below
108
98
- Navigate to the lambda and click on the lambda function that has been created after successful deployment.
109
99
- Navigate to Configuration -> Environment variables and click on Add environment variable.
110
100
- Enter key and value for your ENV variable and click on save. (Refer [API-Extension-Setup](API-Extension-Setup.md))
101
+
102
+
**_NOTE:_** AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY and AWS_REGION can't be modified since they are AWS reserved keywords.
103
+
104
+
The execution role which will be created while deploying to AWS lambda will provide the credentials to lambda function which can be used to run and invoke other web services. Therefore, you don't need to provide AWS credentials in .env file.
111
105
112
-
## Custom Domain Name for Lambda
113
-
114
-
With Serverless, it's easier than ever to deploy production-ready API endpoints. However, using AWS API Gateway results in odd hostnames for your endpoints. Further, these hostnames will change if you remove and redeploy your service. To map a custom domain name to your endpoints, Refer [Serverless-Api-Gateway-Domain](https://www.serverless.com/blog/serverless-api-gateway-domain/)
115
-
116
-
You need to have custom domain for your application since your application will be hosted on that URL and that URL will be used to create API extensions.
106
+
**_NOTE:_** If You need to have custom domain for your application since your application will be hosted on that URL and that URL will be used to create API extensions, refer [Serverless-Api-Gateway-Domain](https://www.serverless.com/blog/serverless-api-gateway-domain/) for more information
117
107
118
108
## Troubleshoot
119
109
@@ -126,3 +116,5 @@ You need to have custom domain for your application since your application will
126
116
[default]
127
117
aws_access_key_id=${Your access key ID}
128
118
aws_secret_access_key=${Your secret access key}
119
+
120
+
3. If you are getting "Internal server error" while running sync service, increase the timeout of your API gateway to 30 seconds in serverless.yml file or in General Configuration of Lambda Function of AWS Console to avoid such error.
0 commit comments