MyTPEMyTPE Pay

Integration Guide

The complete architectural journey for integrating MyTPE Pay into any ERP or CMS.

MyTPE Pay Integration Guide

This guide explains the architecture for integrating MyTPE Pay into external systems (Odoo, WordPress, WooCommerce, Shopify, or any custom solution).

What You'll Achieve

By following this guide, your system will be able to:

  • Automate Links: Automatically create payment links when orders are confirmed.
  • Sync Instances: Map your physical/digital stores to MyTPE Instances.
  • Display Payment URLs: Present the generated payment_link to customers for checkout.
  • Real-time Status: Update order statuses (PendingPaid) instantly via Webhooks.
  • Inventory Management: Handle limited stock automatically using limited payment modes.

Key Concept: ID Mapping

The most critical part of this integration is ID Mapping. You must store MyTPE Pay IDs alongside your local database records. This creates a bridge between your ERP/CMS and our banking gateway.


Integration Journey

Here is the complete journey from authentication to live payment processing.


Data Mapping Strategy

1. The Hierarchy

You need to replicate or map to our 3-level hierarchy to ensure your reports match our bank settlements.

Complete Integration Flow

Scenario: E-commerce Order

This sequence diagram details the logical flow between your server and the MyTPE API.


REQUIRED: Display payment_link to Customer

After creating a payment link via the API, you must display the payment_link URL to the customer. This is the checkout URL where they will complete their payment.

Ways to display the payment link:

  • Direct Link: Show a "Pay Now" button that redirects to payment_link
  • QR Code: Generate a QR code from the payment_link URL for mobile payments
  • Email/SMS: Send the payment_link via email or SMS
  • Embedded: Display in your order confirmation page

Example API Response:

{
  "data": {
    "id": "paylink_new456",
    "payment_link": "https://frontdev.mytpe.app/pay/limited-offer",
    ...
  }
}

You must use: https://frontdev.mytpe.app/pay/limited-offer


Integration Scenarios

1. WordPress / WooCommerce

If you are building a plugin:

  1. Settings Page: Add a field to input API Key/Secret.
  2. Instance Select: Add a dropdown to select which "MyTPE Instance" corresponds to this WooCommerce store.
  3. Checkout Logic:
    • Link Type: Use dynamic for fixed-price products, static for donations/custom amounts
    • Payment Mode: Use one_shot for standard checkout
    • Link Storage: Store link_id in wp_postmeta for the Order
    • Slug: Use wc_order_{id} for the link slug
    • Display: Add a "Complete Payment" button on the order confirmation page that links to payment_link

Example Button:

<a href="<?php echo $payment_link; ?>" class="button">
  Complete Payment
</a>

2. Odoo ERP

If you are building an Odoo module:

  1. Company Settings: Add mytpe_instance_id to the res.company model.
  2. Invoicing: When creating an invoice, generate a Link with type one_shot.
  3. Matching: Store the link_id in a custom field x_mytpe_link_id.
  4. Display: Add the payment_link to the invoice email template
  5. Reconciliation: The webhook should trigger an account.payment registration.

Example Email Template:

<p>
  <a href="${object.x_mytpe_payment_link}"
     style="background: #007bff; color: white; padding: 10px 20px;">
    Pay Invoice Online
  </a>
</p>

3. Multi-Tenant SaaS

If you run a platform (e.g., a food delivery app) with many merchants:

  1. Mapping: Each Merchant in your DB needs their own mytpe_instance_id.
  2. Link Generation: When a customer orders, create a payment link using the merchant's instance ID
  3. Display: Show the payment_link in the order summary
  4. Routing: When a webhook arrives, use the link_id to determine which merchant's order this belongs to.

Understanding when to use each type and mode is crucial:

Payment Modes Apply to Dynamic Links

Static links (customer-entered amounts) are always reusable. Payment modes only apply to dynamic (fixed-price) links.

ModeUse CaseBehavior
reusableE-commerce product pageLink never expires, accepts unlimited payments
one_shotInvoice paymentCloses after exactly 1 successful payment
limitedEvent tickets (e.g., max 50)Closes after max_payments successful payments

Best Practices

3. Error Handling Strategy

4. Webhook Security


Quick Integration Checklist

  • Authentication: Login & store keys securely.
  • Mapping: Map mytpe_instance_id to your Store/Company.
  • Creation: Generate links using POST /links/store and save the link_id.
  • Display: Show the payment_link URL to customers via button/QR/email.
  • Webhooks: Verify signatures and update orders using link_id.
  • Testing: Test with one_shot mode first to ensure auto-closing works.

Common Pitfalls to Avoid

Don't Make These Mistakes

  1. Not storing link_id: You won't be able to match webhook events to orders
  2. Not displaying payment_link: Customers can't pay without the checkout URL
  3. Confusing type and mode: Remember static = customer enters amount, dynamic = fixed price
  4. Fulfilling on pending status: Only fulfill when status is completed
  5. Not encrypting API credentials: Store keys securely in environment variables

Testing Your Integration

Create a test payment link and verify:

  • link_id is stored in your database
  • payment_link URL is displayed to user
  • Link opens successfully in browser

Test Payment Flow

Use test cards to complete a payment:

  • Customer clicks payment_link
  • Payment completes successfully
  • Webhook is received

Test Webhook Handling

Verify your webhook handler:

  • Matches link_id to correct order
  • Updates order status only on completed
  • Handles duplicate webhooks gracefully

Test Error Cases

  • Invalid API credentials
  • Network timeout during link creation
  • Customer cancels payment
  • Failed payment (insufficient funds)

On this page