forked from RazerMS/Mobile-XDK-RazerMS_Android_Studio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md
193 lines (129 loc) · 10.2 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!--
# license: Copyright © 2011-2016 MOLPay Sdn Bhd. All Rights Reserved.
-->
<img src="https://user-images.githubusercontent.com/38641542/39353138-654385dc-4a39-11e8-9710-19e5f03ec62e.jpg">
# molpay-mobile-xdk-android
This is the complete and functional MOLPay Android payment module that is ready to be implemented into Android Studio through gradle from JCenter/Maven repository as a MOLPayXDK module. An example application project
(MOLPayXdkExample) is provided for MOLPayXDK framework integration reference.
这是一个完整和实用的MOLPay安卓支付模块,可以通过JCenter/Maven存储库中的gradle实现到Android Studio以作为一个MOLPayXDK框架。在此提供了一个示例应用程序项目(MOLPayXdkExample)以作为MOLPayXDK框架整合的参考。
## Recommended configurations
- Minimum Android SDK Version: 25 ++
- Minimum Android API level: 19 ++
- Minimum Android target version: Android 4.4
## Installation
Step 1 - Add compile 'com.molpay:molpay-mobile-xdk-android:<put latest release version here>' to dependencies in application build.gradle
Step 2 - Add import com.molpay.molpayxdk.MOLPayActivity;
Step 3 - Add the result callback function to get return results when the payment activity ended,
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == MOLPayActivity.MOLPayXDK && resultCode == RESULT_OK){
Log.d(MOLPayActivity.MOLPAY, "MOLPay result = "+data.getStringExtra(MOLPayActivity.MOLPayTransactionResult));
}
}
=========================================
Sample transaction result in JSON string:
=========================================
{"status_code":"11","amount":"1.01","chksum":"34a9ec11a5b79f31a15176ffbcac76cd","pInstruction":0,"msgType":"C6","paydate":1459240430,"order_id":"3q3rux7dj","err_desc":"","channel":"Credit","app_code":"439187","txn_ID":"6936766"}
Parameter and meaning:
"status_code" - "00" for Success, "11" for Failed, "22" for *Pending.
(*Pending status only applicable to cash channels only)
"amount" - The transaction amount
"paydate" - The transaction date
"order_id" - The transaction order id
"channel" - The transaction channel description
"txn_ID" - The transaction id generated by MOLPay
* Notes: You may ignore other parameters and values not stated above
=====================================
* Sample error result in JSON string:
=====================================
{"Error":"Communication Error"}
Parameter and meaning:
"Communication Error" - Error starting a payment process due to several possible reasons, please contact MOLPay support should the error persists.
1) Internet not available
2) API credentials (username, password, merchant id, verify key)
3) MOLPay server offline.
## Prepare the Payment detail object
HashMap<String, Object> paymentDetails = new HashMap<>();
// Mandatory String. A value not less than '1.00'
paymentDetails.put(MOLPayActivity.mp_amount, "1.10");
// Mandatory String. Values obtained from MOLPay
paymentDetails.put(MOLPayActivity.mp_username, "username");
paymentDetails.put(MOLPayActivity.mp_password, "password");
paymentDetails.put(MOLPayActivity.mp_merchant_ID, "merchantid");
paymentDetails.put(MOLPayActivity.mp_app_name, "appname");
paymentDetails.put(MOLPayActivity.mp_verification_key, "vkey123");
// Mandatory String. Payment values
paymentDetails.put(MOLPayActivity.mp_order_ID, "orderid123");
paymentDetails.put(MOLPayActivity.mp_currency, "MYR");
paymentDetails.put(MOLPayActivity.mp_country, "MY");
// Optional String.
paymentDetails.put(MOLPayActivity.mp_channel, "multi"); // Use 'multi' for all available channels option. For individual channel seletion, please refer to https://github.com/MOLPay/molpay-mobile-xdk-examples/blob/master/channel_list.tsv.
paymentDetails.put(MOLPayActivity.mp_bill_description, "billdesc");
paymentDetails.put(MOLPayActivity.mp_bill_name, "billname");
paymentDetails.put(MOLPayActivity.mp_bill_email, "email@domain.com");
paymentDetails.put(MOLPayActivity.mp_bill_mobile, "+1234567");
paymentDetails.put(MOLPayActivity.mp_channel_editing, false); // Option to allow channel selection.
paymentDetails.put(MOLPayActivity.mp_editing_enabled, false); // Option to allow billing information editing.
// Optional for Escrow
paymentDetails.put(MOLPayActivity.mp_is_escrow, ""); // Put "1" to enable escrow
// Optional for credit card BIN restrictions
String binlock[] = {"414170","414171"};
paymentDetails.put(MOLPayActivity.mp_bin_lock, binlock);
paymentDetails.put(MOLPayActivity.mp_bin_lock_err_msg, "Only UOB allowed");
// For transaction request use only, do not use this on payment process
paymentDetails.put(MOLPayActivity.mp_transaction_id, "");
// Optional, provide a valid cash channel transaction id here will display a payment instruction screen.
paymentDetails.put(MOLPayActivity.mp_request_type, "");
// Optional, use this to customize the UI theme for the payment info screen, the original XDK custom.css file is provided at Example project source for reference and implementation.
paymentDetails.put(MOLPayActivity.mp_custom_css_url, "file:///android_asset/custom.css");
// Optional, set the token id to nominate a preferred token as the default selection, set "new" to allow new card only
paymentDetails.put(MOLPayActivity.mp_preferred_token, "");
// Optional, credit card transaction type, set "AUTH" to authorize the transaction
paymentDetails.put(MOLPayActivity.mp_tcctype, "");
// Optional, set true to process this transaction through the recurring api, please refer the MOLPay Recurring API pdf
paymentDetails.put(MOLPayActivity.mp_is_recurring, false);
// Optional for channels restriction
String allowedchannels[] = {"credit","credit3"};
paymentDetails.put(MOLPayActivity.mp_allowed_channels, allowedchannels);
// Optional for sandboxed development environment, set boolean value to enable.
paymentDetails.put(MOLPayActivity.mp_sandbox_mode, true);
// Optional, required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen.
paymentDetails.put(MOLPayActivity.mp_express_mode, true);
// Optional, enable this for extended email format validation based on W3C standards.
paymentDetails.put(MOLPayActivity.mp_advanced_email_validation_enabled, true);
// Optional, enable this for extended phone format validation based on Google i18n standards.
paymentDetails.put(MOLPayActivity.mp_advanced_phone_validation_enabled, true);
// Optional, explicitly force disable billing name edit.
paymentDetails.put(MOLPayActivity.mp_bill_name_edit_disabled, true);
// Optional, explicitly force disable billing email edit.
paymentDetails.put(MOLPayActivity.mp_bill_email_edit_disabled, true);
// Optional, explicitly force disable billing mobile edit.
paymentDetails.put(MOLPayActivity.mp_bill_mobile_edit_disabled, true);
// Optional, explicitly force disable billing description edit.
paymentDetails.put(MOLPayActivity.mp_bill_description_edit_disabled, true);
// Optional, EN, MS, VI, TH, FIL, MY, KM, ID, ZH.
paymentDetails.put(MOLPayActivity.mp_language, "EN");
// Optional, enable for online sandbox testing.
paymentDetails.put(MOLPayActivity.mp_dev_mode, false);
## Start the payment module
startActivityForResult(intent, MOLPayActivity.MOLPayXDK);
## Cash channel payment process (How does it work?)
This is how the cash channels work on XDK:
1) The user initiate a cash payment, upon completed, the XDK will pause at the “Payment instruction” screen, the results would return a pending status.
2) The user can then click on “Close” to exit the MOLPay XDK aka the payment screen.
3) When later in time, the user would arrive at say 7-Eleven to make the payment, the host app then can call the XDK again to display the “Payment Instruction” again, then it has to pass in all the payment details like it will for the standard payment process, only this time, the host app will have to also pass in an extra value in the payment details, it’s the “mp_transaction_id”, the value has to be the same transaction returned in the results from the XDK earlier during the completion of the transaction. If the transaction id provided is accurate, the XDK will instead show the “Payment Instruction" in place of the standard payment screen.
4) After the user done the paying at the 7-Eleven counter, they can close and exit MOLPay XDK by clicking the “Close” button again.
## XDK built-in checksum validator caveats
All XDK come with a built-in checksum validator to validate all incoming checksums and return the validation result through the "mp_secured_verified" parameter. However, this mechanism will fail and always return false if merchants are implementing the private secret key (which the latter is highly recommended and prefereable.) If you would choose to implement the private secret key, you may ignore the "mp_secured_verified" and send the checksum back to your server for validation.
## Private Secret Key checksum validation formula
chksum = MD5(mp_merchant_ID + results.msgType + results.txn_ID + results.amount + results.status_code + merchant_private_secret_key)
## Support
Submit issue to this repository or email to our support@molpay.com
Merchant Technical Support / Customer Care : support@molpay.com<br>
Sales/Reseller Enquiry : sales@molpay.com<br>
Marketing Campaign : marketing@molpay.com<br>
Channel/Partner Enquiry : channel@molpay.com<br>
Media Contact : media@molpay.com<br>
R&D and Tech-related Suggestion : technical@molpay.com<br>
Abuse Reporting : abuse@molpay.com