🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms toyyibPay Premium Add-on Setup Guide

Updated 9 min read Gravity Forms Integrations A–Z
On this page
  1. How a payment works
  2. Install and activate
  3. Settings
  4. Where to find the key and the category code
  5. The callback address
  6. The feed
  7. The form and the toyyibPay page
  8. Payment statuses
  9. The entry screen
  10. Refunds
  11. Testing in the Sandbox
  12. Going live
  13. For developers
  14. How it differs
  15. Troubleshooting
  16. Uninstall

The Gravity Forms toyyibPay Premium Add-on lets your Gravity Forms take payments in Malaysian Ringgit through toyyibPay. When a form is submitted, the add-on creates a toyyibPay bill for the exact total and sends the customer to the toyyibPay page, where they pay with FPX online banking or a card. When they come back, or when toyyibPay sends its callback, the add-on reads the bill back from toyyibPay and only then marks the entry as paid. This guide covers every setting, the feed, what happens during a payment, testing in the toyyibPay Sandbox and going live.

What you need

Gravity Forms 2.9 or newer, the form currency set to Malaysian Ringgit, a toyyibPay account (and a Sandbox account on dev.toyyibpay.com for tests), and a category created in each account. The callback needs your site to be reachable over HTTPS.

How a payment works

  1. The customer fills in the form. Gravity Forms works out the total; the add-on checks it is a Ringgit amount with at most two decimals and at least RM1.00, and that the email and phone are valid.
  2. The entry is saved with the status Processing. The add-on creates a bill (createBill) with the total in sen, your category, the bill name and description from the feed, the payer’s name, email and phone, a unique order reference, a signed return link and the callback address.
  3. The customer is sent to the toyyibPay page for that bill and pays with FPX or a card. Bank and card details are entered on toyyibPay, never on your website.
  4. When the customer returns, the add-on ignores the status in the address and reads the bill’s transactions from toyyibPay. A successful transaction for the right reference and amount marks the entry Paid; a pending FPX payment shows a page that checks again by itself.
  5. toyyibPay also posts a callback. The add-on checks its hash with your key, then reads the bill back again. The same payment is never completed twice.
  6. Every five minutes a status check reads bills still waiting. When a bill has expired without a payment, it is closed at toyyibPay and the entry is cancelled.

Install and activate

  1. In WordPress, go to Plugins → Add New → Upload Plugin, choose the zip file and activate the add-on.
  2. Go to Forms → Settings → toyyibPay and activate your GravityExtra license key. The settings appear once the license is active.
  3. Make sure Forms → Settings → Currency is Malaysian Ringgit.

Settings

The settings page has one section for your toyyibPay account. Both environments are shown; only the chosen one is used for new bills. Entries always stay with the environment their bill was created in, so switching from Sandbox to Live never confuses earlier test entries.

toyyibPay settings: Sandbox or Live, the User Secret Key and category code of each environment, payment methods, who pays the FPX fee, bill expiry, the Ringgit currency line, the connection line with the masked key and the callback address
Settings: choose Sandbox or Live and paste the User Secret Key and category code of each. Keys are checked with toyyibPay and stored encrypted.
Setting What it does
Environment Sandbox (the default) creates bills on dev.toyyibpay.com, paid with the bank simulator; Live creates real bills on toyyibpay.com.
User Secret Key (Sandbox / Live) The key from Settings in your toyyibPay account. It is checked with toyyibPay when you save, stored encrypted and only ever shown masked (first four and last four characters).
Category code (Sandbox / Live) The code of a category you created in your toyyibPay account. Every bill from your forms is created in it, so you can find them together in toyyibPay.
Payment methods FPX online banking and cards, FPX only, or cards only. Card payments must be switched on for your toyyibPay account.
FPX fee You pay the toyyibPay FPX fee, or it is added for the customer on the toyyibPay page. Card fees are always paid by you.
Bill valid for (days) How long the customer can pay the bill, from 1 to 100 days. After that the status check closes the bill at toyyibPay and cancels the entry.

