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

Gravity Forms Midtrans Premium Add-on Setup Guide

Updated 9 min read Gravity Forms Integrations A–Z
On this page
  1. What you need
  2. Install and activate
  3. Connect your Midtrans account
  4. Payment notifications
  5. Add a feed to your form
  6. How a payment works
  7. Refunds
  8. Subscriptions
  9. Sandbox and Production
  10. For developers
  11. Troubleshooting
  12. Privacy

The Gravity Forms Midtrans Premium Add-on takes payments in Indonesia with your forms through Midtrans. When a visitor submits the form, the add-on creates a Midtrans payment for the exact total Gravity Forms worked out on the server and sends the visitor to the hosted Midtrans payment page (Snap). The visitor pays there with a card, an e-wallet, QRIS, a bank virtual account, a convenience store or another method of your account, so card and e-wallet details never reach your website. Before an entry changes, the add-on asks Midtrans for the transaction status and checks the order ID, the amount, the currency and the status.

Indonesia and rupiah

Midtrans is a payment gateway for businesses in Indonesia, and it charges in Indonesian rupiah (IDR). Set the Gravity Forms currency to Indonesian Rupiah; the add-on adds it to the currency list when it is missing (Rp 150.000: no decimals, a dot for thousands). Which methods your customers see depends on what is active on your Midtrans account, for example cards, GoPay, ShopeePay, QRIS, bank virtual accounts, Indomaret and Alfamart, Kredivo or Akulaku.

This guide covers the setup, the feed, payments, notifications, refunds and going live. The add-on costs one site $49 a year, five sites $69 a year, unlimited sites $199 a year.

What you need

  • WordPress 6.5 or newer, PHP 7.4 or newer (with the openssl extension) and Gravity Forms 2.9 or newer.
  • A Midtrans merchant account. The Sandbox environment is available right after sign-up; Production follows when Midtrans has approved your account.
  • The server key of each environment, from Settings → Access Keys in the Midtrans dashboard.
  • The Gravity Forms currency set to Indonesian Rupiah.
  • Your site public and on HTTPS, so Midtrans can reach the notification address.
  • A form with at least one product field (or a total).

The add-on talks to the Midtrans Snap API (app.midtrans.com, app.sandbox.midtrans.com in Sandbox) to create payments and to the Midtrans API (api.midtrans.com) to read the transaction status and to refund. No Midtrans script is loaded on your pages: the customer is redirected to the payment page. Apart from that, the add-on checks gravityextra.com for your licence and plugin updates.

Install and activate

  1. Upload the zip in Plugins → Add New → Upload Plugin and activate it.
  2. Open Forms → Settings → Midtrans, enter your GravityExtra licence key and press Activate License.
  3. The Midtrans sections appear once the licence is active. Payments, notifications and refunds work only with an active licence.

Connect your Midtrans account

Midtrans settings: Sandbox or Production, the server key of each environment, optional payment methods and payment window, the IDR currency line, the account-ready line and the notification address
Settings: choose Sandbox or Production and paste the server key from Settings, Access Keys. The key is stored encrypted; the notification address is sent with every payment.
  1. Leave Environment on Sandbox for now.
  2. In the Midtrans dashboard, switch to the Sandbox environment, open Settings → Access Keys and copy the Server Key (it starts with SB-Mid-server-) into the Sandbox server key field.
  3. Optional: under Payment methods, list the Midtrans codes of the methods you want on the payment page, separated by commas. Leave it empty to offer every method active on your account.
  4. Optional: set a payment window in hours. It decides how long a bank transfer, store or e-wallet payment stays open after the form is sent. Empty means the Midtrans default.
  5. Save. The Account line turns green with a masked server key and the payment methods. The key is stored encrypted and never shown again.
  6. The Currency line confirms that your forms use IDR.
Setting Used for
Server key (per environment) Creating each payment, reading its status and refunds, on your server only
Payment methods The methods shown on the Midtrans page (optional)
Payment window How long pending payments stay open (optional)
Notification address Where Midtrans reports payment results; sent with every payment

Payment notifications

Midtrans reports every change of a payment with an HTTP notification. The add-on sends its notification address with each payment (Midtrans calls this overriding the notification URL), so it works even when the Payment Notification URL in your dashboard points to another system. You can also paste the address from the settings into Settings → Configuration of the Midtrans dashboard. The settings show the last notification the add-on accepted.

Every notification is signed and checked

Each notification carries a signature_key: a SHA-512 hash of the order ID, the status code, the gross amount and your server key. The add-on recomputes it and refuses any notification that does not match. Even a valid notification is only a hint: the add-on then asks Midtrans for the transaction status with your server key and compares the order ID, the amount, the currency and the status before the entry changes.

Add a feed to your form

The Midtrans feed: products and services with the form total, first name, last name, e-mail and phone mapped, the payment description and the notification option
The feed: map the customer details shown on the Midtrans page and set the payment description.
  1. Open the form, then Settings → Midtrans → Add New.
  2. Choose Products and Services and usually the Form Total.
  3. Map the first name, last name, e-mail and phone. Midtrans shows them on the payment page and uses the e-mail for receipts and instructions.
  4. Set the payment description. It is used as the item name when the form products do not add up to the total. Merge tags work, for example Booking #{entry_id}.
  5. Keep Send form notifications only after the customer has paid ticked, so your booking e-mails go out for paid entries only.
A batik workshop booking form with name, e-mail, mobile number, workshop places and lunch sets with quantities, the total in rupiah and the Continue to payment button
The form your customer fills in. Card and e-wallet details are entered on the Midtrans page, not here.

How a payment works

  1. The visitor submits the form. Gravity Forms works out the total on the server, and the add-on creates a Midtrans payment for that amount in whole rupiah, with a unique order ID, the items, the customer details, the finish address and the notification address.
  2. The visitor goes straight to the Midtrans payment page to choose a method and pay.
  3. Midtrans sends a signed notification. The add-on checks the signature, reads the transaction status and marks the entry Paid only when the payment is settled (or the card capture is accepted) and the order ID, the amount and the currency match.
  4. Midtrans sends the visitor back to your form page. The return page also reads the status; if there is no result yet, it waits and checks again by itself, then shows your confirmation.
  5. A payment is never completed twice, however many notifications or returns arrive.
What Midtrans reports Entry
settlement, or capture accepted by fraud detection Paid, with the transaction and the method in the notes
pending (virtual account or store payment not paid yet) Pending; paid automatically when the customer pays
capture with fraud status “challenge” Pending, with a note to accept or deny it in the Midtrans dashboard
deny, expire or failure Failed: nothing was charged, and the customer gets a link to try again
cancel of a card payment before settlement Voided
refund or partial_refund Refunded or Partially Refunded, each refund booked once

When a payment fails or expires, your form page says that nothing was charged and offers Try the payment again. The add-on then creates a new Midtrans order for the same amount, because Midtrans uses each order ID only once. A notification about the earlier order is not applied to the entry.

Refunds

An entry paid through Midtrans and partly refunded: the Midtrans box with the status, order ID, transaction, method, Midtrans status, amount, refunded amount and the refund form
The entry after payment: status, Midtrans order and method, and refunds from the entry screen.

Open a paid entry. The Midtrans box shows the status, the order ID, the transaction, the payment method, the Midtrans status and the amounts. Type an amount in rupiah and press Refund. The add-on first reads the status (only settled payments can be refunded), then sends the refund with a refund key, so a repeated request is the same refund at Midtrans and never a second one. When Midtrans lists the refund, the entry becomes Partially Refunded or Refunded.

Payment method Refund from the entry
Card, GoPay, QRIS, DANA, Kredivo, Akulaku Full or partial, in several steps up to the amount paid
ShopeePay, OVO Full refund only (Midtrans does not refund part of these)
Bank virtual accounts, Mandiri Bill Payment, Indomaret, Alfamart Not online: refund the customer another way, for example by bank transfer

Refunds you make in the Midtrans dashboard arrive as notifications and are booked on the entry after the add-on has read and checked the status. Midtrans has to enable refunds on your account; refund windows depend on the method (for example DANA and OVO have their own limits).

Subscriptions

Subscriptions are not offered. Recurring charges with Midtrans need a card saved through Midtrans’ card script on your page or a linked GoPay account, which a redirect to the hosted payment page does not provide. Each form submission is one payment.

Sandbox and Production

  • In Sandbox, entries are marked as test payments and no money moves. Pay with the test cards and payment simulators in the Midtrans documentation.
  • For Production, paste the Production server key (it starts with Mid-server-), choose Production and save.
  • Make one small real payment and refund it from the entry.
  • Entries remember the environment they were paid in; notifications and refunds use the key of that environment, and a Production notification never pays a Sandbox entry.

For developers

The payment request can be adjusted with gravityextra_midtrans_snap_body (for example the methods per form), and the notification address with gravityextra_midtrans_notify_url. The amount and the order ID are always checked again against the transaction status.

// Show only e-wallets and QRIS on the Midtrans page for one form (ID 7).
add_filter( 'gravityextra_midtrans_snap_body', function ( $body, $feed, $form, $entry ) {
    if ( 7 !== (int) rgar( $form, 'id' ) ) {
        return $body;
    }
    return array_merge( $body, array( 'enabled_payments' => array( 'gopay', 'shopeepay', 'other_qris' ) ) );
}, 10, 4 );

Troubleshooting

What you see What to do
“This is a Production server key” Sandbox and Production keys are different. Paste the key that starts with SB-Mid-server- into the Sandbox field and the one with Mid-server- into the Production field.
“This is not a Midtrans server key” Copy the server key, not the client key or the merchant ID, from Settings → Access Keys, completely and without spaces.
“Online payment is not available in USD” Midtrans charges in rupiah. Choose Indonesian Rupiah in Forms → Settings.
“Unknown payment method code” Use Midtrans codes such as credit_card, gopay, shopeepay, other_qris, bank_transfer, bca_va or cstore, or leave the field empty.
“Midtrans did not create the payment (http_401 …)” in the entry notes The server key does not belong to the chosen environment. Check the key and the environment.
The customer returns but the entry stays Processing The customer has not paid yet, or Midtrans has not finished. The return page checks again by itself, and the entry updates when the notification arrives. Check that the site is public and not blocked by a firewall.
“Only settled payments can be refunded” A card payment is refundable once Midtrans has settled it, usually the next working day. Before that you can cancel it in the Midtrans dashboard.

If an entry stays Processing although the customer paid, open it and press Check the payment with Midtrans in the Midtrans box: the add-on reads the status of the order and updates the entry.

Privacy

The add-on sends Midtrans the amount, the items, the entry number in the order ID, and the customer details you map (name, e-mail, phone). Card and e-wallet details are entered on the Midtrans page and never reach your site. The server keys are stored encrypted with keys from your site’s WordPress salts. Uninstalling the add-on removes its settings, including the keys.

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