WordPress MicroPayments (CMMP) - Add-on - External API


WordPress MicroPayments - External API Add-on

Back to User Guides

Requirement

In order to use MicroPayments External API Add-on, you need to have the WordPress MicroPayments plugin installed and activated.

Table of Contents

  1. What is This Addon
  2. Installation
  3. Set Up
  4. How To Use This Add-on - Actions
    1. Check if Wallet has Enough Points
    2. Withdraw points
    3. Charge/Top up Wallet
    4. Get points
    5. Get wallets
    6. Withdraw wallet points external
    7. Get wallet by name or nickname
    8. Get wallet
    9. Set points to currency ratio
    10. Get wallet transactions history
  5. External wallet
  6. 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.

External API settings - WordPress Wallet Plugin
External API settings
  • 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

Use: Check if there's enough points in a given wallet.
URL: your_domain/wp-json/cmmpexapi/v1/wallet_has_enough_points
Arguments:
  • 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:

  1. Adding points to the wallet
  2. 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

Use: for get points by user email address.
URL: your_domain/wp-json/cmmpexapi/v1/get_points
Arguments:
  • 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

Use: for get all wallets.
URL: your_domain/wp-json/cmmpexapi/v1/get_wallets
Arguments:
  • key (required) - secure key

Examples:

  • your_domain/wp-json/cmmpexapi/v1/get_wallets?key=abcde

6) Withdraw wallet points external

Use: for withdraw wallet points external.
URL: your_domain/wp-json/cmmpexapi/v1/withdraw_wallet_points_external
Arguments:
  • 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

Use: for get wallet by name or nickname.
URL: your_domain/wp-json/cmmpexapi/v1/get_wallet_by_name
Arguments:
  • 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

Use: for get wallet by user email address.
URL: your_domain/wp-json/cmmpexapi/v1/get_wallet
Arguments:
  • 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

Use: for get wallet transactions history.
URL: your_domain/wp-json/cmmpexapi/v1/get_wallet_transactions
Arguments:
  • 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

  1. Setup the External API credentials.

    Head to Settings → External API. Here, check Open external API gateway and generate an API key.

    Generating API secure key - WordPress Point System
    Generating API secure key
  2. Generate the wallets

Setup 2) Client Side

  1. Head to Settings → External wallet

    External wallet settings - Points and Rewards Plugin
    External wallet settings
  2. Past the API secure key that was just generated
  3. Enable external wallet
  4. Add the URL of the main site including the http protocol. (Example: https://www.site.com)

    Setting up the external wallets connection - WordPress User Wallet Credit System
    Setting up the external wallets connection

This completes the configuration!

Checking Connection

You can check the connection at any time by pressing the button

Testing the connection - WordPress MicroPayments
Testing the connection

When You Add Points

Every time you add points from the main site, you should refresh the state by pressing the button

Refreshing the state - WordPress Wallet Plugin
Refreshing the state

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
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.