Pay with bunq for WooCommerce

By Patrick Kivits

0+ active installationsVersion 2.3.0

Accept iDEAL | Wero, card, Bancontact and bunq payments in your WooCommerce shop with just your bunq account.

Description

Your customers pay through a bunq.me payment request on your own bunq account. There is no payment service provider in between: the money lands on the bunq account you choose.

  • iDEAL | Wero, credit and debit cards, Bancontact and bunq-to-bunq transfers through a bunq.me payment request.
  • Optionally let customers pick the payment method at checkout; methods whose bunq limits do not fit the order total are hidden.
  • The iDEAL | Wero, card and Bancontact logos at checkout, and optionally each of them as a payment option of its own.
  • Orders are confirmed by bunq’s callback, again when the customer returns to the shop, and by background checks (WooCommerce’s Action Scheduler) in case the callback never arrives.
  • Payment requests that bunq reports as expired or cancelled cancel the order; cancelling an order cancels its payment request at bunq.
  • Send an unpaid order’s bunq.me payment link to the customer by email from the order screen, for orders taken by phone or sent as an invoice.
  • Refunds from the WooCommerce order screen, created as a bunq draft payment back to the IBAN the payment came from and approved in the bunq app.
  • A bunq payment box on the order screen (also with High-Performance Order Storage) shows the payer’s name and IBAN, the payment method and a link to the bunq.me payment request.
  • An hourly check of the connection with bunq warns on every admin page when bunq stops accepting it, before checkouts fail. The outcome is in WooCommerce > Status.
  • Works with the classic checkout and the block checkout, and with High-Performance Order Storage.
  • Translatable through translate.wordpress.org.

The payment method logos are from Pronamic’s wp-pay-logos (GPL-2.0-or-later).

The source code, including the development tools, is on GitHub.

Requirements

  • A bunq account.
  • WooCommerce.
  • HTTPS, so bunq can reach the shop’s callback URL.
  • The PHP extensions openssl, curl, json and mbstring.

The plugin is developed by Patrick Kivits and is the WooCommerce integration bunq presents to its business customers, see WooCommerce on bunq.com and the bunq Help article.

External services

This plugin connects your shop to bunq, the bank that holds the merchant’s account and processes the payments. Without bunq the plugin has no function. Depending on the “Test mode” setting it talks to bunq’s production environment or to bunq’s sandbox.

OAuth authorization (oauth.bunq.com, api.oauth.bunq.com; sandbox: oauth.sandbox.bunq.com, api-oauth.sandbox.bunq.com)
When the shop administrator clicks “Connect to bunq” on the settings page, the browser is sent to bunq with the OAuth client ID and the settings page URL. When bunq sends the administrator back, the plugin sends the OAuth client ID, client secret, the authorization code and the settings page URL to bunq to obtain the API key.

bunq API (api.bunq.com; sandbox: public-api.sandbox.bunq.com)
With the API key the plugin registers the shop’s server with bunq (a generated public key; bunq sees the server’s IP address) and then:

  • lists the merchant’s bank accounts on the settings page;
  • registers the shop’s callback URL for payment request notifications;
  • creates a bunq.me payment request when a customer places an order, or when the merchant sends a payment link for an order, with the order total, the currency, the order number and the URL of the order confirmation page;
  • reads the payment request and the payments made through it when bunq calls the callback URL, when the customer returns to the shop and in background checks for up to two days, and stores the payer’s name, IBAN and payment method on the order (for older orders, once when the order is opened in the admin);
  • cancels the payment request when the order is cancelled in WooCommerce;
  • reads the payment and creates a draft payment back to the customer’s IBAN when the merchant refunds an order, with the refund amount, the customer’s IBAN and name as bunq reported them, and a description with the order number, the shop name and the refund reason.

bunq.me (bunq.me)
To pay, the customer is sent to the bunq.me page of the payment request, where they choose a payment method and enter their payment details at bunq.

bunq’s terms and privacy policy apply to this data:

