Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Tung-Huynh-Shopmacher committed Jul 18, 2024
2 parents c618716 + 4c8be33 commit 6c198bd
Show file tree
Hide file tree
Showing 15 changed files with 5,405 additions and 449 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: CI

on:
push:
branches:
- main
- develop
pull_request:
branches:
- "**"

jobs:
build-processor:
runs-on: ubuntu-latest

defaults:
run:
working-directory: processor

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node.js 18.x
uses: actions/setup-node@v3
with:
node-version: "18.x"

- name: Install dependencies
run: npm ci

- name: ESLint check
run: npm run lint

- name: Prettier check
run: npm run prettier:check

- name: Build project
run: npm run build

- name: Run tests
run: npm run test

- name: Run audit
run: npm audit
54 changes: 54 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Publish

on:
push:
tags:
# Release tags v1.0.0, v1.0.1, v1.0.2, etc.
- 'v[0-9]+.[0-9]+.[0-9]+'
# Pre-release tags v1.0.0-alpha.0, v1.0.0-beta.0, etc.
- 'v[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+'
- latest
workflow_dispatch:

jobs:
publish:
name: Publish for commercetools Checkout
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install
env:
CTP_CLIENT_ID: ${{ secrets.CTP_CLIENT_ID }}
CTP_CLIENT_SECRET: ${{ secrets.CTP_CLIENT_SECRET }}
CTP_CONNECTOR_KEY: ${{ secrets.CTP_CONNECTOR_KEY }}
CTP_REGION: ${{ secrets.CTP_REGION }}
run: |
echo Updating connector to tag $GITHUB_REF_NAME
echo Authenticating with commercetools
OAUTH_RESPONSE=$(curl --silent --show-error --location --request POST "https://auth.$CTP_REGION.commercetools.com/oauth/token?grant_type=client_credentials" -u $CTP_CLIENT_ID:$CTP_CLIENT_SECRET)
ACCESS_TOKEN=$(echo $OAUTH_RESPONSE | jq -r '.access_token')
echo Access token retrieved
CONNECTOR_DETAILS=$(curl --silent --show-error --location "https://connect.$CTP_REGION.commercetools.com/connectors/drafts/key=$CTP_CONNECTOR_KEY" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN")
VERSION=$(echo $CONNECTOR_DETAILS | jq -r '.version')
echo Updating version $VERSION
curl --fail-with-body --silent --location POST "https://connect.$CTP_REGION.commercetools.com/connectors/drafts/key=$CTP_CONNECTOR_KEY" \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--data-raw "{\"version\": $VERSION, \"actions\": [{\"action\": \"setRepository\",\"url\": \"[email protected]:mollie/commercetools-connector.git\",\"tag\": \"$GITHUB_REF_NAME\"},{\"action\": \"updatePreviewable\"}]}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ dist

.DS_Store
.vscode
.idea
build/
processor/.env
91 changes: 43 additions & 48 deletions docs/GetPaymentMethods.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
## GET PAYMENT METHODS

Use this to retrieve the list of available Mollie's payment methods.

**Endpoint**

```
Method: POST
Type: RAW
URL: {{extension-public-url}}/processor
```

**Headers**

| **Key** | **Value** |
| ------------ | ---------------- |
| Content-Type | application/json |

**Body**

_Parameters mapping_

| **CT fields** | **Mollie fields** | **Required** |
| --------------------------------------------------------- | ----------------- | ------------ |
| paymentMethodInfo.paymentInterface | ||
| amountPlanned | amount ||
| custom.fields.sctm_payment_methods_request | ||
| custom.fields.sctm_payment_methods_request.sequenceType | sequenceType ||
| custom.fields.sctm_payment_methods_request.locale | locale ||
| custom.fields.sctm_payment_methods_request.resource | resource ||
| custom.fields.sctm_payment_methods_request.billingCountry | billingCountry ||
**Integration steps**

No matter when payment methods is retrieved, the `payment` object has to be **create/update** for the connector procedure to be triggered

1. A `payment` object must be instantiated/modified via CT extension actions
2. The object has several parameters as described in the table below
3. The connector will return the corresponding update actions to this `payment` object
4. Then, these update actions will be consumed and update the `payment` object with its Mollie responses

**Parameters**

| **Name** | **Required** | **Note** |
| -------------------------------------------------------------- | ------------ | ---------------------------------------------------------------------------- |
| amountPlanned || To detemine Mollie payment amount |
| paymentMethodInfo.paymentInterface || To be verified by the connector |
| custom.fields.sctm_payment_methods_response || To trigger the listing payment method action - **its value should be empty** |
| custom.fields.sctm_payment_methods_request || To hold all the listing option for Mollie |
| custom.fields.sctm_payment_methods_request.sequenceType | | To hold Mollie `sequenceType` option |
| custom.fields.sctm_payment_methods_request.locale | | To hold Mollie `locale` option |
| custom.fields.sctm_payment_methods_request.resource | | To hold Mollie `resource` option |
| custom.fields.sctm_payment_methods_request.billingCountry | | To hold Mollie `billingCountry` option |
| custom.fields.sctm_payment_methods_request.includeWallets | | To hold Mollie `includeWallets` option |
| custom.fields.sctm_payment_methods_request.orderLineCategories | | To hold Mollie `orderLineCategories` option |
| custom.fields.sctm_payment_methods_request.include | | To hold Mollie `include` option |

_Example payload_

Expand All @@ -38,31 +32,28 @@ _Example payload_
"action": "Create",
"resource": {
"typeId": "payment",
"id": "pm_112555",
"id": "PM-112555",
"obj": {
"id": "SOMERANDOMID-123456",
"id": "PID-123456",
"amountPlanned": {
"type": "centPrecision",
"currencyCode": "EUR",
"centAmount": 1000,
"fractionDigits": 2
},
"paymentMethodInfo": {
"paymentInterface": "Mollie",
"method": "paypal"
"paymentInterface": "Mollie"
},
"custom": {
"fields": {
"sctm_payment_methods_request": {
"sequenceType": "oneoff",
"locale": "de_DE",
"amount": {
"value": "10.00",
"currencyCode": "EUR"
},
"resource": "payments",
"billingCountry": "DE"
}
"billingCountry": "DE",
"includeWallets": "applepay"
},
"sctm_payment_methods_response: {}
}
}
}
Expand All @@ -78,13 +69,17 @@ _Body:_

```json
{
"actions": [
{
"action": "setCustomField",
"name": "sctm_payment_methods_response",
"value": "{\"count\":10,\"methods\":[{\"resource\":\"method\",\"id\":\"creditcard\",\"description\":\"Karte\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"10000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard<mention value="2">2</mention>x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/creditcard\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"paypal\",\"description\":\"PayPal\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":null,\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/paypal.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/paypal<mention value="2">2</mention>x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/paypal.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/paypal\",\...}"
}
]
"actions": [
{
"action": "setCustomField",
"name": "sctm_payment_methods_response",
"value": "{\"count\":11,\"methods\":[{\"resource\":\"method\",\"id\":\"applepay\",\"description\":\"Apple Pay\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"10000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/applepay.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/applepay%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/applepay.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/applepay\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"creditcard\",\"description\":\"Karte\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"10000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/creditcard%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/creditcard.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/creditcard\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"paypal\",\"description\":\"PayPal\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":null,\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/paypal.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/paypal%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/paypal.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/paypal\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"banktransfer\",\"description\":\"Überweisung\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"1000000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/banktransfer.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/banktransfer\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"ideal\",\"description\":\"iDEAL\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/ideal.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/ideal%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/ideal.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/ideal\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"bancontact\",\"description\":\"Bancontact\",\"minimumAmount\":{\"value\":\"0.02\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/bancontact.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/bancontact%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/bancontact.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/bancontact\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"eps\",\"description\":\"eps\",\"minimumAmount\":{\"value\":\"1.00\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/eps.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/eps%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/eps.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/eps\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"przelewy24\",\"description\":\"Przelewy24\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"12815.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/przelewy24.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/przelewy24\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"kbc\",\"description\":\"KBC/CBC Zahlungsbutton\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/kbc.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/kbc%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/kbc.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/kbc\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"belfius\",\"description\":\"Belfius Pay Button\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/belfius.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/belfius%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/belfius.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/belfius\",\"type\":\"application/hal+json\"}}},{\"resource\":\"method\",\"id\":\"bancomatpay\",\"description\":\"Bancomat Pay\",\"minimumAmount\":{\"value\":\"0.01\",\"currency\":\"EUR\"},\"maximumAmount\":{\"value\":\"50000.00\",\"currency\":\"EUR\"},\"image\":{\"size1x\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay.png\",\"size2x\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay%402x.png\",\"svg\":\"https://www.mollie.com/external/icons/payment-methods/bancomatpay.svg\"},\"status\":\"activated\",\"_links\":{\"self\":{\"href\":\"https://api.mollie.com/v2/methods/bancomatpay\",\"type\":\"application/hal+json\"}}}]}"
},
{
"action": "setCustomField",
"name": "sctm_mollie_profile_id",
"value": "pfl_SPkYGiEQjf"
}
]
}

```
4 changes: 4 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ v0.0.1
- PICT-201 - Add User-Agent for every requests to Mollie & CT
- PICT-195 - Get the list of available payment methods
- PICT-196 - Create Mollie Payment

v0.0.2

- Fix `start` command
1 change: 1 addition & 0 deletions processor/.env.jest
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ CTP_SCOPE=TEST
CTP_REGION=europe-west1.gcp
## MOLLIE vars
MOLLIE_API_KEY=12345678901234567890123456789012
MOLLIE_PROFILE_ID=pfl_12345
MOLLIE_DEBUG=1
Loading

0 comments on commit 6c198bd

Please sign in to comment.