Where to find the key and the category code

Log in to your toyyibPay account. The User Secret Key is in the settings of your account. For the category, open Category, create one (for example “Online orders”) and copy its code, a short string of letters and digits. Do the same in your Sandbox account on dev.toyyibpay.com for the Sandbox fields.

When you save, the add-on asks toyyibPay for the category with the key you typed. If toyyibPay does not know the key, or the category belongs to another account, the field shows toyyibPay’s answer and nothing is saved. If your server cannot reach toyyibPay at that moment, the settings are saved and the connection line says it could not confirm them yet.

The callback address

The add-on sends its callback address with every bill, so there is nothing to set up in your toyyibPay account. The address is shown on the settings page for reference, together with the time of the last verified callback. toyyibPay cannot send callbacks to a local test site; there the return page and the status check confirm payments instead.

The feed

Open your form, go to Settings → toyyibPay and add a feed.

The toyyibPay feed: products and services with the form total, the payer name, email and phone mapping, the bill name and description with merge tags and notifications after payment
The feed: map the payer name, email and phone and write the bill name and description.
  • Transaction type: Products and Services, or Donations. The payment amount is usually the form total.
  • Payer details: map the first and last name, the email and the phone. Email and phone are required: toyyibPay sends its receipt to the email and asks for the phone on every bill.
  • Bill name: the title on the toyyibPay page, up to 30 characters. toyyibPay allows letters, digits, spaces and underscores, so other characters become spaces. The default is the form title.
  • Bill description: up to 100 characters with the same rules. The default is “Order” and the entry number.
  • Notifications: tick to send the form’s notifications only after the customer has paid. They are sent once, at the moment the payment is confirmed.
  • Conditional logic: as with any Gravity Forms feed, you can run it only when a condition is met.

Tip

Add a Phone field to your form and make it required. The add-on cleans the number to digits (for example “+60 12-345 6789” becomes 60123456789) and asks the customer to correct it if it has letters or is too short or too long.

The form and the toyyibPay page

A kopi and kuih order form with quantities, the payer name, email and phone, and the total in Ringgit, with the Continue to payment button
The form: Gravity Forms works out the total in Ringgit; the customer pays it on the toyyibPay page.

The form looks like any Gravity Forms form with products and a total. After submission the customer goes straight to the toyyibPay page for the bill. There they choose their bank for FPX or pay by card, depending on your setting. If they cancel or the bank declines, nothing is charged and the entry shows Failed; they can still pay the same bill until it expires.

Payment statuses

What toyyibPay reports for the bill Entry
A successful transaction (status 1) for the exact amount and the entry’s order reference Paid, with the toyyibPay invoice number as the transaction id and the channel (for example FPX B2C) in the box
A pending transaction (status 2 or 4), for example while the bank confirms FPX Stays Processing; it updates on the next callback, return or status check
Only unsuccessful transactions (status 3) Failed; nothing was charged and the customer can still pay the same bill until it expires
No transaction and the bill has expired Cancelled, after the bill is closed at toyyibPay
A successful transaction for a different amount Not marked as paid; a note asks you to check the bill in toyyibPay

The entry screen

An entry paid through toyyibPay with FPX: the toyyibPay box with the status, amount, bill code, order reference, invoice number and payment channel, and the entry notes
The entry: status, bill, order reference and the toyyibPay invoice number, read back from toyyibPay.

Each entry paid through toyyibPay has a toyyibPay box with the status, the amount, the bill code, the order reference, the toyyibPay invoice number and the payment channel. Sandbox entries carry a “Sandbox — test payment” badge. The Refresh status button reads the bill from toyyibPay at once. The entry notes keep the history: bill created, payment received, failed or cancelled.

Refunds

toyyibPay has no refund function in its API, so the add-on does not offer a refund button. Arrange the refund from your toyyibPay account, then change the payment status of the entry yourself if you want it to show Refunded.

