WP Manifestindependent plugin directory
manifest / forms / gf-sagepay

GF SagePay WP Registry grade C-. High-severity findings · 1 findingWP RegistryHigh-severity findings · 1 findingOpen the reportC- #5 in Forms

Gravity Forms Add-on for SagePay

★ 4stars
130release downloads
≈20active sites
2.5kcomposer installs
0.12.1latest · 11mo ago

Install

Download gf-sagepay.zip From the 0.12.0 release on GitHub, Jan 10, 2024

Upload it under Plugins → Add New Plugin → Upload Plugin, then activate.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/itinerisltd/gf-sagepay/releases/download/0.12.0/gf-sagepay.zip

On Packagist as itinerisltd/gf-sagepay:

composer require itinerisltd/gf-sagepay
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

SagePay payment gateway for GravityForms.

Goal

Allow Gravity Forms accepts SagePay one-off payments via SagePay Server.

Features

Not Supported / Not Implemented

Although these features are not supported by this plugin, but you might able to do so via MySagePay:

  • Card reference
  • Token billing
  • Deferred payment
  • Recurring payment
  • Void
  • Refund
  • Abort
  • Basket
  • Surcharges
  • Account Type M – for telephone (MOTO) transactions
  • Account Type C – for repeat transactions

Pull requests are welcomed.

Minimum Requirements

  • PHP v7.2
  • PHP cURL Extension
  • WordPress v4.9.5
  • Gravity Forms v2.4.14.4

Installation

Composer (Recommended)

composer require itinerisltd/gf-sagepay

Build from Source (Not Recommended)

# Make sure you use the same PHP version as remote servers.
# Building inside docker images is recommanded.
php -v

# Checkout source code
git clone https://github.com/ItinerisLtd/gf-sagepay.git
cd gf-sagepay
git checkout <the-tag-or-the-branch-or-the-commit>

# Build the zip file
composer release:build

Then, install release/gf-sagepay.zip as usual.

Best Practices

HTTPS Everywhere

Although SagePay accepts insecure HTTP sites, you should always use HTTPS to protect all communication.

Payment Status

Always double check payment status on MySagePay.

Fraud Protection

To prevent chargebacks, enforce 3D Secure and AVS/CV2 rules whenever possible.

Test Sandbox

Always test the plugin and your fraud protection rules in test sandbox before going live.

If you can't whitelist test server IPs, use protxross as Vendor Code.

Use ngrok to make local notification URLs publicly accessible.

Use one of the test credit cards.

Common Issues

Missing Gift Aid Acceptance Box

Only registered charities can use Gift Aid through the Sage Pay platform. The gift aid acceptance box only appears if your vendor account is Gift Aid enabled and using Donation as transaction type.

GF SagePay is Missing on Form Settings

Make sure you meet the minimum requirements. Check your environment details at the System Status Page.

Shipping Address

OmniPay requires both billing address and shipping address.

Use case: Not delivering any physical goods

Map the shipping address fields to the billing ones.

Use case: Allow ship to billing address

This is similar to the the WooCommerce way.

Use Gravity Forms' built-in feature: Display option to use the values submitted in different field

FAQ

Will you add support for older PHP versions?

Never! This plugin will only work on actively supported PHP versions.

Don't use it on end of life or security fixes only PHP versions.

It looks awesome. Where can I find more goodies like this?

Where can I give :star::star::star::star::star: reviews?

Thanks! Glad you like it. It's important to let my boss knows somebody is using this project. Please consider:

Developing

Public API

Build URL for continuing confirmation

ConfirmationHandler::buildUrlFor(Entry $entry, int $ttlInSeconds = 3600): string

Usage:

$entryId = 123;
$rawEntry = GFAPI::get_entry($entryId);
if (is_wp_error($rawEntry)) {
    wp_die('Entry not found');
}

$url = ConfirmationHandler::buildUrlFor(
    new Entry($rawEntry),
    86400 // expires in 24 hours (24*3600=86400)
);

echo $url;
// https://example.com?entry=123&gf-sagepay-token=XXXXXXXXXXXX

Use Case: With "using confirmation query strings to populate a form based on another submission":

  1. User fills in formA
  2. User completes SagePay checkout form
  3. User comes back and hits CallbackHandler
  4. CallbackHandler sends user to formB according to confirmation settings
  5. User arrives formB url with merged query strings

If the user quits before completing formB, you could use ConfirmationHandler::buildUrlFor generate a single-use, short-lived url for the user to resume formB.

Note:

  • The url continues Gravity Forms confirmation
  • Whoever got the url will go on confirmation, no authentication performed
  • The confirmation will use latest field values from database which could have changed
  • No payment status checking

Redirect URL Retrieval Failure Handling

After form submit, this plugin sends order information to SagePay in exchange for a redirect URL(the SagePay hosted checkout form URL).