Installation

  1. In your WordPress admin panel, navigate to Plugins > Add New, search for “Pay with bunq for WooCommerce”, then install and activate it.
  2. Navigate to WooCommerce > Settings > Payments > bunq.
  3. Under bunq account, leave Test mode unchecked to receive real payments. To try the plugin first, check Use the bunq sandbox and use a bunq sandbox account in the steps below.
  4. Click Copy next to the Redirect URL. In the bunq app, navigate to Developers > OAuth, tap Add Redirect URL and paste it.
  5. In the bunq app, tap Show Client Details and copy the Client ID and Client Secret into the fields with the same name.
  6. Click Connect to bunq. The settings are saved and bunq shows a QR code: scan it with the bunq app, choose the bank accounts the shop may use and approve. bunq sends you back to the settings page, where Connection now says “Connected to bunq as” followed by your name.
  7. Under Receiving payments, select the Bank account payments are paid into. Check Enable bunq Gateway at the top of the page and click Save changes.

Under Checkout you set the title and description customers see. With Enable direct gateway customers choose iDEAL | Wero, card, Bancontact or a bunq transfer on the checkout page; Payment methods limits which of them are offered.

With Show payment methods separately iDEAL | Wero, card and Bancontact are each a payment option of their own at checkout, with its own logo, instead of one bunq option; customers go straight to the chosen method on bunq.me. Payment methods limits which of them are offered, and they also appear in WooCommerce’s list of payment methods, where turning one on or off updates these settings. Payments from a bunq account are not offered separately.

Managing the connection

Once the shop is connected, the settings page hides the Client ID and Client Secret and shows three actions next to Connection:

  • Connect again: scan a new QR code, for example after bunq rejected the connection.
  • Change OAuth client: shows the Client ID and Client Secret fields again to switch to another OAuth client.
  • Disconnect: the shop forgets its access to bunq. Remove the connection in the bunq app to revoke it at bunq as well.

Live mode and the sandbox each have their own OAuth client and connection; the Test mode checkbox switches between them. The Client Secret is never shown again after saving it: leave the field empty to keep it.

The bank account list is cached for an hour. Click Refresh bank accounts below the bank account select after adding an account in the bunq app.

FAQ

How do I send a payment link for an order taken by phone or sent as an invoice?

Open an unpaid order in WooCommerce, choose Send bunq payment link to customer under Order actions and click Update. The plugin creates a bunq.me payment request for the order total and emails the link to the billing email address. When the customer pays, the order is confirmed the same way as a checkout payment. Sending the link again reuses the open payment request, unless the order total changed; then the old link is cancelled and a new one is sent. The order’s payment method becomes bunq. The action is offered for orders that need payment (pending or failed) in euros while bunq is connected. Edit the email’s subject, heading and text in WooCommerce > Settings > Emails > bunq payment link.

How do refunds work?

Open the order in WooCommerce, click Refund, enter the amount and choose Refund via bunq. The plugin creates a draft payment at bunq back to the IBAN the payment came from and adds a note with the draft payment id to the order. Approve the draft in the bunq app to actually send the money: bunq does not let an app connected through OAuth pay an external IBAN without that approval.

WooCommerce records the refund as soon as the draft is created, so an unapproved draft leaves the order marked as refunded while the customer has not received anything. Payments without a counterparty IBAN (for example card payments) cannot be refunded through the API; refund those from the bunq app.

An order does not change status. Where do I look?

Everything the plugin does with bunq (callbacks received, payments matched, refunds, errors) is written to WooCommerce > Status > Logs (source: bunq).

An admin notice says “The connection with bunq stopped working”

The plugin checks the connection with bunq every hour. bunq no longer accepts it: the access was removed in the bunq app, the shop now connects from another IP address, or the selected bank account was closed. The notice shows bunq’s answer. Click Connect again on the bunq settings page and scan the QR code; Check again in the notice confirms the fix. WooCommerce > Status shows the outcome of the last check.

The settings page still says “Not connected” after the authorization, or the bank account list says “bunq rejected the saved connection”

  • The plugin shows the error returned by bunq at the top of the settings page right after the redirect back from bunq, with details in the WooCommerce log.
  • Make sure the redirect URL registered in the bunq app is exactly the redirect URL shown on the settings page, including &section=bunq.
  • bunq ties the API key to the IP address the shop’s server connects from. If your host sends outgoing requests from changing IP addresses, bunq may reject the session with “Incorrect API key or IP address”. List all of the host’s outgoing addresses with the bunq_for_woocommerce_permitted_ips filter and click Connect again; see the plugin’s GitHub readme for an example.

Unpaid orders are cancelled before the customer paid

By default WooCommerce holds stock for unpaid orders for 60 minutes and then cancels them. Some payment methods offered by bunq.me can take longer. Increase or disable WooCommerce > Settings > Products > Inventory > Hold stock (minutes). The plugin keeps checking unpaid orders in the background for two days and cancels an order once bunq reports its payment request as expired.

