Payment Gateway Integration
Relevant source files
The following files were used as context for generating this wiki page:
- packages/common/src/entities/PaymentGateway.ts
- packages/admin-web-angular/src/app/@shared/payment-gateways/stripe-gateway/stripe-gateway.component.ts
- packages/admin-web-angular/src/app/@shared/payment-gateways/payPal-gateway/payPal-gateway.component.ts
- packages/admin-web-angular/src/app/@shared/payment-gateways/payment-gateways.module.ts
- packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/payments.ts
- packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/mutation/mutation.ts
- packages/admin-web-angular/src/app/pages/+setup/+merchants/components/payments/payments.component.ts
- README.md
The Ever Demand platform provides a modular system for integrating various payment gateways, allowing merchants to accept online payments. The system is designed to be extensible, with specific gateways like Stripe and PayPal implemented as distinct components. Merchants can configure and manage their preferred payment methods through dedicated interfaces in the admin and merchant applications.
Configuration for payment gateways is stored on a per-warehouse basis, enabling multi-store or multi-vendor setups where each merchant can have their own payment settings. The frontend applications provide forms for merchants to securely input their gateway credentials and settings, such as API keys and supported currencies.
Sources: README.md:43-43, packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/payments.ts:22-25
Core Data Model
The foundation of the payment gateway integration is defined in the @ever-platform/common package, ensuring a consistent data structure across the platform.
PaymentGateway Entity
The PaymentGateway class defines the structure for a configured payment gateway. It is associated with a Warehouse and contains the specific gateway type and its configuration object.
This diagram shows that a Warehouse entity can have multiple PaymentGateway configurations.
Sources: packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/payments.ts:22-25, packages/common/src/entities/PaymentGateway.ts:11-23
The IPaymentGatewayCreateObject interface specifies the data required to create a new payment gateway configuration.
| Property | Type | Description |
|---|---|---|
paymentGateway | PaymentGateways | The enum identifier for the specific gateway (e.g., Stripe, PayPal). |
configureObject | object | A JSON object containing the specific settings for the gateway (API keys, etc.). |
isDefault | boolean | (Optional) Whether this is the default payment method. |
Sources: packages/common/src/entities/PaymentGateway.ts:4-8
PaymentGateways Enum
The PaymentGateways enum provides a standardized list of supported payment providers. Helper functions are available to get the string name and logo path for each gateway.
| Enum Value | String Name |
|---|---|
| 0 | Stripe |
| 1 | PayPal |
Sources: packages/common/src/entities/PaymentGateway.ts:25-29, packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/payments.ts:47-51
Frontend Architecture
Payment gateway configuration is managed through Angular components in both the admin-web-angular and merchant-tablet-ionic applications.
Angular Module Structure
In the admin-web-angular app, the PaymentGatewaysModule encapsulates the functionality. It declares and exports the main PaymentGatewaysComponent, which acts as a container for individual gateway components like StripeGatewayComponent and PayPalGatewayComponent.
This diagram illustrates the composition of the PaymentGatewaysModule and its usage by other modules.
Sources: packages/admin-web-angular/src/app/@shared/payment-gateways/payment-gateways.module.ts:18-24, packages/admin-web-angular/src/app/pages/+setup/+merchants/components/payments/payments.module.ts:14-14
Merchant Configuration Flow
In the merchant-tablet-ionic application, a merchant can add, update, or remove payment gateways from their warehouse settings. The process involves opening a modal (PaymentMutationComponent) to edit the details of a specific gateway.
The following sequence diagram shows the flow for updating a payment gateway configuration.
This flow demonstrates how the UI components interact to provide a seamless editing experience for the merchant.
Sources: packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/payments.ts:53-85, packages/merchant-tablet-ionic/src/components/settings-page-components/settings/payments/mutation/mutation.ts:38-40
Configuration Details
Each payment gateway has a dedicated Angular component with a form for its specific configuration fields.
PayPal Gateway Configuration
The PayPalGatewayComponent provides a form for configuring PayPal payments.
| Field | UI Control | configModel Property | Required | Description |
|---|---|---|---|---|
| Mode | select | mode | Yes | The PayPal mode (live or sandbox). |
| Currency | select | currency | Yes | The currency code (e.g., USD, EUR). |
| Publishable Key | input | publishableKey | Yes | The public API key from PayPal. |
| Secret Key | input | secretKey | Yes | The secret API key from PayPal. |
| Payment Description | input | description | Yes | A description for the payment. |
Sources: packages/admin-web-angular/src/app/@shared/payment-gateways/payPal-gateway/payPal-gateway.component.html:7-154, packages/admin-web-angular/src/app/@shared/payment-gateways/payPal-gateway/payPal-gateway.component.ts:24-29
Stripe Gateway Configuration
The StripeGatewayComponent handles the configuration for Stripe.
| Field | UI Control | configModel Property | Required | Description |
|---|---|---|---|---|
| Currency | select | currency | Yes | The currency code (e.g., USD, EUR). |
| Publishable Key | input | publishableKey | Yes | The public API key from Stripe. |
| Secret Key | input | secretKey | Yes | The secret API key from Stripe. |
| Payment Description | input | description | Yes | A description for the payment. |
| Company Brand Logo | input | companyBrandLogo | No | URL for the company logo to show on checkout. |
Summary
The payment gateway integration in Ever Demand is a well-structured and modular system. It leverages a common data model for consistency and uses dedicated Angular components to handle the unique configuration requirements of each payment provider. This approach allows merchants to easily and securely manage how they receive online payments for their stores, with clear separation between different gateways like Stripe and PayPal. The system is integrated into both the main admin panel and the merchant-specific tablet application, providing flexible management options.