wc-rest-payment

Process Payments via REST API for WooCommerce.

Bancontact Payments with Stripe Sources

Use Sources to accept payments using Bancontact, Belgium’s most popular payment method.


Before you can use Bancontact, you must activate it in the Stripe Dashboard. Your use of Bancontact must be in accordance with Stripe’s Bancontact Terms of Service.

Before you Start

Please make sure you have followed Getting Started and know the basics.

Also, check it out our Demo Shop, place an test order,

It will help your understanding of the WorkFlow.

Installation & Setup

For installation, install & activate WooCommerce Stripe Payment Gateway and WC REST Payment - Stripe Gateway from you wp-admin Dashboard.

You can enable or disable it in your wp-admin Dashboard.

  1. Visit WooCommerce > Settings
  2. Click Payments tab
  3. Toggle the switch in Enabled column
  4. Click Save Changes
  5. Click Set Up and follow the instructions.

For help setting up and configuring, please refer to the user guide


Stripe Bancontact Workflow

Stripe users in Europe and the United States can accept Bancontact payments from customers in Belgium using Sources — a single integration path for creating payments using any supported method.

Here’s how Stripe Bancontact works WooCommerce and WC REST Payment.

  1. Create a Source object
  2. (Done by Customer) The customer complete authorization
  3. (Done Automatically) Charge the Source
  4. (Done Automatically) Confirm that the charge has succeeded

Let’s dive in!

Step 1: Create a Authorization URL for Source

If you have already created Source object using

Please skip to Step 2.

Otherwise, you need to created Source object using REST API.

URL HTTP payment_method
/wp-json/wc/v2/process_payment POST stripe_bancontact

Request

POST: /wp-json/wc/v2/process_payment

{
  "order_id": 65,
  "payment_method": "stripe_bancontact"
}
Parameter Description
order_id ID of an existing WooCommerce Order Object, without the #.
payment_method Each WooCommerce Payment Gateway has a unique ID. You can find the corresponding payment_method above.
stripe_source Optional, If your have already obtained Source, pass its ID with stripe_source. This will trigger WC REST Payment to process the payment immediately, instead of returning a Source Authentication URL.

Response

If the request was successful.

You will receive a response similar to the following.

{
    "code": 200,
    "message": "Payment Successful.",
    "data": {
        "result": "success",
        "redirect": "https://hooks.stripe.com/redirect/authenticate/src_1ECFVpKmJqjdvKCnXXXxxXXX?client_secret=src_client_secret_Efahl1iQhrBCXXXXXXXXXXXX"
    }
}

If ‘stripe_source’ was set in the request body, The redirect contains the url to Order Confirmation page.

If ‘stripe_source’ was NOT set in the request body, The redirect contains the url to Bancontact Authorization page.

If the request failed.

You will receive a response similar to the following.

{
    "code": 403,
    "message": "Order status is 'processing', meaning it had already received a successful payment. Duplicate payments to the order is not allowed. The allow status it is either 'pending' or 'failed'. ",
    "data": {
        "status": 400
    }
}

The message contains the error message and how to fix it.

Step 2: Redirect the customer to complete Authorization

Redirect your customer to the url returned above in redirect. Customer will provide authorization on Bancontact’s page (Don’t worry, they know how).

Step 3: Charge the Source

Upon authorization (or cancellation), the customer will be redirected back.

WC REST Payment will automatically charge the source.

Step 4: Confirm that the charge has succeeded

If the charge is successful,

  • Your customer will be automatically redirected a ‘Order Confirmation’ page.
  • Your WooCommerce Order status will be updated from pending to processing.

If the charge is unsuccessful,

  • Your customer will see the error on the checkout page
  • You will see the error on the WooCommerce -> Status -> Log,

Summary

That’s it! Easy right? Here’s a quick summary.

  1. Send a REST API POST Request to /wp-json/wc/v2/process_payment
  2. Include a JSON Body with order_id and process_payment as ‘stripe_bancontact’
  3. Redirect your customer to Bancontact for Authorization
  4. All done! The rest happens automatically!

Next Step

There’re a lot more Gateways that WC REST Payment supports!

Check out more WC REST Payment Gateways here!