n8n PayMongo Tutorial: Automate GCash, Maya and QR Ph Payments

If you sell anything online in the Philippines, your customers want to pay with GCash, Maya, QR Ph or a card. PayMongo gives you all of those behind one hosted checkout page, but the work around each payment still piles up: sending payment links, checking who paid, updating your order sheet, thanking the customer and reconciling at the end of the day.

n8n doesn’t ship a dedicated PayMongo node, but PayMongo has a clean REST API and webhooks, so the HTTP Request and Webhook nodes are all you need. In this tutorial you’ll connect PayMongo to n8n and build four workflows that handle the full payment loop, including two that use AI.

What you’ll build

  • On-demand checkout links – send an order to n8n and get a PayMongo checkout URL back that accepts GCash, Maya, cards and QR Ph.
  • Verified payment confirmations – receive PayMongo webhooks, verify the signature, mark the order paid in Google Sheets and ping you on Telegram.
  • AI thank-you emails – have an AI model write a short, personal receipt email for every paid order.
  • AI daily sales digest – every evening, summarize the day’s payments into a quick report.

Step 1: Connect PayMongo to n8n

PayMongo authenticates API calls with HTTP Basic Auth: your secret key is the username and the password is empty.

  1. Log in to the PayMongo Dashboard and open Developers (API keys). Copy your test secret key, which starts with sk_test_. Use the sk_live_ key only when you go live.
  2. In n8n, go to Credentials → Add credential → Basic Auth.
  3. Set User to your secret key and leave Password empty. Name it PayMongo Test.
  4. Add an HTTP Request node, set Authentication to Generic Credential Type → Basic Auth, and pick the credential.

Every request goes to https://api.paymongo.com with Content-Type: application/json, and every request body is wrapped in data.attributes. One detail that trips people up: amounts are in centavos, so ₱500.00 is sent as 50000. If you’re new to calling APIs from n8n, the HTTP Request tutorial for beginners covers the basics.

Workflow 1: Create a checkout link on demand

Webhook (POST /new-order)
   ↓
HTTP Request (POST /v2/checkout_sessions)
   ↓
Respond to Webhook (checkout_url)
  1. Add a Webhook node with method POST, path new-order, and Respond set to Using ‘Respond to Webhook’ Node. Your shop, form or chatbot sends JSON like {"order_id":"ORD-1042","item":"Logo design","amount":1500,"email":"juan@example.com"}.
  2. Add an HTTP Request node: method POST, URL https://api.paymongo.com/v2/checkout_sessions, your PayMongo credential, and Body Content Type JSON:
    {
      "data": {
        "attributes": {
          "line_items": [{
            "name": "{{ $json.body.item }}",
            "amount": {{ Math.round($json.body.amount * 100) }},
            "currency": "PHP",
            "quantity": 1
          }],
          "payment_method_types": ["gcash", "paymaya", "card", "qrph"],
          "success_url": "https://yourshop.ph/thank-you",
          "cancel_url": "https://yourshop.ph/cart",
          "reference_number": "{{ $json.body.order_id }}"
        }
      }
    }
  3. Add a Respond to Webhook node that returns JSON: {"checkout_url": "{{ $json.data.attributes.checkout_url }}"}.

The reference_number is the important part. It’s how you match the payment back to your order later. Only include payment methods that are activated on your account; you can check them under Payment Methods in the dashboard. PayMongo also offers /v1/checkout_sessions, but its docs now use /v2, which creates the payment intent only when the customer actually pays.

Workflow 2: Verified payment confirmations

Webhook (POST /paymongo, Raw Body on)
   ↓
Code (verify Paymongo-Signature)
   ↓
IF (valid AND type = checkout_session.payment.paid)
   ↓
