WordPress MicroPayments (CMMP) - Add-on - External API
WordPress MicroPayments - External API Add-on
Requirement
In order to use MicroPayments External API Add-on, you need to have the WordPress MicroPayments plugin installed and activated.
Table of Contents
- What is This Addon
- Installation
- Set Up
- How To Use This Add-on - Actions
- External wallet
- Response Format
What Is This Add-on
The MicroPayments External API Add-on allows you to connect your apps to MicroPayment wallets. This works by using WordPress REST API methods.
Allowed HTTPs requests
- GET
- POST
Supported actions
- Check if wallet has enough points
- Withdraw points
- Charge wallet
- Get points
- Get wallets
- Withdraw wallet points external
- Get wallet by name or nickname
- Get wallet
- Set points to currency ratio
- Get wallet transactions history
You can also allow external calls to the site to perform those actions (added in version 1.0.2)
This add-on is aimed at users with sufficient know-how to set up the API integration between a WordPress plugin and their apps.
Additional resources
Installation
Installing an add-on works just as installing a plugin. The only requirement is that the base WordPress MicroPayments plugin has to be activated in order for the add-on to work.
Check the article for the base plugin: WordPress MicroPayments (CMMP) - Installation
Setup
To start using the add-on, head to Admin Dashboard → CM Micropayment Platform → Settings → External API tab.
- Enable the "Open external API gateway" option to allow external requests, effectively enabling this add-on
- Click the "Generate secure key" button. You will use this key as an argument. Clicking on it again will generate a new one
How To Use This Add-on
This is the list of actions with their respective URLs and arguments.
Actions
1) Check if Wallet has Enough Points
- wallet (required) - name or nickname of the wallet
- points (required) - value of the points
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/wallet_has_enough_points?wallet=123&points=10&key=abcde
2) Withdraw Points
Use: Withdraw points from wallet. This can be useful if you want users to pay for an action such as viewing your page, downloading a file, sending a form etc.
URL: your_domain/wp-json/cmmpexapi/v1/withdraw_wallet_points
Arguments you need to pass:
- wallet (required) - name or nickname of the wallet
- points (required) - value of the points
- key (required) - secure key
Examples
- test.com/wp-json/cmmpexapi/v1/withdraw_wallet_points?wallet=123&points=10&key=abcde
3) Charge/Top up Wallet
Important: Note that, by using this API method, the points are not transferred anywhere. They are either created or removed altogether.
Uses: Can be used in two ways:
- Adding points to the wallet
- Subtracting points from the wallet
URL: your_domain/wp-json/cmmpexapi/v1/charge_wallet
Required arguments:
- wallet (required) - name or nickname of the wallet
- points (required) - value of the points. A positive value (>0) adds points to the wallet; a negative value (<0) subtracts points from it
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/charge_wallet?wallet=123&points=10&key=abcde
- your_domain/wp-json/cmmpexapi/v1/charge_wallet?wallet=123&points=-10&key=abcde
4) Get points
- email (required) - email of user who has the checked wallet
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/get_points?email=john@doe.com&key=abcde
5) Get wallets
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/get_wallets?key=abcde
6) Withdraw wallet points external
- wallet (required) - name or nickname of the wallet
- points (required) - value of the points
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/withdraw_wallet_points_external?wallet=123&points=10&key=abcde
7) Get wallet by name or nickname
- wallet (required) - name or nickname of the wallet
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/get_wallet_by_name?wallet=123&key=abcde
8) Get wallet by user email address
- email (required) - email of user who has the checked wallet
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/get_wallet?email=john@doe.com&key=abcde
9) Set points to currency ratio
Use: This can be useful if you want update points to currency ratio.
URL: your_domain/wp-json/cmmpexapi/v1/set_points_to_currency_ratio
Arguments you need to pass:
- ratio (required) - value of the ratio
- key (required) - secure key
Examples
- test.com/wp-json/cmmpexapi/v1/set_points_to_currency_ratio?ratio=2&key=abcde
10) Get wallet transactions history
- wallet (required) - name or nickname of the wallet
- key (required) - secure key
Examples:
- your_domain/wp-json/cmmpexapi/v1/get_wallet_transactions?wallet=123&key=abcde
External Wallets
Starting from version 1.0.2, it's possible to add calls from external site to manage wallets. This requires configuration in both server and client sides.
Setup 1) Server Side
Setup the External API credentials.
Head to Settings → External API. Here, check Open external API gateway and generate an API key.
- Generate the wallets
Setup 2) Client Side
Head to Settings → External wallet
- Past the API secure key that was just generated
- Enable external wallet
Add the URL of the main site including the http protocol. (Example: https://www.site.com)
This completes the configuration!
Checking Connection
You can check the connection at any time by pressing the button
When You Add Points
Every time you add points from the main site, you should refresh the state by pressing the button
Don't Close The Browser Window
If you have many wallets, refreshing the state might take several minutes.
Response Format
The response format is JSON.
- "success" - true or false
- "message" - explain what is wrong if "success" is false
Example
- {"success":false,"message":["Wallet doesn't have enough points"]}{"success":true,"message":[]}
- {"success":false,"message":["Please provide wallet id or email and points"]}
- {"success":false,"message":["Please provide a secure key"]}
More information about the WordPress MicroPayments plugin Other WordPress products can be found at CreativeMinds WordPress Store |
|
Let us know how we can Improve this Product Documentation Page To open a Support Ticket visit our support center |