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_linkto customers for checkout. - Real-time Status: Update order statuses (
Pending→Paid) instantly via Webhooks. - Inventory Management: Handle limited stock automatically using
limitedpayment 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.
Critical: Displaying the Payment Link
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_linkURL for mobile payments - Email/SMS: Send the
payment_linkvia 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:
- Settings Page: Add a field to input API Key/Secret.
- Instance Select: Add a dropdown to select which "MyTPE Instance" corresponds to this WooCommerce store.
- Checkout Logic:
- Link Type: Use
dynamicfor fixed-price products,staticfor donations/custom amounts - Payment Mode: Use
one_shotfor standard checkout - Link Storage: Store
link_idinwp_postmetafor 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
- Link Type: Use
Example Button:
<a href="<?php echo $payment_link; ?>" class="button">
Complete Payment
</a>2. Odoo ERP
If you are building an Odoo module:
- Company Settings: Add
mytpe_instance_idto theres.companymodel. - Invoicing: When creating an invoice, generate a Link with type
one_shot. - Matching: Store the
link_idin a custom fieldx_mytpe_link_id. - Display: Add the
payment_linkto the invoice email template - Reconciliation: The webhook should trigger an
account.paymentregistration.
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:
- Mapping: Each Merchant in your DB needs their own
mytpe_instance_id. - Link Generation: When a customer orders, create a payment link using the merchant's instance ID
- Display: Show the
payment_linkin the order summary - Routing: When a webhook arrives, use the
link_idto determine which merchant's order this belongs to.
Payment Link Types & Modes
Understanding when to use each type and mode is crucial:
Link Types
Payment Modes (Dynamic Links Only)
Payment Modes Apply to Dynamic Links
Static links (customer-entered amounts) are always reusable. Payment modes only apply to dynamic (fixed-price) links.
| Mode | Use Case | Behavior |
|---|---|---|
reusable | E-commerce product page | Link never expires, accepts unlimited payments |
one_shot | Invoice payment | Closes after exactly 1 successful payment |
limited | Event tickets (e.g., max 50) | Closes after max_payments successful payments |
Best Practices
1. Always Store the Link ID
2. Always Display the payment_link
3. Error Handling Strategy
4. Webhook Security
Quick Integration Checklist
- Authentication: Login & store keys securely.
- Mapping: Map
mytpe_instance_idto your Store/Company. - Creation: Generate links using
POST /links/storeand save thelink_id. - Display: Show the
payment_linkURL to customers via button/QR/email. - Webhooks: Verify signatures and update orders using
link_id. - Testing: Test with
one_shotmode first to ensure auto-closing works.
Common Pitfalls to Avoid
Don't Make These Mistakes
- Not storing
link_id: You won't be able to match webhook events to orders - Not displaying
payment_link: Customers can't pay without the checkout URL - Confusing type and mode: Remember
static= customer enters amount,dynamic= fixed price - Fulfilling on
pendingstatus: Only fulfill when status iscompleted - Not encrypting API credentials: Store keys securely in environment variables
Testing Your Integration
Test Link Creation
Create a test payment link and verify:
link_idis stored in your databasepayment_linkURL 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_idto 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)