Can I try it without real money?

Yes. Check Use the bunq sandbox under Test mode and connect the OAuth client of a bunq sandbox account; the plugin then talks to bunq’s sandbox. The live connection is kept: uncheck the box to switch back.

Which language does the payment page use?

The bunq.me payment page is hosted by bunq and follows the language of the customer’s browser.

Screenshots

Changelog

2.3.0

  • A payment request for a chosen payment method now offers only that method on bunq.me. A customer who comes back and picks another method gets a new payment request for it, and a payment link sent from the order screen still offers every method.
  • New banner and icon for the plugin page on wordpress.org.

2.2.0

  • The plugin talks to bunq through the WordPress HTTP API and no longer bundles Guzzle or league/oauth2-client; it has no third-party libraries left. Production calls still pin the public key of api.bunq.com, now on WordPress’ cURL transport.

2.1.2

  • Fixed: on multisite, a network-activated WooCommerce was treated as missing, so the plugin deactivated itself.
  • Translations now come from translate.wordpress.org as language packs; the plugin no longer bundles its own translation files.

2.1.1

  • Fixed: since 2.0.1 every call to bunq’s production environment failed with “Passing CURLOPT_PINNEDPUBLICKEY (10230) in the “curl” request option is not supported”, so payments could not be created. Guzzle 8 no longer allows the pinned public key of api.bunq.com, so the plugin is back on Guzzle 7. The sandbox was not affected.

2.1.0

  • Renamed to Pay with bunq for WooCommerce, with the plugin folder and text domain pay-with-bunq-for-woocommerce, ahead of the listing on wordpress.org. Settings and the bunq connection are kept.
  • When the plugin is installed twice (the old bunq-for-woocommerce folder next to the new one), the second copy only shows a notice to delete the older one instead of loading again.

2.0.1

  • Updated the bundled libraries: Guzzle 8 for the connection with bunq. No change in behavior.

2.0.0

  • Requires PHP 8.1 and WordPress 5.9 or newer. Shops on older versions stay on 1.11.0, which has the same features and fixes.
  • The code uses PHP 8.1: typed properties, native parameter and return types and newer syntax. No change in behavior.

1.11.0

  • New order action Send bunq payment link to customer: emails the customer a bunq.me link for an unpaid order, for example one taken by phone or sent as an invoice.
  • The order screen shows who paid with bunq and how: the payer’s name and IBAN, the payment method and a link to the payment request.
  • Warns in the admin when the connection with bunq stops working, with the details in WooCommerce > Status.
  • Fix: payments are confirmed automatically again after selecting another bank account in the settings.
  • Fix: pending orders are still confirmed after the bank account setting changes.
  • Fix: a customer who places the order again no longer gets a second payment request; the open one is reused.
  • Fix: a payment that comes in just before WooCommerce cancels the unpaid order is recorded on the order, so it can be refunded.

1.10.0

  • The iDEAL | Wero, card and Bancontact logos are shown at checkout, in the classic and the block checkout.
  • New setting Show payment methods separately: iDEAL | Wero, card and Bancontact each appear as a payment option of their own at checkout, with their own logo, and take the customer straight to that method on bunq.me. Off by default.
  • iDEAL is shown as “iDEAL | Wero” for the move of iDEAL to Wero. Saved settings and existing orders keep working.
  • bunq is no longer offered at checkout when the cart or order is not in euros; bunq.me payment requests are in euros only.

1.9.2

  • New filter bunq_for_woocommerce_permitted_ips to register the IP addresses bunq accepts the shop’s API key from. Shops on hosts that send outgoing requests from several addresses (load balanced or serverless hosting) can list all of them, so bunq no longer rejects the connection with “Incorrect API key or IP address” when a request comes from another address of the host. Click Connect again after setting the list.

1.9.1

  • When bunq’s callback and the customer’s return to the shop checked the same order at the same moment, both could record the payment: the bunq payment id and account were stored twice on the order, the “bunq payment received” note was added twice and the payment completion (status change, emails) ran twice. Only one check of an order runs at a time now, and a check that finds the payment already recorded leaves the order alone.

