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

Gravity Forms Paymob Premium Add-on Setup Guide

Updated 8 min read Gravity Forms Integrations A–Z
On this page
  1. What you need
  2. Install and activate
  3. Connect your Paymob account
  4. Callbacks: nothing to set up
  5. Add a feed to your form
  6. How a payment works
  7. Refunds
  8. Subscriptions
  9. Test mode and live mode
  10. For developers
  11. Troubleshooting
  12. Privacy

The Gravity Forms Paymob Premium Add-on takes payments with your forms through Paymob. When a visitor submits the form, the add-on creates a Paymob payment for the exact total Gravity Forms worked out on the server and sends the visitor to the secure Paymob Unified Checkout page. The visitor pays there with a card, a mobile wallet, a kiosk payment or another method of your Paymob account, so card and wallet details never reach your website. Before an entry changes, the add-on retrieves the transaction from Paymob and checks the reference, the amount, the currency and the status.

Which Paymob accounts?

This add-on works with Paymob accounts in Egypt (EGP), the United Arab Emirates (AED), Saudi Arabia (SAR), Oman (OMR) and Pakistan (PKR). The region comes from your keys (they start with egy_, are_, ksa_, omn_ or pak_), and the form currency must be the currency of that region. The add-on adds these five currencies to Gravity Forms when they are missing.

This guide covers the setup, the feed, payments, callbacks, 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 Paymob merchant account. Test mode is available as soon as you sign up; live mode follows when Paymob has activated your account.
  • From the Paymob dashboard: the secret key and public key of each mode, the API key and the HMAC secret (Settings → Account info), and the integration IDs of the payment methods you want to offer (Developers → Payment Integrations).
  • The Gravity Forms currency set to the currency of your Paymob region.
  • Your site public and on HTTPS, so Paymob can reach the callback address.
  • A form with at least one product field (or a total).

The add-on talks to the Paymob API of your region (for example accept.paymob.com in Egypt or ksa.paymob.com in Saudi Arabia) to create payments, retrieve transactions and refund, and sends customers to the Paymob checkout page. Apart from that, it 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 → Paymob, enter your GravityExtra licence key and press Activate License.
  3. The Paymob sections appear once the licence is active. Payments, callbacks and refunds work only with an active licence.

Connect your Paymob account

Paymob settings: Test or Live mode, the secret key, public key and integration IDs for each mode, the API key and HMAC secret, the EGP currency line for Egypt, the account-ready line and the callback address
Settings: choose Test or Live mode, paste the keys and integration IDs from your Paymob dashboard. Secrets are stored encrypted; the callback address is sent with every payment.
  1. In the add-on, leave Mode on Test mode for now.
  2. In the Paymob dashboard, open Settings → Account info. Copy the test secret key and public key into the Test fields.
  3. Open Developers → Payment Integrations and copy the IDs of the test integrations you want on the payment page, for example card and mobile wallet, separated by commas.
  4. Back in Account info, copy the API key and the HMAC secret. They are the same for test and live mode.
  5. Save. The Account line turns green and shows the region, a masked secret key and the integration IDs. Secrets are stored encrypted and never shown again.
  6. The Currency line confirms that the form currency matches your Paymob region.
Value Used for
Secret key Creating each payment and refunds, on your server
Public key Opening the Paymob checkout page for the customer
Integration IDs The payment methods shown on the checkout page
API key Retrieving each transaction from Paymob before an entry changes
HMAC secret Checking the signature of every callback

Callbacks: nothing to set up

Paymob tells your site about every transaction with a “transaction processed” callback. The add-on sends its callback address with every payment, so you do not need to change your integrations. If you prefer, you can also paste the address shown in the settings as the transaction processed callback of your integrations. The settings show the last callback the add-on accepted.

Every callback is signed and checked

Paymob signs each callback with your HMAC secret (HMAC-SHA512 over the transaction fields). The add-on recomputes the signature and refuses any callback that does not match. Even a valid callback is only a hint: the add-on then retrieves the transaction from Paymob with your API key and compares the reference, the Paymob order, the mode, the amount, the currency and the result before the entry changes.

Add a feed to your form

The Paymob feed: products and services with the form total, first name, last name, e-mail, phone, city and country mapped, the payment description and the notification option
The feed: map the billing fields Paymob needs and set the payment description.
  1. Open the form, then Settings → Paymob → Add New.
  2. Choose Products and Services and usually the Form Total.
  3. Map the first name, last name, e-mail, phone, city and country. Paymob needs billing data with every payment; empty values are sent as “NA”.
  4. Set the payment description. 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 Nile felucca trip booking form with name, e-mail, mobile number, trips and dinners with quantities, the total in Egyptian pounds and the Continue to payment button
