This module adds GraphQL functionality for the PAY. Magento2 plugin
- Description
- Requirements
- Installation
- Create Authorization token
- Usage And Examples
- Queries
- Mutations
- Types
- Support
PHP 7.2 or higher
PAY. Magento2 plugin 2.4.0 or higher
Tested up to Magento 2.4.3
On your server's command line, navigate to the installation directory of Magento2 and enter the following commands:
composer require paynl/magento2-graphql
php bin/magento setup:upgrade
php bin/magento cache:clean
The plugin is now installed and ready for use.
PAY. GraphQL requests require an ADMIN or INTEGRATION Authorization token to be used.
ADMIN Authorization token
You can create an ADMIN Authorization token by making a POST to the following REST url:
http://mymagento.com/rest/all/V1/integration/admin/token?username=MyName&password=MyPassword
An ADMIN Authorization token has a default lifetime of 1 hour, in order to extend the duration you can change this setting in the magento2 backend.
In the backend navigate to Stores
-> Configuration
-> Services
-> OAuth
and then expand the Access Token Expiration
tab, here you can change the duration of your ADMIN Authorization token.
INTEGRATION Authorization token (Magento 2.4.3 or lower only)
You can create an INTEGRATION token via the magento2 backend.
- Navigate to System -> Integrations.
- Then click "Add New Integration" at the top right of the screen.
- Enter a name for your new integration, and leave the other fields blank (they are optional).
- Then click "Save" at the top right of the screen.
- Now in the integration-list, click on
Activate
on your newly made integration. - Then click "Allow" at the top right of the screen.
- You will now be presented with several codes. Copy past the "Access Token" and Click Done.
To see how to use the queries, please check the samples folder.
This GraphQL library consists of queries, mutations and some other classes. They are explained below.
- paynlGetTransaction
Retrieve a PAY. transaction status based on the PAY order-ID.
This query expectspay_order_id
as an argument and returns a #paynlGetTransactionOutput
-
paynlStartTransaction
Start a transaction based on the Magento2 order-ID. This will return a URL with the PAY. transaction.
This mutation expectsorder_id
and optionallyreturn_url
. It will return type #PaynlStartTransactionOutput -
paynlFinishTransaction
This mutation closes the Magento quote when the transaction is marked as successfull and also returns the PAY. transaction info.
As argument it expects thepay_order_id
and returns type #paynlGetTransactionOutput
- paynlGetTransactionOutput
Variable | Type | Description |
---|---|---|
orderId | String | The PAY. order-ID. |
state | Int | The state number. |
stateName | String | The state name. |
currency | String | The currency used in the payment |
amount | String | The amount in cents. |
currenyAmount | String | The amount in cents in the currency. |
paidAmount | String | The paid amount in cents. |
paidCurrenyAmount | String | The paid amount in cents in the currency. |
refundAmount | String | The refunded amount in cents. |
refundCurrenyAmount | String | The refunded amount in cents in the currency. |
created | String | Date of creation. |
orderNumber | String | The order number given by Magento. |
isSuccess | Boolean | True, in case of a successfull payment. |
- PaynlStartTransactionOutput
Variable | Type | Description |
---|---|---|
redirectUrl | String | The PAY. payment URL |
Contact us: support@pay.nl