By default, when redirect URL retrieval fails:

  1. Mark entry payment status as Failed
  2. Log the error
  3. wp_die immediately

Common failure reasons:

  • Incorrect vendor code
  • Server IP not whitelisted

Tips: Check the log.

You can use 'gf_sagepay_redirect_url_failure_wp_die' filter to:

  • continue Gravity Forms' feed and confirmation flow
  • perform extra operations
  • redirect to a different error page

Important: If this filter returns false, normal Gravity Forms' feed and confirmation flow continues. Improper settings might lead to disasters.

Example:

add_filter('gf_sagepay_redirect_url_failure_wp_die', function(bool $shouldWpDie, ServerAuthorizeResponse $response, Entry $entry, GFPaymentAddOn $addOn): bool {

    // Do something.

    return true; // Do `wp_die`
    return false; // Don't `wp_die`, continue normal flow
    return $shouldWpDie; // Undecisive
}, 10, 4);

Required Reading List

Read the followings before developing:

Gravity Forms

Gravity Forms has undocumented hidden magics, read its source code.

Testing

composer style:check

Pull requests without tests will not be accepted!

Feedback

Please provide feedback! We want to make this library useful in as many projects as possible. Please submit an issue and point out what you do and don't like, or fork the project and make suggestions. No issue is too small.

Change Log

Please see CHANGELOG for more information on what has changed recently.

Security

If you discover any security related issues, please email dev@itineris.co.uk instead of using the issue tracker.

Credits

GF SagePay is a Itineris Limited project created by Tang Rufus.

Full list of contributors can be found here.

License

GF SagePay is released under the MIT License.

Releases

13 releases. Each count is every asset in that release; expand a row for the breakdown.

Tag
Published
Assets
Downloads
0.12.1 latest
Nov 3, 2025 11mo ago
tag only
—
Jan 10, 2024 2 years ago
gf-sagepay.zip
25
Jan 23, 2023 3 years ago
tag only
—
Aug 3, 2021 5 years ago
gf-sagepay.zip
16
Feb 11, 2020 6 years ago
gf-sagepay.zip
20
Jan 31, 2020 6 years ago
gf-sagepay.zip
5
Jan 31, 2020 6 years ago
gf-sagepay.zip
8
Jan 17, 2020 6 years ago
gf-sagepay.zip
5
Dec 3, 2019 6 years ago
gf-sagepay.zip
7
Oct 20, 2019 7 years ago
gf-sagepay.zip
15
Oct 20, 2019 7 years ago
gf-sagepay.zip
9
Oct 20, 2019 7 years ago
gf-sagepay.zip
11
Oct 20, 2019 7 years ago
gf-sagepay.zip
9

Active-site estimate ≈20 comes from the median of recent superseded releases. Method.

C- grade

Security

GF SagePay 0.12.0 · audited by WP Registry

High-severity findings.

1 high
Audited release
0.12.0
Findings
1
Worst severity
high
Content hash
1ed5e3ef122f384796410222…

Findings

  • high Unauthenticated SagePay callback fails payments without a valid signature

    missing_auth

    Gravity Forms routes ?callback=gf-sagepay to AddOn::callback() on parse_request with no auth. CallbackHandler::run() builds an Omnipay SagePay Server gateway from attacker-controlled vendor and isTest query args (any non-empty strings pass), then acceptNotification() reads the POST body. After resolving an entry, a failed VPSSignature check still calls markAsFailed() before $response->invalid(). Omnipay's default exitOnResponse is false, so invalid() only echoes Status=INVALID and does not stop the request; getTransactionStatus() also returns STATUS_FAILED when the signature is bad, so the switch cannot mark the entry Paid — but fail_payment has already run. GFPaymentAddOn::fail_payment() unconditionally sets entry payment_status to Failed (including entries that were already Paid), adds an error note, and sends fail_payment notifications when the form has a SagePay feed. Entry resolution does not require a real SagePay payload: get_entry_by_transaction_id(VendorTxCode) matches any Gravity Forms payment by transaction_id, and the fallback query interpolates VendorTxCode into LIKE %"VendorTxCode":"<id>"% so VendorTxCode=% selects the first row with a SagePay transaction_reference. An unauthenticated POST to /?callback=gf-sagepay&vendor=x&isTest=1 with that wildcard (or a known transaction id from a receipt) therefore corrupts payment records and can spam failure emails. Invalid notifications must be rejected without changing payment_status.

    src/CallbackHandler.php:49-70

    Recommendation

    On !isValid(), do not call markAsFailed/markAsPaid/markAsPending; respond INVALID (or HTTP 400) and exit. Require a valid VPSSignature before any entry write. Look up entries by exact transaction_id/VendorTxCode only (no LIKE wildcards). After a valid signature, map SagePay Status to Paid/Pending/Failed as now. Optionally restrict the callback to SagePay/Opayo notification source networks.

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.