1.9.0

  • The plugin talks to the bunq API with its own client instead of the bunq PHP SDK. The plugin zip is about 98,000 lines of code smaller, PHP 8.4 and newer no longer report deprecations from it, and opcache.save_comments=0 no longer breaks the connection with bunq.
  • Fewer calls to bunq: loading the connection no longer lists the bank accounts on every request, and the default bank account is only looked up when no bank account is selected.
  • When bunq ends a session early, the plugin opens a new one and repeats the rejected call. When bunq refuses a new session as well (for example after the server’s IP address changed), it reconnects with the saved access before any call went through, and not again for five minutes after a failed attempt.
  • Connecting keeps the callback URLs other integrations registered on the bank account; before, they were replaced.
  • The bank account select lists up to 200 accounts per type instead of 10.
  • Existing connections keep working without connecting again.

1.8.1

  • Servers whose PHP OPcache removes code comments (opcache.save_comments=0) could not connect to bunq: the bunq SDK needs those comments to read bunq’s responses, and connecting failed with “Installation::getToken(): Return value must be of type bunq\Model\Core\Token, array returned”. The settings page now explains that the hosting provider has to set opcache.save_comments=1, before sending you to bunq and in the bank account select.
  • opcache.save_comments=1 is listed in the requirements.
  • Updated Dutch, French and German translations.

1.8.0

  • Redesigned settings page: a Connection row shows whether the shop is connected to bunq and to which account, the redirect URL to register in the bunq app has a Copy button, and the fields are grouped into bunq account, Receiving payments and Checkout.
  • “Connect to bunq” saves the settings and opens bunq’s QR code in one step; it replaces the “OAuth Authorization Request” button.
  • New: Disconnect, which forgets the shop’s access to bunq and keeps the OAuth client so connecting again takes one click.
  • The test mode checkbox switches the OAuth client and connection on the settings page right away, without saving first.
  • The OAuth redirect URL is always the plugin settings page URL (/wp-admin/admin.php?page=wc-settings&tab=checkout&section=bunq), however the page was opened. Before, extra parameters on the page URL could make bunq reject the authorization.
  • The browser no longer fills in the WordPress login password in the Client Secret field.
  • Errors from bunq during the authorization show bunq’s error descriptions instead of the raw response, and the bank account select says when bunq rejected the saved connection.
  • The payment method select of the direct gateway in the block checkout looks like the other checkout fields in every theme and has a “Payment method” label.
  • Updated Dutch, French and German translations.

1.7.0

  • Security: only an administrator returning from bunq to the plugin settings page can complete the bunq authorization, and only with the state of the authorization they started. Before, the authorization could be completed by requests from anyone.
  • Security: the OAuth client secret, the client ID, the authorization code and the API key are kept out of the WooCommerce log, the PHP error log and the error shown on the settings page, also when bunq repeats them in an error.
  • Security: the API key and the API context (which holds the private key) are no longer settings fields. They are not shown on the settings page or in the WooCommerce REST API, cannot be changed through either, and are stored apart from the settings without being loaded on every request. The OAuth client secret is no longer put in the settings page; leave the field empty to keep it.
  • Security: callbacks arriving in quick succession for the same payment request make one request to bunq and queue a single follow-up check.
  • Restructured the plugin into autoloaded, namespaced classes following the WordPress coding standards. Code that refers to the WC_Bunq_Gateway or WC_Bunq_WooCommerce_Block_Checkout classes keeps working.
  • Requires WordPress 4.7 or newer and declares WooCommerce as a required plugin.
  • Fix: the block checkout no longer fails with a fatal error on servers that do not meet the plugin’s requirements.
  • Tested up to WordPress 7.1 and WooCommerce 11.2.

1.6.4

  • Fix: no warning about the other mode’s OAuth client on the first save of the settings.

1.6.3

  • Refunds are created as bunq draft payments that you approve in the bunq app.

1.6.2

  • Fix: strip characters bunq rejects from the refund description.

1.6.1

  • Fix: the payment method chosen at checkout opens directly on bunq.me again.

1.6.0

  • Payments are confirmed when the customer returns to the shop and by background checks.
  • Expired or cancelled payment requests cancel the order, and cancelled orders cancel their payment request.
  • Refunds from the WooCommerce order screen.
  • Dutch, French and German translations.

1.5.10

  • Fix: order lookup and amount check of bunq’s callback, and registration of the callback URL.

1.5.9

  • Fix: the settings fields are defined outside the admin as well.

1.5.8

  • Supports PHP 7.3 up to 8.5.

1.5.7

  • Updated Guzzle and the OAuth client library.

1.5.6

  • Errors from bunq during the OAuth setup are shown instead of silently ignored.