Configuration
In order to properly add this application in your project you have to complete its configuration as described in the following sections.
Payment Gateway Manager
In order to complete the configuration of the Payment Gateway Manager
you have to:
- set the
ENABLED_PROVIDERS
environment variable - add the required environment variables depending on the chosen payment provider
- on
Public Variables
section set the PROJECT_HOST variable as host of the current project
For further details on refer to the service's configuration documentation.
Put a valid URL in the PAYMENT_CALLBACK_URL environment variable.
Payment Front End
In order to complete the configuration of the Payment Front End
you have to set the following environment variables:
CSP_HEADER
: list of content security policy to includePROJECT_HOST
: host of the current projectVITE_POLLING_INTERVAL
: interval in ms between two calls during polling
Based on the payments method enabled you have to set other variables:
- Axerve
VITE_AXERVE_API_KEY
VITE_AXERVE_SHOPLOGIN
- Adyen
VITE_ADYEN_KEY
- Braintree
VITE_BRAINTREE_KEY
BRAINTREE_TOKENIZATION_KEY
- Google Pay
VITE_GOOGLE_MERCHANT_ID
VITE_GOOGLE_MERCHANT_NAME
- Apple Pay
- add the right certificate on
/usr/static/.well-known/apple-developer-merchantid-domain-association.txt
.
- add the right certificate on
Further personalization is available modifying its config-map.
Backend for Frontend
In order to complete the configuration of the Back End for Front End
you have to set the following environment variables:
PAYMENT_OK_REDIRECT_URL
: url to which to redirect the user following a successfully completed paymentPAYMENT_KO_REDIRECT_URL
: url to which to redirect the user following a failed paymentFLOW_MANAGER_URL
: flow manager service urlPGM_URL
: payment gateway manager urlINVOICE_SERVICE_URL
: invoice service urlFILES_SERVICE_URL
: file service urlSAGA_CRUD_URL
: saga collection urlINVOICE_CRUD_URL
: invoice collection urlCRUD_POLLING_INTERVAL_MS
: interval in ms between two calls during pollingCRUD_POLLING_ATTEMPTS_LIMIT
: maximum number of attempts during pollingAPPLEPAY_CERTIFICATE_PASSWORD
APPLEPAY_CERTIFICATE_FILE
Frullino
This service periodically retrieves from the crud the payments that are in the pending state, checks the actual status through the provider and updates the payment state accordingly (failed or executed).
The following environment variables are customizable:
PGM_URL
: payment gateway manager urlFLOW_MANAGER_URL
: flow manager service urlCRUD_SERVICE_URL
: crud service urlMIN_DATE_OFFSET_MS
andMAX_DATE_OFFSET_MS
: define the interval between payments have to be checked as:NOW - MAX_DATE_OFFSET_MS
< payment last update <NOW - MIN_DATE_OFFSET_MS
ENABLED_PROVIDERS
: the list of providers whose payments to checkREDIS_HOST
: Redis installation URLTHREAD_NUMBER
: the number of payments the service can check in parallelFRULLINO_RUNNING_INTERVAL_CRON
: how often the service performs the check
Others
For further configuration of the microservices you can refer to the dedicated documentation:
- Invoice-Service
- Flow-Manager-Service
- Files-Service
- SMTP Mail Notification Service
- Data-Visualization
- Analytics
View
The user could perform the additional steps reported below in order to create mongo views that enabled to use the ready to use backoffice pages related to payments.
- Setup aggregation of
fm_transactions_view
as follows.
create a new aggregation view on MongoDB Views section called
fm_transactions_view
choose
fm_transactions
as starting collectioncreate
fm_transactions_view
schema as the schema belowpaste the following pipeline and fields
Pipeline
[
{
"$match": {
"__STATE__": "PUBLIC"
}
},
{
"$lookup": {
"from": "fm_subscriptions",
"localField": "metadata.subscriptionId",
"foreignField": "sagaId",
"as": "subscriptions"
}
},
{
"$project": {
"__STATE__": "$__STATE__",
"createdAt": "$createdAt",
"updatedAt": "$updatedAt",
"creatorId": "$creatorId",
"updaterId": "$updaterId",
"sagaId": "$sagaId",
"amount": "$metadata.amount",
"currency": "$metadata.currency",
"paymentMethodId": "$metadata.paymentMethod",
"paymentMethod": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"applepay"
]
},
"then": "Apple Pay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"credit-cards"
]
},
"then": "Credit Card"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"googlepay"
]
},
"then": "Google Pay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"pay-pal"
]
},
"then": "PayPal"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"stripe"
]
},
"then": "Stripe"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"external"
]
},
"then": {
"$concat": [
"External - ",
"$metadata.provider"
]
}
}
],
"default": "$metadata.paymentMethod"
}
},
"providerId": "$metadata.provider",
"provider": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$metadata.provider",
"braintree"
]
},
"then": "Braintree"
},
{
"case": {
"$eq": [
"$metadata.provider",
"axerve"
]
},
"then": "Axerve"
},
{
"case": {
"$eq": [
"$metadata.provider",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$metadata.provider",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$metadata.provider",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$metadata.provider",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$metadata.provider",
"unicredit"
]
},
"then": "Unicredit"
},
{
"case": {
"$eq": [
"$metadata.provider",
"stripe"
]
},
"then": "Stripe"
}
],
"default": "$metadata.provider"
}
},
"currentStatus": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$businessStateDescription",
"PAYMENT_PAID"
]
},
"then": "Paid"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"PAYMENT_CREATED"
]
},
"then": "Created"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"PAYMENT_TOTALLY_REFUNDED"
]
},
"then": "Totally Refunded"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"PAYMENT_PARTIALLY_REFUNDED"
]
},
"then": "Partially Refunded"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"PAYMENT_FAILED"
]
},
"then": "Failed"
}
],
"default": "$businessStateDescription"
}
},
"buyerName": "$metadata.additionalData.buyer.name",
"buyerEmail": "$metadata.additionalData.buyer.email",
"channel": "$metadata.additionalData.channel",
"date": "$createdAt",
"history": {
"$reverseArray": {
"$function": {
"body": "function(history, refundedAmounts) { externalIndex = 0; return history.events.map((event, index) => { let refundedAmount = undefined; if (event.event === 'partialRefundExecuted' || event.event === 'totalRefundExecuted') { if (refundedAmounts !== null && externalIndex < refundedAmounts.length) { refundedAmount = refundedAmounts[externalIndex]; externalIndex++; } else { refundedAmount = null; } } let status; switch (history.states[index].businessStateDescription) { case 'PAYMENT_CREATED': status = 'Created'; break; case 'PAYMENT_PAID': status = 'Paid'; break; case 'PAYMENT_PARTIALLY_REFUNDED': status = 'Partially Refunded'; break; case 'PAYMENT_TOTALLY_REFUNDED': status = 'Totally Refunded'; break; case 'PAYMENT_FAILED': status = 'Failed'; break; default: status = history.states[index].businessStateDescription; } let eventName; switch (event.event) { case 'paymentCreated': eventName = 'Payment created'; break; case 'scheduleRequested': eventName = 'Payment schedule requested'; break; case 'paymentRedirected': eventName = 'Payment redirected'; break; case 'redirectionCompleted': eventName = 'Redirection completed'; break; case 'paymentScheduled': eventName = 'Payment scheduled'; break; case 'confirmRequested': eventName = 'Payment confirmation requested'; break; case 'confirmReceived': eventName = 'Payment confirmation received'; break; case 'paymentScheduleFailed': eventName = 'Payment schedule failed'; break; case 'redirectionFailed': eventName = 'Payment redirection failed'; break; case 'paymentExecutionFailed': eventName = 'Payment failed'; break; case 'paymentExecutionFailedFrullino': eventName = 'Payment failed by the system'; break; case 'paymentConfirmFailed': eventName = 'Payment confirmation failed'; break; case 'emailNotificationSent': eventName = 'Email notification sent'; break; case 'emailNotificationFailed': eventName = 'Email notification failed'; break; case 'emailNotificationRequested': eventName = 'Email notification requested'; break; case 'paymentExecuted': eventName = 'Payment executed'; break; case 'paymentExecutedFrullino': eventName = 'Payment executed by the system'; break; case 'refundRequested': eventName = 'Refund requested'; break; case 'refundFailed': eventName = 'Refund failed'; break; case 'partialRefundExecuted': eventName = 'Partial refund executed'; break; case 'totalRefundExecuted': eventName = 'Total refund executed'; break; case 'invoiceGenerated': eventName = 'Invoice generated'; break; case 'invoiceGenerationFailed': eventName = 'Invoice generation failed'; break; default: eventName = event.event; } return { date: event.timestamp, event: eventName, status, refundedAmount }; });}",
"args": [
"$history",
"$metadata.refundDetails.refundedAmounts"
],
"lang": "js"
}
}
},
"shopTransactionId": "$metadata.shopTransactionId",
"paymentID": "$metadata.paymentID",
"totalRefundedAmount": {
"$ifNull": [
"$metadata.refundDetails.totalRefundedAmount",
"0"
]
},
"remainingAmount": {
"$subtract": [
"$metadata.amount",
{
"$ifNull": [
"$metadata.refundDetails.totalRefundedAmount",
0
]
}
]
},
"type": "$metadata.type",
"subscriptionId": {
"$first": "$subscriptions"
}
}
},
{
"$set": {
"subscriptionId": "$subscriptionId._id",
"amount": {
"$divide": [
{
"$toDouble": "$amount"
},
100
]
},
"totalRefundedAmount": {
"$divide": [
{
"$toDouble": "$totalRefundedAmount"
},
100
]
},
"remainingAmount": {
"$divide": [
{
"$toDouble": "$remainingAmount"
},
100
]
},
"history": {
"$map": {
"input": "$history",
"in": {
"date": "$$this.date",
"event": "$$this.event",
"status": "$$this.status",
"refundedAmount": {
"$divide": [
{
"$toDouble": "$$this.refundedAmount"
},
100
]
}
}
}
}
}
}
]Fields
[
{
"name": "_id",
"description": "_id",
"type": "ObjectId",
"required": true,
"nullable": false
},
{
"name": "creatorId",
"description": "creatorId",
"type": "string",
"required": true,
"nullable": false
},
{
"name": "createdAt",
"description": "createdAt",
"type": "Date",
"required": true,
"nullable": false
},
{
"name": "updaterId",
"description": "updaterId",
"type": "string",
"required": true,
"nullable": false
},
{
"name": "updatedAt",
"description": "updatedAt",
"type": "Date",
"required": true,
"nullable": false
},
{
"name": "__STATE__",
"description": "__STATE__",
"type": "string",
"required": true,
"nullable": false
},
{
"name": "amount",
"type": "number",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "paymentMethodId",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "paymentMethod",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "providerId",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "provider",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "currentStatus",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "buyerName",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "buyerEmail",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "channel",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "date",
"type": "Date",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "history",
"type": "Array_RawObject",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "shopTransactionID",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "paymentID",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "sagaId",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "totalRefundedAmount",
"type": "number",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "remainingAmount",
"type": "number",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "currency",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "shopTransactionId",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "subscriptionId",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
},
{
"name": "type",
"type": "string",
"required": false,
"nullable": false,
"sensitivityValue": 0
}
]
- Create endpoint for the mongoDB view previously created
transactions_saga_view
- Create a new endpoint on the endpoint section
/transactions-saga-view
- Choose mongoDB view as type
- Choose Mongo view base path as
/transactions-saga-view
- Setup aggregation of
subscriptions_view
as follows.
create a new aggregation view on MongoDB Views section called
subscriptions_view
choose
fm_subscriptions
as starting collectioncreate
subscriptions_view
schema as the schema belowpaste the following pipeline and fields
Pipeline
[
{
"$match": {
"__STATE__": "PUBLIC"
}
},
{
"$lookup": {
"from": "fm_transactions",
"localField": "metadata.transactions",
"foreignField": "sagaId",
"as": "transactionsData"
}
},
{
"$project": {
"__STATE__": "$__STATE__",
"createdAt": "$createdAt",
"updatedAt": "$updatedAt",
"creatorId": "$creatorId",
"updaterId": "$updaterId",
"sagaId": "$sagaId",
"amount": "$metadata.amount",
"currency": "$metadata.currency",
"providerId": "$metadata.provider",
"paymentMethod": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"applepay"
]
},
"then": "Apple Pay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"credit-cards"
]
},
"then": "Credit Card"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"googlepay"
]
},
"then": "Google Pay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"pay-pal"
]
},
"then": "PayPal"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"stripe"
]
},
"then": "Stripe"
},
{
"case": {
"$eq": [
"$metadata.paymentMethod",
"external"
]
},
"then": {
"$concat": [
"External - ",
"$metadata.provider"
]
}
}
],
"default": "$metadata.paymentMethod"
}
},
"provider": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$metadata.provider",
"braintree"
]
},
"then": "Braintree"
},
{
"case": {
"$eq": [
"$metadata.provider",
"axerve"
]
},
"then": "Axerve"
},
{
"case": {
"$eq": [
"$metadata.provider",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$metadata.provider",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$metadata.provider",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$metadata.provider",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$metadata.provider",
"unicredit"
]
},
"then": "Unicredit"
},
{
"case": {
"$eq": [
"$metadata.provider",
"stripe"
]
},
"then": "Stripe"
}
],
"default": "$metadata.provider"
}
},
"status": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$businessStateDescription",
"CREATED"
]
},
"then": "created"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"ACTIVE"
]
},
"then": "active"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"EXPIRED"
]
},
"then": "not active"
},
{
"case": {
"$eq": [
"$businessStateDescription",
"ABORTED"
]
},
"then": "not active"
}
],
"default": "$businessStateDescription"
}
},
"shopSubscriptionId": "$metadata.shopSubscriptionId",
"interval": "$metadata.interval",
"intervalCount": "$metadata.intervalCount",
"nextPaymentDate": "$metadata.nextPaymentDate",
"expirationDate": "$metadata.expirationDate",
"additionalData": "$metadata.additionalData",
"transactions": "$transactionsData",
"expireRequested": "$metadata.expireRequested"
}
},
{
"$set": {
"amount": {
"$divide": [
{
"$toDouble": "$amount"
},
100
]
},
"transactions": {
"$map": {
"input": "$transactions",
"in": {
"date": "$$this.createdAt",
"_id": "$$this._id",
"shopTransactionId": "$$this.metadata.shopTransactionId",
"amount": {
"$divide": [
{
"$toDouble": "$$this.metadata.amount"
},
100
]
},
"status": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$$this.businessStateDescription",
"PAYMENT_PAID"
]
},
"then": "Paid"
},
{
"case": {
"$eq": [
"$$this.businessStateDescription",
"PAYMENT_CREATED"
]
},
"then": "Created"
},
{
"case": {
"$eq": [
"$$this.businessStateDescription",
"PAYMENT_TOTALLY_REFUNDED"
]
},
"then": "Totally Refunded"
},
{
"case": {
"$eq": [
"$$this.businessStateDescription",
"PAYMENT_PARTIALLY_REFUNDED"
]
},
"then": "Partially Refunded"
},
{
"case": {
"$eq": [
"$$this.businessStateDescription",
"PAYMENT_FAILED"
]
},
"then": "Failed"
}
],
"default": "$businessStateDescription"
}
}
}
}
}
}
}
]Fields
[
{
"name":"_id",
"description":"_id",
"type":"ObjectId",
"required":true,
"nullable":false
},
{
"name":"creatorId",
"description":"creatorId",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"createdAt",
"description":"createdAt",
"type":"Date",
"required":true,
"nullable":false
},
{
"name":"updaterId",
"description":"updaterId",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"updatedAt",
"description":"updatedAt",
"type":"Date",
"required":true,
"nullable":false
},
{
"name":"__STATE__",
"description":"__STATE__",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"shopSubscriptionId",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"transactions",
"type":"Array_RawObject",
"required":false,
"nullable":false,
"sensitivityValue":0,
"schema":{
"properties":{
"transactionId":{
"type":"string"
},
"date":{
"type":"string"
},
"status":{
"type":"string"
}
}
}
},
{
"name":"amount",
"type":"number",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"currency",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"interval",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"intervalCount",
"type":"number",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"nextPaymentDate",
"type":"Date",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"status",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"provider",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"paymentMethod",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"sagaId",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"expirationDate",
"type":"Date",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"providerId",
"type":"string",
"required":false,
"nullable":false,
"sensitivityValue":0
},
{
"name":"expireRequested",
"type":"boolean",
"required":false,
"nullable":true,
"sensitivityValue":0
}
]
- Create endpoint for the mongoDB view previously created
subscriptions_view
- Create a new endpoint on the endpoint section
/subscriptions-view
- Choose mongoDB view as type
- Choose Mongo view base path as
/subscriptions-view
- Setup aggregation of
adaptive_checkout_view
as follows.
create a new aggregation view on MongoDB Views section called
adaptive_checkout_view
choose
adaptive_checkout
as starting collectioncreate
adaptive_checkout_view
schema as the schema belowpaste the following pipeline and fields
Pipeline
[
{
"$match": {
"__STATE__": "PUBLIC"
}
},
{
"$project": {
"__STATE__": "$__STATE__",
"createdAt": "$createdAt",
"updatedAt": "$updatedAt",
"creatorId": "$creatorId",
"updaterId": "$updaterId",
"priority": "$priority",
"ruleId": "$ruleId",
"amount": "$amount",
"enabledMethods": {
"$map": {
"input": "$enabledMethods",
"as": "m",
"in": {
"paymentMethod": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$$m.paymentMethod",
"applepay"
]
},
"then": "Apple Pay"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"credit-cards"
]
},
"then": "Credit Card"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"googlepay"
]
},
"then": "Google Pay"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"pay-pal"
]
},
"then": "PayPal"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$$m.paymentMethod",
"stripe"
]
},
"then": "Stripe"
}
],
"default": "$$m.paymentMethod"
}
},
"provider": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$$m.provider",
"adyen"
]
},
"then": "Adyen"
},
{
"case": {
"$eq": [
"$$m.provider",
"braintree"
]
},
"then": "Braintree"
},
{
"case": {
"$eq": [
"$$m.provider",
"axerve"
]
},
"then": "Axerve"
},
{
"case": {
"$eq": [
"$$m.provider",
"safecharge"
]
},
"then": "SafeCharge"
},
{
"case": {
"$eq": [
"$$m.provider",
"satispay"
]
},
"then": "Satispay"
},
{
"case": {
"$eq": [
"$$m.provider",
"scalapay"
]
},
"then": "Scalapay"
},
{
"case": {
"$eq": [
"$$m.provider",
"soisy"
]
},
"then": "Soisy"
},
{
"case": {
"$eq": [
"$$m.provider",
"unicredit"
]
},
"then": "Unicredit"
},
{
"case": {
"$eq": [
"$$m.provider",
"stripe"
]
},
"then": "Stripe"
}
],
"default": "$$m.provider"
}
},
"index": {
"$indexOfArray": [
"$enabledMethods",
"$$m"
]
}
}
}
},
"matchInValues": {
"$map": {
"input": "$matchInValues",
"as": "miv",
"in": {
"key": {
"$switch": {
"branches": [
{
"case": {
"$eq": [
"$$miv.key",
"metadata.additionalData.productsCategory"
]
},
"then": "Product Category"
},
{
"case": {
"$eq": [
"$$miv.key",
"metadata.additionalData.channel"
]
},
"then": "Channel"
},
{
"case": {
"$eq": [
"$$miv.key",
"metadata.buyer.type"
]
},
"then": "User Type"
}
],
"default": "$$miv.key"
}
},
"values": {
"$reduce": {
"input": "$$miv.values",
"initialValue": "",
"in": {
"$cond": {
"if": {
"$eq": [
"$$value",
""
]
},
"then": {
"$concat": [
"$$value",
"$$this"
]
},
"else": {
"$concat": [
"$$value",
",",
"$$this"
]
}
}
}
}
},
"index": {
"$indexOfArray": [
"$matchInValues",
"$$miv"
]
}
}
}
}
}
},
{
"$set": {
"amount": {
"min": {
"$divide": [
{
"$toDouble": "$amount.min"
},
100
]
},
"max": {
"$divide": [
{
"$toDouble": "$amount.max"
},
100
]
}
}
}
}
]Fields
[
{
"name":"_id",
"description":"_id",
"type":"ObjectId",
"required":true,
"nullable":false
},
{
"name":"creatorId",
"description":"creatorId",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"createdAt",
"description":"createdAt",
"type":"Date",
"required":true,
"nullable":false
},
{
"name":"updaterId",
"description":"updaterId",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"updatedAt",
"description":"updatedAt",
"type":"Date",
"required":true,
"nullable":false
},
{
"name":"__STATE__",
"description":"__STATE__",
"type":"string",
"required":true,
"nullable":false
},
{
"name":"priority",
"type":"number",
"required":true,
"nullable":false,
"sensitivityValue":0
},
{
"name":"amount",
"type":"RawObject",
"required":false,
"nullable":true,
"sensitivityValue":0
},
{
"name":"enabledMethods",
"type":"Array_RawObject",
"required":false,
"nullable":true,
"sensitivityValue":0
},
{
"name":"matchInValues",
"type":"Array_RawObject",
"required":false,
"nullable":true,
"sensitivityValue":0
},
{
"name":"ruleId",
"type":"string",
"required":true,
"nullable":false,
"sensitivityValue":0
}
]
- Create endpoint for the mongoDB view previously created
adaptive-checkout-view
- Create a new endpoint on the endpoint section
/adaptive-checkout-view
- Choose mongoDB view as type
- Choose Mongo view base path as
/adaptive-checkout-view