-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'kinghin.leung/edit-gitignore' into kinghin.leung/create…
…-supported-payment-api
- Loading branch information
Showing
16 changed files
with
1,837 additions
and
3,073 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Code Editor directories and files | ||
.idea |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,62 @@ | ||
# Payment Integration template Processor | ||
|
||
## Getting Started | ||
|
||
These instructions will get you up and running on your local machine for development and testing purposes. | ||
|
||
### Prerequisites | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
### Running application | ||
|
||
Setup correct environment variables: check `processor/src/config/config.ts` for default values. | ||
|
||
Make sure `clientId` and `clientSecret` have at least the following permissions: | ||
|
||
* `manage_payments` | ||
* `manage_checkout_payment_intents` | ||
* `view_sessions` | ||
* `introspect_oauth_tokens` | ||
|
||
``` | ||
npm run dev | ||
``` | ||
|
||
#### Additional notes | ||
|
||
Some of the services have authentication mechanism. | ||
|
||
* `jwt`: Relies on the jwt token injected by the merchant center via the forward-to proxy | ||
* `session`: Relies on commercetools session service | ||
* `oauth2`: Relies on commercetools oauth2 server | ||
|
||
While `session` and `oauth2` authentication mechanisms are easy to work locally, `jwt` will need some workaround to be able to test locally as it depends on the merchant center forward-to proxy. | ||
|
||
In order to make easy running the application locally, the code comes with a jwt mock server: | ||
|
||
``` | ||
# Set environment variable to point to the jwksUrl | ||
export CTP_JWKS_URL="http://localhost:9000/jwt/.well-known/jwks.json" | ||
# Run the jwt server | ||
docker compose up -d | ||
``` | ||
|
||
**Get a token** | ||
``` | ||
# Request token | ||
curl --location 'http://localhost:9000/jwt/token' \ | ||
--header 'Content-Type: application/json' \ | ||
--data '{ | ||
"iss": "https://mc-api.europe-west1.gcp.commercetools.com", | ||
"sub": "subject", | ||
"https://mc-api.europe-west1.gcp.commercetools.com/claims/project_key": "<project-key>" | ||
}' | ||
{"token":"<token>"} | ||
``` | ||
|
||
Use the token to authenticate requests protected by JWT: `Authorization: Bearer <token>`. |
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,14 @@ | ||
version: "3.8" | ||
|
||
services: | ||
jwt-server: | ||
image: node:alpine | ||
restart: always | ||
command: | ||
- npx | ||
- --package | ||
- jwt-mock-server | ||
- -y | ||
- start | ||
ports: | ||
- 9000:9000 |
Oops, something went wrong.