Skip to main content
Version: 13.x (Current)

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:

  1. set the ENABLED_PROVIDERS environment variable
  2. add the required environment variables depending on the chosen payment provider
  3. 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.

danger

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 include
  • PROJECT_HOST: host of the current project, as Public variable
  • VITE_DEMO_API_KEY: api key used to protect PGM BFF service

Based on the payment methods or providers enabled you have to set specific variables:

  • Axerve
    • VITE_AXERVE_API_KEY
    • VITE_AXERVE_SHOPLOGIN
  • Adyen
    • VITE_ADYEN_KEY
  • Braintree
    • VITE_BRAINTREE_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. More info on the official documentation.

Further personalization is available modifying its ConfigMap, that has the schema below:

{
"primaryColor": "color used for primary element",
"backgroundColor": "color used for background",
"bodyColor": "color used for the pages' body",
"fontColor": "color used for the fonts",
"logo": "path to the logo image",
"favicon": "path to the favicon image",
"title": "title of the website",
// path of the Frontend pages
"pages": {
"home": "/demo/checkout",
"checkout": "/demo/checkout",
"subscription": "/demo/subscription",
"buyer": "/demo/buyer",
"pay": "/demo/pay",
"result": "/demo/result",
"error": "/demo/error",
"pending": "/demo/pending"
},
// endpoint that Frontend should call to perform actions
"endpoint": {
"pay": "/pay",
"paySubscription": "/pay-recurrent",
"payPolling": "/pay-polling",
"payByLink": "/pay-by-link",
"downloadInvoice": "/invoice-download",
"checkout": "/fm/saga",
"checkoutSubscription": "/create",
"paymentDetail": "/payment-info",
"paymentMethods": "/payment/{id}/methods",
"axerveCreditToken": "https://sandbox.gestpay.net/api/v1/shop/token",
"applePaySession": "/apple-pay-session",
"paymentTokenization": "/tokenization"
},
"googlepay": {
"environment": "TEST or PRODUCTION",
"countryCode": "ISO 3166-1 alpha-2 country code for the country where the transaction will be completed/processed"
},
"applePay": {
"merchantIdentifier": "unique identify for the merchant",
"domain": "URL where the project is hosted",
"displayName": "name to display to the user"
},
"pollingInterval": "interval in ms between two calls during polling"
}

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 payment
  • PAYMENT_KO_REDIRECT_URL: url to which to redirect the user following a failed payment
  • PAYMENT_PENDING_REDIRECT_URL: url to which to redirect the user following a pending payment
  • FLOW_MANAGER_URL: flow manager service url
  • PGM_URL: payment gateway manager url
  • INVOICE_SERVICE_URL: invoice service url
  • FILES_SERVICE_URL: file service url
  • SUBSCRIPTION_HANDLER_SERVICE: subscription handler service url
  • ADAPTIVE_CHECKOUT_URL: adaptive approval service url
  • SAGA_CRUD_URL: transaction saga collection url
  • INVOICE_CRUD_URL: invoice collection url
  • USERS_CRUD_URL: users collection url
  • SAGA_SUBSCRIPTION_CRUD_URL: subscription saga collection url
  • PAY_BY_LINK_PROVIDER: enabled provider for PAY_BY_LINK payments
  • APPLEPAY_CERTIFICATE_PASSWORD
  • APPLEPAY_CERTIFICATE_FILE: read the official documentation to learn how to create it

Frullino

This service periodically retrieves payments from crud, 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 url
  • FLOW_MANAGER_URL: flow manager service url
  • CRUD_SERVICE_URL: crud service view url. In order to perform custom query (e.g. if payment is in a specific state or if it is made with a subset of providers), you have to update the related MongoDB View
  • REDIS_HOST: Redis installation URL
  • THREAD_NUMBER: the number of payments the service can check in parallel
  • FRULLINO_RUNNING_INTERVAL_CRON: how often the service performs the check

Others

For further configuration of the microservices you can refer to the dedicated documentation:

MongoDB Views