Google Sheets (update order row) → Telegram (alert)
  1. Create a Webhook node with method POST and path paymongo. Under Options, turn on Raw Body, because the signature must be checked against the exact bytes PayMongo sent. Set Respond to Immediately so PayMongo gets a fast 200.
  2. In the PayMongo Dashboard, go to Developers → Webhooks → Add endpoint, paste your n8n production URL and subscribe to checkout_session.payment.paid. Copy the webhook’s secret key.
  3. Add a Code node (Run Once for All Items) to verify the Paymongo-Signature header. The header looks like t=...,te=...,li=...; you compute an HMAC-SHA256 of t + "." + rawBody with the webhook secret and compare it to te (test mode) or li (live mode):
    const crypto = require('crypto');
    const secret = 'whsk_your_webhook_secret';
    const raw = (await this.helpers.getBinaryDataBuffer(0, 'data')).toString('utf8');
    const header = $input.first().json.headers['paymongo-signature'] || '';
    const parts = Object.fromEntries(header.split(',').map(p => p.split('=')));
    const body = JSON.parse(raw);
    const live = body.data.attributes.livemode;
    const expected = crypto.createHmac('sha256', secret)
      .update(parts.t + '.' + raw).digest('hex');
    const valid = expected === (live ? parts.li : parts.te);
    return [{ json: { valid, event: body.data } }];
  4. Add an IF node with two conditions: {{ $json.valid }} is true, and {{ $json.event.attributes.type }} equals checkout_session.payment.paid.
  5. On the true branch, add a Google Sheets node (Update Row) matching on your order_id column with {{ $json.event.attributes.data.attributes.reference_number }}, and set status to paid and paid_at to {{ $now.toISO() }}.
  6. Finish with a Telegram node: Paid: {{ $('IF').item.json.event.attributes.data.attributes.reference_number }}.

PayMongo retries failed deliveries up to 12 times, so the same event can arrive more than once. Store the event ID ({{ $json.event.id }}) in a sheet or database and skip IDs you’ve already processed.

Workflow 3: AI thank-you emails

Google Sheets Trigger (row updated, status = paid)
   ↓
OpenAI (write receipt message)
   ↓
Gmail (send to customer)
  1. Add a Google Sheets Trigger on your orders sheet watching for updated rows, followed by an IF node that only continues when {{ $json.status }} equals paid.
  2. Add an OpenAI node (Message a Model) with a prompt like: Write a short, warm thank-you email in English for order {{ $json.order_id }} ({{ $json.item }}, PHP {{ $json.amount }}). Confirm payment was received, say what happens next, and keep it under 90 words. No subject line.
  3. Add a Gmail node: To {{ $('Google Sheets Trigger').item.json.email }}, Subject Payment received for {{ $('Google Sheets Trigger').item.json.order_id }}, and the model’s output as the message.

Keep facts such as amounts and order IDs in the sheet, not in the AI’s hands. The model only writes the friendly wording around them.

Workflow 4: AI daily sales digest

Schedule Trigger (8:00 PM daily)
   ↓
Google Sheets (get today's paid rows)
   ↓
Aggregate → OpenAI (summarize) → Telegram
  1. Add a Schedule Trigger set to every day at 20:00 (make sure your instance timezone is Asia/Manila).
  2. Add a Google Sheets node (Get Row(s)) and a Filter node keeping rows where {{ $json.status === 'paid' && $json.paid_at.startsWith($today.toFormat('yyyy-MM-dd')) }} is true.
  3. Use an Aggregate node to combine the rows into one item, then an OpenAI node with: Summarize these paid orders for a shop owner: total sales in PHP, number of orders, top item and anything unusual. Data: {{ JSON.stringify($json.data) }}.
  4. Send the result with a Telegram node so the day’s numbers land on your phone.

Troubleshooting

  • 401 Unauthorized – the secret key must be the Basic Auth username with an empty password. Don’t use the public key (pk_).
  • Amount looks 100x too small – you sent pesos instead of centavos. Multiply by 100.
  • Payment method error on checkout – remove methods from payment_method_types that aren’t activated on your account.
  • Webhook never arrives – you registered the test URL, or the workflow isn’t published. PayMongo needs the production URL, and test-mode endpoints only receive test-mode events.
  • Signature never matches – Raw Body is off, the wrong secret is used, or you compared against li for a test event. If the Code node can’t load crypto on a self-hosted instance, allow it with NODE_FUNCTION_ALLOW_BUILTIN=crypto.
  • Duplicate rows or emails – add the event ID check from Workflow 2. For catching failed runs, see the n8n error handling guide.

Wrapping up

With two core nodes and a bit of signature checking, PayMongo becomes a fully automated payment layer: links on demand, verified confirmations, friendly receipts and a daily summary, all without touching the dashboard. Start in test mode, run a few GCash and QR Ph test payments, then swap in your live keys and a separate live webhook endpoint.

Want to see builds like this step by step? Watch and subscribe to Node & Volt on YouTube.

Leave a Comment