Skip to main content

RM-API-SDK-Python

image0 image1 image2

This is an Python SDK that maps some of the RESTful methods of Open API that are documented at Revenue Monster Open API Documentation.

Getting Started

Installation

pip3 install rmsdk

Prerequisite

Before using the SDK, users must obtain credentials from merchant portal first. Click here for tutorial.

Supported APIs

Usage

This section explains the basic usage of the SDK. Detail usage for individual modules are prepared in the examples folder.

A dictionary that contains clientID, clientSecret, environment and privateKey (path to private key) is expected to passed in as argument. An object of the RMSDK class will be instantiated. All modules covered in this SDK will be available under the instantiated object.

For instance, to use the store module, simply,

response = client.module.methodName(*args)

Authentication

Authenticate SDK

from rmsdk import RMSDK

client = RMSDK(configs={
    "environment": "sandbox", # or production
    "clientID": "client-id",
    "clientSecret": "client-secret",
    "privateKey": "path-to-private-key"
})

accessToken, refreshToken = client.accessToken, client.refreshToken

Generate Client Credentials

To get refresh token and access token(expired after 2 hours) with using provided clientID and clientSecret.

client = Auth({
    "environment": "sandbox", # or production
    "clientID": "client-id",
    "clientSecret": "client-secret",
    "privateKey": "path-to-private-key"
})

accessToken, refreshToken = client.clientCredentials()

Generate Refresh Token

To get new access token(expired after 2 hours) with using provided clientId and clientSecret (recommended to schedule to run this fucntion on every less than 2 hours) in order to avoid expired access token error.

accessToken, refreshToken = client.getRefreshToken(refreshToken)

Merchant

Get Merchant Profile

result = client.merchant.getMerchantProfile(accessToken)

Get Merchant Subscriptions

result = client.merchant.getMerchantSubcriptions(accessToken)

Store

Get Store List

result = client.store.getStores(accessToken)

Get Store By ID

result = client.store.getStoreByID(accessToken, storeID)

Create Store

result = client.store.createStore(accessToken, {
    "name": "Test store",
    "addressLine1": "Earth",
    "addressLine2": "Mars",
    "postCode": "10001",
    "city": "Petaling Jaya",
    "state": "Selangor",
    "country": "Malaysia",
    "countryCode": "60",
    "phoneNumber": "377334080"
})

Update Store

result = client.store.updateStore(accessToken, storeID, {
    "name": "Test store",
    "addressLine1": "Earth",
    "addressLine2": "Mars",
    "postCode": "10001",
    "city": "Petaling Jaya",
    "state": "Selangor",
    "country": "Malaysia",
    "countryCode": "60",
    "phoneNumber": "377334080"
})

Delete Store

result = client.store.deleteStore(accessToken, storeID)

User

Get User Profile

result = client.user.getUserProfile(accessToken)

Payment (Quickpay QR)

QuickPay

result = client.quickPay.quickPay(accessToken, {
    "authCode": "1234567890",
    "order": {
        "amount": 100,
        "currencyType":"MYR",
        "id":"1312331232",
        "title":"title",
        "detail":"desc",
        "additonalData":"API Test"
   },
    "ipAddress": "8.8.8.8",
    "terminalId": "19382734937293999",
    "storeId": "6170506694335521334"
})

Refund

result = client.quickPay.refund(accessToken, {
    "transactionId": "190109042809010428940037",
    "refund": {
        "type": "FULL",
        "currencyType": "MYR",
        "amount": 100,
    },
    "reason": "test"
})

Reverse

result = client.quickPay.reverse(accessToken, {
    "orderId": "111222333"
})

Get All Transactions

result = client.quickPay.getAllTransactions(accessToken)

Get Transaction By ID

result = client.quickPay.getTransactionByID(accessToken, transactionID)

Get Transaction By Order ID

result = client.quickPay.getTransactionByOrder(accessToken, orderID)

Get Daily Settlement Report

result = client.quickPay.dailySettlementReport(accessToken, {
    "date": "2019-01-09",
    "method": "WECHATPAY",
    "region": "MALAYSIA",
    "sequence": 1
})

Payment (Transaction QR)

Create Transaction

result = client.transaction.createTransaction(accessToken, {
    "amount": 100,
    "currencyType": "MYR",
    "expiry": {
        "type": "PERMANENT"
    },
    "isPreFillAmount": True,
    "method": ['WECHATPAY'],
    "order": {
        "details": "Test",
        "title": "Title"
    },
    "redirectUrl": 'https://www.revenuemonster.com',
    "storeId": '1981039839353524638',
    "type": 'DYNAMIC',
})

Get Transaction

result = client.transaction.getTransaction(accessToken)

Get Transaction By Code

result = client.transaction.getTransactionByCode(accessToken, qrCode)

Get List of Transactions By Code

result = client.transaction.getTransactionByCode(accessToken, qrCode)

Loyalty

Give Loyalty Point

result = client.loyalty.giveLoyaltyPoint(accessToken, {
    "point": 100,
    "type": "ID",
    "memberId": "7765269777796630408",
    "countryCode": "60",
    "phoneNumber": "172826990"
})

Get Loyalty Member

result = client.loyalty.getLoyaltyMember(accessToken, memberID)

Get List of Loyalty Members

result = client.loyalty.getLoyaltyMembers(accessToken)

Get Point History

Get Loyalty point history of a member

result = client.loyalty.getLoyaltyMemberPointHistory(accessToken, memberID)

Voucher

Issue Voucher

result = client.voucher.issueVoucher(accessToken, batchKey)

Void Voucher

result = client.voucher.voidVoucher(accessToken, voucherCode)

Get Voucher By Code

result = client.voucher.getVoucherByCode(accessToken, voucherCode)

Get Voucher Batches

result = client.voucher.getVoucherBatches(accessToken)

Get Voucher Batches By Batch Key

result = client.voucher.getVoucherBatchByKey(accessToken, batchKey)

Detail examples can be found at examples.

Metadata

Release files for rmsdk 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rmsdk 1.0.1
File Size Uploaded Provenance Actions
rmsdk-1.0.1.tar.gz 11.9 kB Without provenance Details for rmsdk-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rmsdk 1.0.1
File Interpreter ABI Platform Actions
rmsdk-1.0.1-py3-none-any.whl Python 3 none any Details for rmsdk-1.0.1-py3-none-any.whl

Total release size: 25.5 kB

Release files / rmsdk-1.0.1.tar.gz

Download URL rmsdk-1.0.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c7ecac3efdd5869cb521e9d9acc182240dd4aa27807e7e293431b9aad186633c
BLAKE2b-256 checksum
How to use checksums
ba1be200677c370f7c6f18ad5391e368612f6f4967aeb673d4e97bec5fda4a45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / rmsdk-1.0.1-py3-none-any.whl

Download URL rmsdk-1.0.1-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e8a91b984d21320a1e2b5b11d0bd78e2fa03fea305c8620bc6f44d11ba86bed
BLAKE2b-256 checksum
How to use checksums
5f9fc2e31121f6fd1097b0c6633900754940671aff0b57cb8dd61e637424b833
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Security for rmsdk 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page