The user should perform the additional steps reported below in order to create MongoDB views that enable to exploit the ready to use backoffice pages related to payments.

  1. 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 collection
    • create fm_transactions_view schema as the schema below
    • paste 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",
    "wire-transfer"
    ]
    },
    "then": "Wire Transfer"
    },
    {
    "case": {
    "$eq": [
    "$metadata.paymentMethod",
    "external"
    ]
    },
    "then": {
    "$concat": [
    "External - ",
    "$metadata.provider"
    ]
    }
    }
    ],
    "default": "$metadata.paymentMethod"
    }
    },
    "provider": "$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",
    "buyerPhone": "$metadata.additionalData.buyer.phone",
    "notificationChannels": "$metadata.additionalData.notificationChannels",
    "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": "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": "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": true,
    "sensitivityValue": 0
    },
    {
    "name": "type",
    "type": "string",
    "required": false,
    "nullable": false,
    "sensitivityValue": 0
    },
    {
    "name": "buyerPhone",
    "type": "string",
    "required": false,
    "nullable": false,
    "sensitivityValue": 0
    },
    {
    "name": "notificationChannels",
    "type": "Array_string",
    "required": false,
    "nullable": false,
    "sensitivityValue": 0
    },
    {
    "name": "paymentId",
    "type": "string",
    "required": false,
    "nullable": false,
    "sensitivityValue": 0
    }
    ]
  2. Create endpoint for the MongoDB view previously created fm_transactions_view

    • Create a new endpoint on the endpoint section /fm-transactions-view
    • Choose MongoDB view as type
    • Choose MongoDB view base path as /fm-transactions-view
  3. Setup aggregation of subscriptions_view as follows.

    • create a new aggregation view on MongoDB Views section called subscriptions_view
    • choose fm_subscriptions as starting collection
    • create subscriptions_view schema as the schema below
    • paste 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",
    "provider": "$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"
    }
    },
    "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": "expireRequested",
    "type": "boolean",
    "required": false,
    "nullable": true,
    "sensitivityValue": 0
    }
    ]
  4. 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 MongoDB view base path as /subscriptions-view
  5. Setup aggregation of payment_pending_view as follows.

    • create a new aggregation view on MongoDB Views section called payment_pending_view
    • choose fm_transactions as starting collection
    • create payment_pending_view schema as the schema below
    • paste the following pipeline and fields
    Pipeline
    [
    {
    "$match": {
    "__STATE__": "PUBLIC",
    "metadata.provider": {
    "$in": [
    "axerve",
    "braintree",
    "satispay",
    "scalapay",
    "soisy",
    "stripe"
    ]
    },
    "currentState": {
    "$in": [
    "PAYMENT_PENDING"
    ]
    },
    "$expr": {
    "$and": [
    {
    "$gte": [
    "$updatedAt",
    {
    "$dateSubtract": {
    "startDate": "$$NOW",
    "unit": "second",
    "amount": 86400
    }
    }
    ]
    },
    {
    "$lte": [
    "$updatedAt",
    {
    "$dateSubtract": {
    "startDate": "$$NOW",
    "unit": "second",
    "amount": 60
    }
    }
    ]
    }
    ]
    }
    }
    }
    ]
    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": "sagaId",
    "description": "",
    "type": "string",
    "required": true,
    "nullable": false
    },
    {
    "name": "metadata",
    "type": "RawObject",
    "required": true,
    "nullable": false,
    "sensitivityValue": 0,
    "encryptionEnabled": false,
    "encryptionSearchable": false,
    "schema": {
    "properties": {
    "shopTransactionID": {
    "type": "string"
    },
    "amount": {
    "type": "number"
    },
    "currency": {
    "type": "string"
    },
    "paymentMethod": {
    "type": "string"
    },
    "provider": {
    "type": "string"
    },
    "isRecurrent": {
    "type": "boolean"
    },
    "recurrenceDetails": {
    "type": "object"
    },
    "subscriptionId": {
    "type": "string"
    },
    "buyer": {
    "type": "object"
    },
    "providerData": {
    "type": "object"
    },
    "paymentID": {
    "type": "string"
    },
    "sessionToken": {
    "type": "string"
    },
    "paymentToken": {
    "type": "string"
    },
    "additionalData": {
    "type": "object",
    "properties": {
    "channel": {
    "type": "string"
    },
    "items": {
    "type": "array",
    "items": {
    "type": "object",
    "properties": {
    "itemId": {
    "type": "string"
    },
    "description": {
    "type": "string"
    },
    "amount": {
    "type": "number"
    },
    "quantity": {
    "type": "number"
    }
    }
    }
    }
    }
    },
    "refundDetails": {
    "type": "object"
    },
    "payRequestData": {
    "type": "object"
    },
    "refundRequestData": {
    "type": "object"
    }
    }
    }
    },
    {
    "name": "isFinal",
    "description": "",
    "type": "boolean",
    "required": true,
    "nullable": false
    },
    {
    "name": "currentState",
    "description": "",
    "type": "string",
    "required": true,
    "nullable": false
    },
    {
    "name": "latestEvent",
    "description": "",
    "type": "RawObject",
    "required": true,
    "nullable": false
    },
    {
    "name": "associatedEntityId",
    "description": "",
    "type": "string",
    "required": true,
    "nullable": false
    },
    {
    "name": "events",
    "description": "",
    "type": "Array_string",
    "required": false,
    "nullable": false
    },
    {
    "name": "history",
    "description": "",
    "type": "RawObject",
    "required": false,
    "nullable": false
    },
    {
    "name": "businessStateId",
    "description": "",
    "type": "string",
    "required": true,
    "nullable": false
    },
    {
    "name": "businessStateDescription",
    "description": "",
    "type": "string",
    "required": false,
    "nullable": false
    }
    ]
note

There is no reason to expose the payment_pending_view with an endpoint because it is used by a BackEnd service.