-
Notifications
You must be signed in to change notification settings - Fork 53
REST Integration
For frontend purposes, we recommend that you use the GraphQL integration, which is more fleshed out.
To integrate the Mollie extension with a PWA using REST, we added 2 endpoints to the normal Magento 2 checkout flow.
This is a normal flow:
- Create cart
- Add products
- Set shipping information
- Place order
When using Mollie the order flow looks like this:
- Create cart
- Add products
- Set shipping information
- Create payment token
- Place order
- Start transaction
To create a payment token you should do a GET request to the applicable endpoint:
GET /V1/carts/mine/mollie/payment-token
GET /V1/guest-carts/:cartId/mollie/payment-token
This will return a random 32 character string:
TumUZulyLVk16boibN59euvSr1Quh6hR
Next, after placing the order, do a POST request to the endpoint with the payment token:
POST /V1/mollie/transaction/start
{
"token": "TumUZulyLVk16boibN59euvSr1Quh6hR"
}
The response will be the redirect URL. You should redirect your user to this URL:
https://www.mollie.com/payscreen/order/checkout/rhdz9w
This page will handle the payment and redirect your user back to your webshop. By default, the URL of the Magento installation is used, but in most cases, you'll want to provide a custom URL.
You can enter one under
Stores -> Configuration -> Sales -> Payment Methods -> Mollie -> General -> Use custom redirect url?
.
After the order is placed, you can retrieve its details. You can do this by using the value of the {{order_hash}}
, which gets appended to your custom URL:
GET /V1/mollie/get-order/<hash-value>
To retrieve a list of recurring orders, you can use this endpoint:
GET /V1/mollie/orders/recurring
This endpoint uses the SearchCriteriaInteface
so you can filter and sort however you like.
Note: For this endpoint you need backend authentication, which differs from the other endpoints in this document.
The Mollie Payments extension is developed by Magmodules.