Testing in the Sandbox

  1. Create a Sandbox account on dev.toyyibpay.com and a category in it.
  2. Paste the Sandbox User Secret Key and category code, keep the environment on Sandbox and save. The connection line should say “Connected to toyyibPay (Sandbox)”.
  3. Submit your form. On the toyyibPay Sandbox page, pay with the bank simulator.
  4. Back on your site, the confirmation shows and the entry is Paid. Try a failed payment too, and leave one bill unpaid to see it cancelled after it expires.

Going live

  1. Paste the Live User Secret Key and the code of a category in your live account.
  2. Switch the environment to Live and save.
  3. Make one small real payment with FPX and check the entry and your toyyibPay account.

For developers

The filter gravityextra_toyyibpay_bill_fields lets you change the bill fields before the bill is created, for example the receipt email text. The amount, price setting, order reference, category, return link and callback address are set again after the filter, so they cannot be changed by mistake.

// Send a custom thank-you line in the toyyibPay receipt email for one form (ID 7).
add_filter( 'gravityextra_toyyibpay_bill_fields', function ( $fields, $feed, $entry, $form ) {
    if ( 7 !== (int) rgar( $form, 'id' ) ) {
        return $fields;
    }
    $fields['billContentEmail'] = 'Terima kasih! We will deliver within 2 working days.';
    return $fields;
}, 10, 4 );
  • gravityextra_toyyibpay_callback_url: the callback address sent with bills.
  • gravityextra_toyyibpay_rate_limit: the per-visitor limits per minute (bill creation 10, return page 30, callback 120).
  • gravityextra_toyyibpay_bills_per_hour: the cap on new bills per hour for the whole site (300).

How it differs

  • Nothing is trusted from the browser or the callback: every result is read back from toyyibPay with your key (getBillTransactions) and checked against the entry’s order reference and amount before the entry changes.
  • Each callback must carry the right hash for the key of the environment the bill was created in; a repeated callback is dropped, and a payment can only be completed once.
  • The bill is for the exact Gravity Forms total in sen. Totals with more than two decimals, below RM1.00 or in another currency are refused before a bill is made.
  • Each payment attempt gets its own order reference, and bills from several sites on one toyyibPay account never mix.
  • Expired bills are closed at toyyibPay, so an old payment link cannot be paid after the entry was cancelled.
  • Bill creation, the return page and the callback have per-visitor limits, and new bills have an hourly cap, so a flood of form posts cannot create bills without end.

Troubleshooting

What you see What to do
“toyyibPay did not accept this Sandbox key with this category code ([KEY-DID-NOT-EXIST])” The key is not a Sandbox key. Sandbox keys come from your account on dev.toyyibpay.com; Live keys from toyyibpay.com. Paste the key of the environment you are filling in.
“… ([CATEGORY-NOT-MATCH])” The category code belongs to another account or environment. Create a category in the same account as the key and paste its code.
“This toyyibPay category is inactive” Activate the category in your toyyibPay account, or create a new one.
“Online payment is not available in USD” toyyibPay bills are in Malaysian Ringgit. Choose Malaysian Ringgit in Forms → Settings.
“The order total must be at least RM1.00” toyyibPay does not create bills below RM1.00. Check the prices and quantities of the form.
“Please enter a valid phone number” toyyibPay needs the payer’s phone with digits only. Map a Phone field in the feed and make it required.
The customer paid but the entry stays Processing The callback needs a public HTTPS address (it cannot reach a local test site). The status check every five minutes and the “Refresh status” button read the bill anyway.

Uninstall

Uninstalling from Forms → Settings → Uninstall removes the settings (including the encrypted keys), the status check schedule and the add-on’s temporary data. Entries and their notes stay, and bills and payments at toyyibPay are not touched.

Plans: one site $49 a year, five sites $69 a year, unlimited sites $199 a year. Get the add-on on the Gravity Forms toyyibPay Premium Add-on page.

Still need help?

Our support team answers tickets every day, usually within a few hours.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr