Skip to content

Commit 3797a8f

Browse files
committed
update readme
1 parent 3c8e416 commit 3797a8f

File tree

1 file changed

+314
-51
lines changed

1 file changed

+314
-51
lines changed

Diff for: README.md

+314-51
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,53 @@ This is an Python SDK that maps some of the RESTful methods of Open API that are
1414
pip3 install rmsdk
1515
```
1616

17-
### Registration and obtain credentials
17+
### Prerequisite
1818

1919
Before using the SDK, users must obtain credentials from merchant portal first. Click [here](https://github.com/RevenueMonster/RM-API-SDK-Python/blob/master/docs/merchant-portal.md) for tutorial.
2020

21-
## Usage Examples
21+
22+
## Supported APIs
23+
24+
* Client Credentials (Authentication)
25+
* [Generate Client Credentials](#generate-client-credentials)
26+
* [Generate Refresh Token](#generate-refresh-token)
27+
* Merchant Related APIs
28+
* [Get Merchant Profile](#get-merchant-profile)
29+
* [Get Merchant Subscriptions](#get-merchant-subscriptions)
30+
* Store
31+
* [Get Store List](#get-store-list)
32+
* [Get Store By ID](#get-store-by-id)
33+
* [Create Store](#create-store)
34+
* [Update Store](#update-store)
35+
* [Delete Store](#delete-store)
36+
* User
37+
* [Get User Profile](#get-user-profile)
38+
* Payment (Quickpay QR)
39+
* [QuickPay](#quickpay)
40+
* [Refund](#refund)
41+
* [Reverse](#reverse)
42+
* [Get All Transactions](#get-all-transactions)
43+
* [Get Transaction By ID](#get-transaction-by-id)
44+
* [Get Transaction By Order ID](#get-transaction-by-order-id)
45+
* [Get Daily Settlement Report](#get-daily-settlement-report)
46+
* Payment (Transaction QR)
47+
* [Create Transaction](#create-transaction)
48+
* [Get Transaction](#get-transaction)
49+
* [Get Transaction By Code](#get-transaction-by-code)
50+
* [Get List of Transactions By Code](#get-list-of-transaction-by-code)
51+
* Loyalty
52+
* [Give Loyalty Point](#give-loyalty-point)
53+
* [Get Loyalty Member](#get-loyalty-member)
54+
* [Get List of Loyalty Members](#get-list-of-loyalty-members)
55+
* [Get Point History](#get-point-history)
56+
* Voucher
57+
* [Issue Voucher](#issue-voucher)
58+
* [Void Voucher](#void-voucher)
59+
* [Get Voucher By Code](#get-voucher-by-code)
60+
* [Get Voucher Batches](#get-voucher-batches)
61+
* [Get Voucher Batches By Batch Key](#get-voucher-batches-by-batch-key)
62+
63+
## Usage
2264

2365
This section explains the basic usage of the SDK. Detail usage for individual modules are prepared in the [examples](https://github.com/RevenueMonster/RM-API-SDK-Python/tree/master/examples) folder.
2466

@@ -27,14 +69,12 @@ A `dictionary` that contains `clientID`, `clientSecret`, `environment` and `priv
2769
For instance, to use the store module, simply,
2870

2971
```
30-
response = client.store.methodName(*args)
72+
response = client.module.methodName(*args)
3173
```
3274

33-
For full parameter, please refer [Revenue Monster Open API Documentation](doc.revenuemonster.my).
34-
35-
36-
### Authentication
75+
## Authentication
3776

77+
### Authenticate SDK
3878

3979
```
4080
from rmsdk import RMSDK
@@ -49,10 +89,110 @@ client = RMSDK(configs={
4989
accessToken, refreshToken = client.accessToken, client.refreshToken
5090
```
5191

52-
### Payment
92+
### Generate Client Credentials
93+
94+
To get refresh token and access token(expired after 2 hours) with using provided clientID and clientSecret.
95+
96+
```
97+
client = Auth({
98+
"environment": "sandbox", # or production
99+
"clientID": "client-id",
100+
"clientSecret": "client-secret",
101+
"privateKey": "path-to-private-key"
102+
})
103+
104+
accessToken, refreshToken = client.clientCredentials()
105+
```
106+
107+
### Generate Refresh Token
108+
109+
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.
110+
111+
```
112+
accessToken, refreshToken = client.getRefreshToken(refreshToken)
113+
```
114+
115+
## Merchant
116+
117+
### Get Merchant Profile
118+
119+
```
120+
result = client.merchant.getMerchantProfile(accessToken)
121+
```
122+
123+
### Get Merchant Subscriptions
124+
125+
```
126+
result = client.merchant.getMerchantSubcriptions(accessToken)
127+
```
128+
129+
## Store
130+
131+
### Get Store List
132+
133+
```
134+
result = client.store.getStores(accessToken)
135+
```
136+
137+
### Get Store By ID
138+
139+
```
140+
result = client.store.getStoreByID(accessToken, storeID)
141+
```
142+
143+
### Create Store
53144

54145
```
55-
quickpay_payload = {
146+
result = client.store.createStore(accessToken, {
147+
"name": "Test store",
148+
"addressLine1": "Earth",
149+
"addressLine2": "Mars",
150+
"postCode": "10001",
151+
"city": "Petaling Jaya",
152+
"state": "Selangor",
153+
"country": "Malaysia",
154+
"countryCode": "60",
155+
"phoneNumber": "377334080"
156+
})
157+
```
158+
159+
### Update Store
160+
161+
```
162+
result = client.store.updateStore(accessToken, storeID, {
163+
"name": "Test store",
164+
"addressLine1": "Earth",
165+
"addressLine2": "Mars",
166+
"postCode": "10001",
167+
"city": "Petaling Jaya",
168+
"state": "Selangor",
169+
"country": "Malaysia",
170+
"countryCode": "60",
171+
"phoneNumber": "377334080"
172+
})
173+
```
174+
175+
### Delete Store
176+
177+
```
178+
result = client.store.deleteStore(accessToken, storeID)
179+
```
180+
181+
## User
182+
183+
### Get User Profile
184+
185+
```
186+
result = client.user.getUserProfile(accessToken)
187+
```
188+
189+
## Payment (Quickpay QR)
190+
191+
192+
### QuickPay
193+
194+
```
195+
result = client.quickPay.quickPay(accessToken, {
56196
"authCode": "1234567890",
57197
"order": {
58198
"amount": 100,
@@ -65,45 +205,168 @@ quickpay_payload = {
65205
"ipAddress": "8.8.8.8",
66206
"terminalId": "19382734937293999",
67207
"storeId": "6170506694335521334"
68-
}
69-
70-
response = client.quickPay.quickPay(accessToken, quickpay_payload)
71-
```
72-
73-
For full examples, please visit the [examples](https://github.com/RevenueMonster/RM-API-SDK-Python/tree/master/examples) folder
74-
75-
76-
## Covered Functions
77-
78-
- [x] Client Credentials (Authentication)
79-
- [x] Refresh Token (Authentication)
80-
- [x] Get Merchant Profile
81-
- [x] Get Merchant Subscriptions
82-
- [x] Get Stores
83-
- [x] Get Stores By ID
84-
- [x] Create Store
85-
- [x] Update Store
86-
- [x] Delete Store
87-
- [x] Get User Profile
88-
- [x] Payment (Transaction QR) - Create Transaction QRCode/URL
89-
- [x] Payment (Transaction QR) - Get Transaction QRCode/URL
90-
- [x] Payment (Transaction QR) - Get Transaction QRCode/URL By Code
91-
- [x] Payment (Transaction QR) - Get Transactions By Code
92-
- [x] Payment (Quick Pay) - Payment
93-
- [x] Payment (Quick Pay) - Refund
94-
- [x] Payment (Quick Pay) - Reverse
95-
- [x] Payment (Quick Pay) - Get All Payment Transactions
96-
- [x] Payment (Quick Pay) - Get All Payment Transaction By ID
97-
- [x] Payment (Quick Pay) - Daily Settlement Report
98-
- [x] Give Loyalty Point
99-
- [x] Get Loyalty Members
100-
- [x] Get Loyalty Member
101-
- [x] Get Loyalty Member Point History
102-
- [x] Issue Voucher
103-
- [x] Void Voucher
104-
- [x] Get Voucher By Code
105-
- [x] Get Voucher Batches
106-
- [x] Get Voucher Batch By Key
107-
- [ ] Send Notification (Merchant)
108-
- [ ] Send Notification (Store)
109-
- [ ] Send Notification (User)
208+
})
209+
```
210+
211+
### Refund
212+
213+
```
214+
result = client.quickPay.refund(accessToken, {
215+
"transactionId": "190109042809010428940037",
216+
"refund": {
217+
"type": "FULL",
218+
"currencyType": "MYR",
219+
"amount": 100,
220+
},
221+
"reason": "test"
222+
})
223+
```
224+
225+
### Reverse
226+
227+
```
228+
result = client.quickPay.reverse(accessToken, {
229+
"orderId": "111222333"
230+
})
231+
```
232+
233+
### Get All Transactions
234+
235+
```
236+
result = client.quickPay.getAllTransactions(accessToken)
237+
```
238+
239+
### Get Transaction By ID
240+
241+
```
242+
result = client.quickPay.getTransactionByID(accessToken, transactionID)
243+
```
244+
245+
### Get Transaction By Order ID
246+
247+
```
248+
result = client.quickPay.getTransactionByOrder(accessToken, orderID)
249+
```
250+
251+
### Get Daily Settlement Report
252+
253+
```
254+
result = client.quickPay.dailySettlementReport(accessToken, {
255+
"date": "2019-01-09",
256+
"method": "WECHATPAY",
257+
"region": "MALAYSIA",
258+
"sequence": 1
259+
})
260+
```
261+
262+
## Payment (Transaction QR)
263+
264+
### Create Transaction
265+
266+
```
267+
result = client.transaction.createTransaction(accessToken, {
268+
"amount": 100,
269+
"currencyType": "MYR",
270+
"expiry": {
271+
"type": "PERMANENT"
272+
},
273+
"isPreFillAmount": True,
274+
"method": ['WECHATPAY'],
275+
"order": {
276+
"details": "Test",
277+
"title": "Title"
278+
},
279+
"redirectUrl": 'https://www.revenuemonster.com',
280+
"storeId": '1981039839353524638',
281+
"type": 'DYNAMIC',
282+
})
283+
```
284+
285+
### Get Transaction
286+
287+
```
288+
result = client.transaction.getTransaction(accessToken)
289+
```
290+
291+
### Get Transaction By Code
292+
293+
```
294+
result = client.transaction.getTransactionByCode(accessToken, qrCode)
295+
```
296+
297+
### Get List of Transactions By Code
298+
299+
```
300+
result = client.transaction.getTransactionByCode(accessToken, qrCode)
301+
```
302+
303+
304+
## Loyalty
305+
306+
### Give Loyalty Point
307+
308+
```
309+
result = client.loyalty.giveLoyaltyPoint(accessToken, {
310+
"point": 100,
311+
"type": "ID",
312+
"memberId": "7765269777796630408",
313+
"countryCode": "60",
314+
"phoneNumber": "172826990"
315+
})
316+
```
317+
318+
### Get Loyalty Member
319+
320+
```
321+
result = client.loyalty.getLoyaltyMember(accessToken, memberID)
322+
```
323+
324+
### Get List of Loyalty Members
325+
326+
```
327+
result = client.loyalty.getLoyaltyMembers(accessToken)
328+
```
329+
330+
### Get Point History
331+
332+
Get Loyalty point history of a member
333+
334+
```
335+
result = client.loyalty.getLoyaltyMemberPointHistory(accessToken, memberID)
336+
```
337+
338+
## Voucher
339+
340+
### Issue Voucher
341+
342+
```
343+
result = client.voucher.issueVoucher(accessToken, batchKey)
344+
```
345+
346+
### Void Voucher
347+
348+
```
349+
result = client.voucher.voidVoucher(accessToken, voucherCode)
350+
```
351+
352+
### Get Voucher By Code
353+
354+
```
355+
result = client.voucher.getVoucherByCode(accessToken, voucherCode)
356+
```
357+
358+
### Get Voucher Batches
359+
360+
```
361+
result = client.voucher.getVoucherBatches(accessToken)
362+
```
363+
364+
### Get Voucher Batches By Batch Key
365+
366+
```
367+
result = client.voucher.getVoucherBatchByKey(accessToken, batchKey)
368+
```
369+
370+
371+
Detail examples can be found at [examples](https://github.com/RevenueMonster/RM-API-SDK-Python/tree/master/examples).
372+

0 commit comments

Comments
 (0)