Skip to content

Commit f6583d6

Browse files
cybersource-tpiShakshiPoddarShakshi Poddarrajasuma1SA20184625
authored
23.1.0 (#10)
* Document for AWS Lambda Deplpoyment (#80) Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * eCheck (#85) * Document and code changes for AWS Lambda (#99) Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * 100 echeck document updation (#103) * eCheck document Updation * Update Process-a-Payment-eCheck.md * eCheck document Updation * eCheck diagram reference updated * eCheck diagram issue fixed * Version Changed to V22.2.0 (#106) * 107 document updation (#109) * Documentation changes added * review changes for document * 22.2.0 (#44) * Latest code with 3ds payment method integration * Latest code with subscription * Latest code with refactoring * latest code with unit testing * Latest code with Tokenization with update and delete tokens feature * Changed env file * Latest code with Google Pay payment method * Latest code for unit testing including google pay * Latest code with Apple Pay payment method * Latest code with google pay unit test cases * Latest code with 3ds defects fixed * Removed old Unit test folder * Latest code with apple pay unit test * Latest code with Sonar fix * Removed unwanted files * Latest code with tokenization bug fix * Latest code of unit test * Payer Authentication bundle call * Variable rename * Variable rename * Variable rename * Enroll fields mapping * Partner solution id & capture bug fix * Removed public folder * Unit test with latest fixes * Device information for payments * Messages updated * Messages updated * Messages updated * Updated messages * Spell check * Spell check * Added offset for run sync * Defect undefined firtstName fixed * Defect undefined firtstName fixed * Updated card details * Added more validation for service response * Added docs * Added docs * Added docs * Unit test case with latest fixes * Latest code with visa Click to Pay defect and TypeError fix * new feature rate limiter and discounts * Updated rate limiter variables * Updated rate limiter changes * 3ds Dm scenario updated * Updated payments query * Updated unit test cases * Feature sca (#37) * Latest code with SCA challenge for 3DS * Latest code with SCA challenge for 3DS * Add token and script to load custom data (#38) * Add token and script to load custom data * Add token and script to load custom types * Add token and script to load custom data * Add token and script to load custom data * Add token and script to load custom data * Added code for Sale and MOTO transactions (#41) * Updated docs for tokenization (#40) * Updates docs for tokenization * Updated docs for tokenization * loggers changes (#42) * updated documents for sale and MOTO transactions * Document for AWS Lambda Deplpoyment (#80) Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * eCheck (#85) * Document and code changes for AWS Lambda (#99) Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * 100 echeck document updation (#103) * eCheck document Updation * Update Process-a-Payment-eCheck.md * eCheck document Updation * eCheck diagram reference updated * eCheck diagram issue fixed * Version Changed to V22.2.0 (#106) * 22.2.0 release * 107 document updation (#109) * Documentation changes added * review changes for document Co-authored-by: sh20094173 <shwetha.v08@wipro.com> Co-authored-by: jbransvisa <55891199+jbransvisa@users.noreply.github.com> Co-authored-by: Shakshi Poddar (Americas 2 - iDEAS-Cloud Transformation) <sh20202930@wipro.com> Co-authored-by: Sandra <sandra.m07@wipro.com> Co-authored-by: shwethav08 <68940571+shwethav08@users.noreply.github.com> Co-authored-by: SA20184625 <85941120+SA20184625@users.noreply.github.com> Co-authored-by: rajasuma1 <85928576+rajasuma1@users.noreply.github.com> Co-authored-by: ShakshiPoddar <85929351+ShakshiPoddar@users.noreply.github.com> Co-authored-by: Krishna Prasad <ksalemna@visa.com> * Updated unit test cases (#110) * Updated unit test cases * Update PaymentRefundServiceECCredit.spec.ts Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * Defects fix and Docker deployment (#113) * Defects fix and Docker deployment * Defects-fix-and-Docker * Defects fix and Docker deployment * Defects fix and Docker deployment * 109 latest unit test (#119) * Updated document & unit test cases * Updated navigations & links * Updated AWS documents * Updated document * Update Commercetools-Setup.md --------- Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> * updated PSID (#126) * updatedDocuments (#130) * Checkmarx fixes (#131) * checkmarkfix --------- * checkmark fixes (#133) * 137 defect fix v23.1.0 (#141) * Auth Reversal issue fixed * Auth Reversal issue fixed with re-tries --------- Co-authored-by: ShakshiPoddar <85929351+ShakshiPoddar@users.noreply.github.com> Co-authored-by: Shakshi Poddar <sh20202930@wipro.com> Co-authored-by: rajasuma1 <85928576+rajasuma1@users.noreply.github.com> Co-authored-by: SA20184625 <85941120+SA20184625@users.noreply.github.com> Co-authored-by: sh20094173 <shwetha.v08@wipro.com> Co-authored-by: jbransvisa <55891199+jbransvisa@users.noreply.github.com> Co-authored-by: Sandra <sandra.m07@wipro.com> Co-authored-by: shwethav08 <68940571+shwethav08@users.noreply.github.com> Co-authored-by: Krishna Prasad <ksalemna@visa.com>
1 parent af0db56 commit f6583d6

73 files changed

Lines changed: 2167 additions & 617 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.env

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ PAYMENT_GATEWAY_SAVED_CARD_LIMIT_FRAME =
2727
PAYMENT_GATEWAY_DECISION_SYNC =
2828
PAYMENT_GATEWAY_RUN_SYNC =
2929

30-
AWS_ACCESS_KEY_ID_VALUE =
31-
AWS_SECRET_KEY_VALUE =
32-
AWS_REGION_NAME =
33-
PAYMENT_GATEWAY_ENABLE_CLOUD_LOGS =
30+
AWS_ACCESS_KEY_ID =
31+
AWS_SECRET_ACCESS_KEY =
32+
AWS_REGION =
33+
PAYMENT_GATEWAY_ENABLE_CLOUD_LOGS =
34+
PAYMENT_GATEWAY_ENABLE_SERVERLESS_DEPLOYMENT =
3435

3536
CT_PROJECT_KEY =
3637
CT_CLIENT_ID =

Dockerfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM node:16-alpine3.14
2+
3+
WORKDIR /app
4+
COPY . /app
5+
6+
RUN npm install
7+
8+
RUN npm run build
9+
10+
CMD ["node","build/main/index.js"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ This repository contains one standalone module that interact with Commercetools
2222
![Architecture](./docs/images/High-Level-Architecture.svg)
2323

2424
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.
2626
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.
2727
Note that order creations or modifications should be part of the front end business logic.
2828

2929
Please see the [Overview](./docs/Overview.md) for a high-level overview of the plugin.
3030

3131
## Plugin
3232

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.
3434

3535
- Follow [Setup Guide](./docs/Setup.md) for getting started with the integration of Commercetools with the plugin.
3636
- Follow [Usage Guide](./docs/Usage.md) to see more information about the payment services.

docs/API-Extension-Setup.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# API Extension Setup
22

3-
- [Configuration](#Configuration)
4-
- [Environment Properties](#EnvironmentProperties)
5-
- [Deployment](#Deployment)
3+
- [Configuration](#configuration)
4+
- [Environment Properties](#environment-properties)
5+
- [Deployment](#deployment)
66

7-
# <a name="Configuration"></a>Configuration
7+
# Configuration
88

99
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.
1010

11+
For multiple environments you should use unique values per environment.
1112
For multiple environments you should use unique values per environment.
1213

13-
## <a name="EnvironmentProperties"></a>Environment Properties
14+
## Environment Properties
1415

1516
Variables that begin with 'CT' prefix are Commercetools project specific properties.
1617

@@ -31,31 +32,34 @@ Variables that begin with 'CT' prefix are Commercetools project specific propert
3132
| 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 |
3233
| PAYMENT_GATEWAY_ENABLE_DEBUG | Boolean value - true or false | Flag for enabling or disabling logging of requests that is send to Cybersource. Case sensitive |
3334
| 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 |
3536
| PAYMENT_GATEWAY_APPLE_PAY_KEY_PATH | Path where the Apple Pay key is stored | Used only if payment.paymentMethodInfo.method == applePay |
3637
| 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 |
3738
| 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 |
3839
| 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 |
3940
| PAYMENT_GATEWAY_DECISION_SYNC | Boolean value - true or false | Flag for enabling or disabling Decision sync. Case sensitive |
4041
| 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 |
4445
| 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.
4547
| CT_PROJECT_KEY | Project key for your Commercetools project | Created in <a href="Key-Creation.md">Key Creation</a> |
4648
| CT_CLIENT_ID | Client Id of your Commercetools Payment API key | Created in <a href="Key-Creation.md">Key Creation</a> |
4749
| CT_CLIENT_SECRET | Client secret of your Commercetools Payment API key | Created in <a href="Key-Creation.md">Key Creation</a> |
4850
| CT_AUTH_HOST | Commercetools auth server URL | Created in <a href="Key-Creation.md">Key Creation</a> |
4951
| CT_API_HOST | Commercetools API server URL | Created in <a href="Key-Creation.md">Key Creation</a> |
5052

51-
# <a name="Deployment"></a>Deployment
53+
# Deployment
5254

5355
The Commercetools - Cybersource plugin is a typescript project which is built using cybersource-rest-client npm package and other several node packages.
5456

5557
> **_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.
5658
5759
If you want serverless deployment of the plugin on AWS Lambda, refer [AWS-Serverless-Deployment\#AWSDeploymentSteps](AWS-Serverless-Deployment.md#AWSDeploymentSteps)
5860

61+
If you want serverless deployment of the plugin on AWS Lambda, refer [AWS-Serverless-Deployment\#AWSDeploymentSteps](AWS-Serverless-Deployment.md#AWSDeploymentSteps)
62+
5963
## Example deployment steps
6064

6165
The steps involved in deploying the Commercetools - Cybersource plugin in development environment are the following:

docs/AWS-Serverless-Deployment.md

Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Here is a list of pre-requisites that you need to have before proceeding with de
1515
- Active AWS subscription
1616
- AWS credentials
1717

18-
## <a name="AWSSecurityCredentials"></a>AWS Security Credentials
18+
## AWS Security Credentials
1919

2020
To connect the application to AWS account, you need to generate AWS Security Credentials. Follow below steps to generate security credentials
2121

@@ -29,23 +29,12 @@ To connect the application to AWS account, you need to generate AWS Security Cre
2929
3030
3. The downloaded file contains `AWSAccessKeyId` and `AWSSecretKey`, use these credentials whenever required.
3131

32-
## <a name="ServerlessFrameworkServices"></a>Serverless Framework Services
32+
## Serverless Framework Services
3333

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.
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.
4735

4836
Specify the event along with the path which will trigger the handler function.
37+
The serverless.yml file should looks like as follows:
4938

5039
functions:
5140
HandlerFunction:
@@ -73,32 +62,33 @@ In order to get logs in AWS Cloudwatch, you need to provide following permission
7362
Resource:
7463
- arn:aws:logs:*:*:*
7564

65+
Inside provider, you need to provide timeout for your API gateway as 20 second
66+
67+
timeout: 20
68+
7669
> **_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))
7770
7871
## Loggers in AWS Cloudwatch
7972

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))
8174

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-
## <a name="AWSDeploymentSteps"></a>Steps to Deploy Plugin on AWS Lambda
75+
## Steps to Deploy Plugin on AWS Lambda
8676

8777
1. Navigate to the root directory and run the following command to include the npm dependencies
8878

8979
npm install
9080

9181
> **_NOTE:_** This is not necessary if the dependencies are already available in <b>node_modules</b> repository
9282
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
9484

9585
serverless config credentials --provider aws --key <your_aws_access_key_id> --secret <your_aws_access_key_secret>
9686

9787
3. Remove .gitignore file and and run the following command
9888

9989
Serverless create -t aws-nodejs
10090

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))
10292

10393
5. To deploy a service, run the below command in the same directory as serverless.yml i.e. root directory
10494

@@ -108,12 +98,12 @@ You can see all your logs in AWS Cloudwatch, for that you need to perform below
10898
- Navigate to the lambda and click on the lambda function that has been created after successful deployment.
10999
- Navigate to Configuration -> Environment variables and click on Add environment variable.
110100
- 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.
111105

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
117107

118108
## Troubleshoot
119109

@@ -126,3 +116,5 @@ You need to have custom domain for your application since your application will
126116
[default]
127117
aws_access_key_id=${Your access key ID}
128118
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

Comments
 (0)