The form your customer fills in. Card and wallet details are entered on the Paymob 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 Paymob payment (an intention) for that amount in minor units (piastres, fils or halalas; baisa in Oman), with your integration IDs, a unique reference for the entry, the items, the billing data, the callback address and a signed return address.
  2. The visitor goes straight to the Paymob checkout page of your region to pay.
  3. Paymob sends a signed callback with the result. The add-on checks the HMAC, retrieves the transaction and marks the entry Paid only when it succeeded and the reference, the amount and the currency match.
  4. Paymob sends the visitor back to your form page. The return page also asks Paymob for the transaction; 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 callbacks or returns arrive.
Paymob result Entry
Successful Paid, with the transaction and the payment method in the notes
Pending (kiosk or cash) Pending, with a note; paid automatically when the customer completes it
Declined Failed: the customer has not been charged and can try again on the Paymob page
Voided in the dashboard Voided, after the add-on has retrieved and checked the transaction

When a card is declined, your form page says that nothing was charged and offers a link back to the same Paymob page, so the customer can try another card or method.

Refunds

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

Open a paid entry. The Paymob box shows the status, the transaction, your reference, the Paymob order, the payment method and the amounts. Type an amount and press Refund to refund all or part of the payment; you can refund in several steps up to the amount paid. A refund form can only be sent once, so a double click never refunds twice.

Paymob answers with the refund transaction, and the add-on books it at once: the entry becomes Partially Refunded or Refunded. Refunds and voids you make in the Paymob dashboard arrive as callbacks and are recorded on the entry after the add-on has retrieved and checked them. Kiosk and cash payments cannot be refunded online.

Subscriptions

Subscriptions are not offered. Recurring payments with Paymob need a subscription integration that Paymob enables on your account first, so they are not something the add-on can switch on by itself. Each form submission is one payment.

Test mode and live mode

  • In test mode, entries are marked as test payments and no money moves. Pay with the test cards listed in the Paymob documentation.
  • For live mode, paste the live secret key, the live public key and the live integration IDs, choose Live mode and save.
  • Make one small real payment and refund it from the entry.
  • Entries remember the mode they were paid in; callbacks and refunds use the keys of that mode, and a live transaction never pays a test entry.

For developers

The callback address can be changed with the gravityextra_paymob_notify_url filter. The payment request can be adjusted with gravityextra_paymob_intention_body; the amount, the currency and the reference are always checked again when the transaction is retrieved.

// Receive Paymob callbacks on another public address of the same site
// (for example when the home page is behind a login).
add_filter( 'gravityextra_paymob_notify_url', function ( $url, $env ) {
    return add_query_arg( array( 'callback' => 'gfpaymob', 'paymob_env' => $env ), home_url( '/pay/' ) );
}, 10, 2 );

Troubleshooting

What you see What to do
“This is not a Paymob secret key of this mode” Test and live keys are different. Paste the key that starts with ..._sk_test_ into the Test field and the one with ..._sk_live_ into the Live field.
“The secret key and the public key belong to different Paymob regions” Both keys must come from the same Paymob account. Copy them again from Settings → Account info.
“Paymob did not create the payment (http_400 … integrations …)” in the entry notes An integration ID does not belong to this mode or currency. Use the IDs listed in Developers → Payment Integrations for the mode you chose.
“Online payment is not available in USD” The form currency is not the currency of your Paymob region. Choose it in Forms → Settings.
The customer returns but the entry stays Processing Paymob has not reported a transaction yet. The return page checks again by itself, and the entry updates when the callback arrives. Check that the site is public and that no firewall blocks Paymob.
The entry is Pending The customer chose a kiosk or cash method and still has to pay. The entry is paid automatically when Paymob reports it.
“Refund failed: … can not be refunded” Kiosk and cash payments cannot be refunded online, and a payment can be refunded only up to the amount paid. Check the transaction in your Paymob dashboard.

If an entry stays Processing although the customer paid, open it and press Check the payment with Paymob in the Paymob box: the add-on asks Paymob for the transaction of the entry and updates it.

Privacy

The add-on sends Paymob the amount, the currency, the items, the entry number in the reference, and the billing data you map (name, e-mail, phone, city, country). Card and wallet details are entered on the Paymob page and never reach your site. The secret keys, the API key, the HMAC secret and auth tokens 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