Medusa tpay Payment Provider
This plugin is compatible with Medusa v2.4.0+.
This plugin provides Tpay payment integration for Medusa commerce platform.
npm install medusa-tpay# oryarn add medusa-tpay
Add the payment provider configuration to your :
modules: [// ... other modules ...{resolve: "@medusajs/medusa/payment",options: {providers: [{resolve: 'medusa-tpay/providers/tpay',options: {clientId: process.env.TPAY_CLIENT_ID,clientSecret: process.env.TPAY_CLIENT_SECRET,merchantId: process.env.TPAY_MERCHANT_ID,sandbox: process.env.TPAY_SANDBOX === 'true',returnUrl: process.env.TPAY_RETURN_URL,// By default, this should be your backend's base URL + /hooks/payment/tpay (e.g. https://example.com/hooks/payment/tpay)callbackUrl: process.env.TPAY_CALLBACK_URL || `${process.env.APP_BASE_URL}/hooks/payment/tpay`,title: "Payment for order", // OptionalrefundDescription: "Refund", // Optional},},],}}]
Once configured, Tpay will be available as a payment provider in your Medusa store. The plugin integrates seamlessly with Medusa's payment workflow to handle the complete payment lifecycle.
The following data is required from your checkout flow and needs to be provided in the call in order to create a tpay transaction:
const tpayData = {customer_name: string;email: string;}
When a customer selects Tpay as their payment method during checkout, the plugin creates a new transaction with Tpay and returns a payment URL.
Redirect: Redirect the customer to the provided Tpay payment URL to let them complete the payment on tpay's pay-by-link page.
Payment Processing: After completing or canceling the payment, the customer is redirected back to your store via the configured values.
Webhook Notification: Tpay sends a webhook notification to your configured endpoint to confirm the payment status. The plugin automatically validates and processes these webhooks.
Order Completion: Based on the webhook data, Medusa updates the payment and order status accordingly.
The webhook endpoint is automatically registered at . Ensure that:
Refunds can be processed through Medusa's admin panel or API. The plugin will:
You can customize the refund description using the option in the plugin configuration.