This is an Python SDK that maps some of the RESTful methods of Open API that are documented at Revenue Monster Open API Documentation.
pip3 install rmsdk
Before using the SDK, users must obtain credentials from merchant portal first. Click here for tutorial.
- Client Credentials (Authentication)
- Merchant Related APIs
- Store
- User
- Payment (Quickpay QR)
- Payment (Transaction QR)
- Loyalty
- Voucher
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)
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
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()
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)
result = client.merchant.getMerchantProfile(accessToken)
result = client.merchant.getMerchantSubcriptions(accessToken)
result = client.store.getStores(accessToken)
result = client.store.getStoreByID(accessToken, storeID)
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"
})
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"
})
result = client.store.deleteStore(accessToken, storeID)
result = client.user.getUserProfile(accessToken)
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"
})
result = client.quickPay.refund(accessToken, {
"transactionId": "190109042809010428940037",
"refund": {
"type": "FULL",
"currencyType": "MYR",
"amount": 100,
},
"reason": "test"
})
result = client.quickPay.reverse(accessToken, {
"orderId": "111222333"
})
result = client.quickPay.getAllTransactions(accessToken)
result = client.quickPay.getTransactionByID(accessToken, transactionID)
result = client.quickPay.getTransactionByOrder(accessToken, orderID)
result = client.quickPay.dailySettlementReport(accessToken, {
"date": "2019-01-09",
"method": "WECHATPAY",
"region": "MALAYSIA",
"sequence": 1
})
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',
})
result = client.transaction.getTransaction(accessToken)
result = client.transaction.getTransactionByCode(accessToken, qrCode)
result = client.transaction.getTransactionByCode(accessToken, qrCode)
result = client.loyalty.giveLoyaltyPoint(accessToken, {
"point": 100,
"type": "ID",
"memberId": "7765269777796630408",
"countryCode": "60",
"phoneNumber": "172826990"
})
result = client.loyalty.getLoyaltyMember(accessToken, memberID)
result = client.loyalty.getLoyaltyMembers(accessToken)
Get Loyalty point history of a member
result = client.loyalty.getLoyaltyMemberPointHistory(accessToken, memberID)
result = client.voucher.issueVoucher(accessToken, batchKey)
result = client.voucher.voidVoucher(accessToken, voucherCode)
result = client.voucher.getVoucherByCode(accessToken, voucherCode)
result = client.voucher.getVoucherBatches(accessToken)
result = client.voucher.getVoucherBatchByKey(accessToken, batchKey)
Detail examples can be found at examples.