/

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


MicroPayments - External API Add-on

Back to User Guides

Requirement

In order to use this add-on, you need to have the CM MicroPayments WordPress 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
  5. Charge wallet

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

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 plugin (MicroPayments) has to be activated in order for the add-on to work.

Check the article for the base plugin: CM MicroPayments (CMMP) - Installation


Set Up

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

Use: Check if there's enough points in a given wallet.
URL: your_domain/wp-json/cmmpexapi/v1/wallet_has_enough_points
Arguments:
  • wallet_id - name of the checked wallet OR email - email of user who has the checked wallet
  • points (required) - value of the points
  • key (required) - secure key

Examples:

  • your_domain/wp-json/cmmpexapi/v1/wallet_has_enough_points?wallet_id=123&points=10&key=abcde
  • your_domain/wp-json/cmmpexapi/v1/wallet_has_enough_points?email=john@doe.com&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_id - name of the checked wallet OR email - email of user who has the checked wallet
  • points - value of the points
  • key  - secure key

Examples

  • test.com/wp-json/cmmpexapi/v1/withdraw_wallet_points?wallet_id=123&points=10&key=abcde
  • test.com/wp-json/cmmpexapi/v1/withdraw_wallet_points?email=john@doe.com&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_id - ID of the checked wallet OR email - email of user who has the checked wallet
  • points - value of the points. A positive value (>0) adds points to the wallet; a negative value (<0) subtracts points from it
  • key - secure key

Examples

  • your_domain/wp-json/cmmpexapi/v1/charge_wallet?wallet_id=123&points=-10&key=abcde
  • your_domain/wp-json/cmmpexapi/v1/charge_wallet?email=john@doe.com&points=-10&key=abcde


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 CM MicroPayments WordPress  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