MOLPayXDK 3.27.0

MOLPayXDK 3.27.0

测试已测试
Lang语言 Obj-CObjective C
许可 MIT
发布上次发布2024年4月

Clement 维护。



MOLPayXDK 3.27.0

  • MOLPay 移动部门

rms-mobile-xdk-cocoapods

这是完整的、可用的 Razer Merchant Services iOS 支付模块,可以通过 Cocoapods 框架实现到 Xcode 应用程序项目中。为 MOLPayXDK 框架集成提供了示例 Cocoapods 应用程序项目(示例)。

这是完整的功能性 Razer Merchant Services iOS 支付模块,可以通过 Cocoapods 框架集成到 Xcode 应用程序项目中。为 MOLPayXDK 框架集成提供了一个示例 Cocoapods 应用程序项目(示例)。

推荐配置

- Xcode version: 9 ++

- Minimum target version: iOS 8

安装

Objective-C 版本

Step 1 - Add pod 'MOLPayXDK', '~> <put latest release version here>' to the Podfile, then Pod install.

Step 2 - Add #import <MOLPayXDK/MOLPayLib.h>

Step 3 - Add <MOLPayLibDelegate> to @interface

Step 4 - Add -(void)transactionResult:(NSDictionary *)result for all delegate callbacks

Step 5 - Add 'App Transport Security Settings > Allow Arbitrary Loads > YES' to the application project info.plist

Step 6 - Add 'NSPhotoLibraryUsageDescription' > 'Payment images' to the application project info.plist

Step 7 - Add 'NSPhotoLibraryAddUsageDescription' > 'Payment images' to the application project info.plist

为 Swift 提供内容

Step 1 - Add pod 'MOLPayXDK', '~> <put latest release version here>' to the Podfile, then Pod install.

Step 2 - Create a bridging header file for MOLPay XDK Obj-c framework.
Then add the bridging header file to the Swift Compiler under Objective-C Bridging Header. (Refer https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html)

Step 3 - Add #import <MOLPayXDK/MOLPayLib.h> to the last line of the bridging header file.

Step 4 - Add MOLPayLibDelegate to the view controller class declaration

Step 5 - Add func transactionResult(_ result: [AnyHashable: Any]!) for all delegate callbacks

Step 6 - Add 'App Transport Security Settings > Allow Arbitrary Loads > YES' to the application project info.plist

Step 7 - Add 'NSPhotoLibraryUsageDescription' > 'Payment images' to the application project info.plist

Step 8 - Add 'NSPhotoLibraryAddUsageDescription' > 'Payment images' to the application project info.plist

准备支付详情对象

对于 Objective-C

NSDictionary * paymentRequestDict = @{
    // Optional, REQUIRED when use online Sandbox environment and account credentials.
    @"mp_dev_mode": [NSNumber numberWithBool:NO],

    // Mandatory String. Values obtained from MOLPay.
    @"mp_username": @"username",
    @"mp_password": @"password",
    @"mp_merchant_ID": @"merchantid",
    @"mp_app_name": @"appname",
    @"mp_verification_key": @"vkey123",

    // Mandatory String. Payment values.
    @"mp_amount": @"1.10", // Minimum 1.01
    @"mp_order_ID": @"orderid123",
    @"mp_currency": @"MYR",
    @"mp_country": @"MY",
    
    // Optional, but required payment values. User input will be required when values not passed.
    @"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.
    @"mp_bill_description": @"billdesc",
    @"mp_bill_name": @"billname",
    @"mp_bill_email": @"[email protected]",
    @"mp_bill_mobile": @"+1234567",

    // Optional, allow channel selection. 
    @"mp_channel_editing": [NSNumber numberWithBool:NO],

    // Optional, allow billing information editing.
    @"mp_editing_enabled": [NSNumber numberWithBool:NO],

    // Optional, for Escrow.
    @"mp_is_escrow": @"0", // Put "1" to enable escrow

    // Optional, for credit card BIN restrictions and campaigns.
    @"mp_bin_lock": [NSArray arrayWithObjects:@"414170", @"414171", nil],

    // Optional, for mp_bin_lock alert error.
    @"mp_bin_lock_err_msg": @"Only UOB allowed",
    
    // WARNING! FOR TRANSACTION QUERY USE ONLY, DO NOT USE THIS ON PAYMENT PROCESS.
    // Optional, provide a valid cash channel transaction id here will display a payment instruction screen. Required if mp_request_type is 'Receipt'.
    @"mp_transaction_id": @"",
    // Optional, use 'Receipt' for Cash channels, and 'Status' for transaction status query.
    @"mp_request_type": @"",

    // Optional, use this to customize the UI theme for the payment info screen, the original XDK custom.css file can be obtained at https://github.com/MOLPay/molpay-mobile-xdk-examples/blob/master/custom.css.
    @"mp_custom_css_url": [[NSBundle mainBundle] pathForResource:@"custom.css" ofType:nil],

    // Optional, set the token id to nominate a preferred token as the default selection, set "new" to allow new card only.
    @"mp_preferred_token": @"",

    // Optional, credit card transaction type, set "AUTH" to authorize the transaction.
    @"mp_tcctype": @"",

    // Optional, required valid credit card channel, set true to process this transaction through the recurring api, please refer the MOLPay Recurring API pdf. 
    @"mp_is_recurring": [NSNumber numberWithBool:NO],

    // Optional, show nominated channels.
    @"mp_allowed_channels": [NSArray arrayWithObjects:@"credit", @"credit3", nil],

    // Optional, simulate offline payment, set boolean value to enable. 
    @"mp_sandbox_mode": [NSNumber numberWithBool:YES],

    // Optional, required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen.
    @"mp_express_mode": [NSNumber numberWithBool:YES],

    // Optional, extended email format validation based on W3C standards.
    @"mp_advanced_email_validation_enabled": [NSNumber numberWithBool:YES],

    // Optional, extended phone format validation based on Google i18n standards.
    @"mp_advanced_phone_validation_enabled": [NSNumber numberWithBool:YES],

    // Optional, explicitly force disable user input.
    @"mp_bill_name_edit_disabled": [NSNumber numberWithBool:YES],
    @"mp_bill_email_edit_disabled": [NSNumber numberWithBool:YES],
    @"mp_bill_mobile_edit_disabled": [NSNumber numberWithBool:YES],
    @"mp_bill_description_edit_disabled": [NSNumber numberWithBool:YES],

    // Optional, EN, MS, VI, TH, FIL, MY, KM, ID, ZH.
    @"mp_language": @"EN",

    // Optional, Cash channel payment request expiration duration in hour.
    @"mp_cash_waittime": @"48",
    
    // Optional, allow bypass of 3DS on some credit card channels.
    @"mp_non_3DS": [NSNumber numberWithBool:YES],

    // Optional, disable card list option.
    @"mp_card_list_disabled": [NSArray arrayWithObjects:@"credit", nil],

    // Optional for channels restriction, this option has less priority than mp_allowed_channels.
    @"mp_disabled_channels": [NSArray arrayWithObjects:@"credit", nil]
};

对于 Swift

let paymentRequestDict: [String:Any] = [
    // Optional, REQUIRED when use online Sandbox environment and account credentials.
    "mp_dev_mode": NSNumber.init(booleanLiteral:false),

    // Mandatory String. Values obtained from MOLPay.
    "mp_username": "username",
    "mp_password": "password",
    "mp_merchant_ID": "merchantid",
    "mp_app_name": "appname",
    "mp_verification_key": "vkey123",

    // Mandatory String. Payment values.
    "mp_amount": "1.10", // Minimum 1.01
    "mp_order_ID": "orderid123",
    "mp_currency": "MYR",
    "mp_country": "MY",
    
    // Optional, but required payment values. User input will be required when values not passed.
    "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.
    "mp_bill_description": "billdesc",
    "mp_bill_name": "billname",
    "mp_bill_email": "[email protected]",
    "mp_bill_mobile": "+1234567",

    // Optional, allow channel selection. 
    "mp_channel_editing": NSNumber.init(booleanLiteral:false),

    // Optional, allow billing information editing.
    "mp_editing_enabled": NSNumber.init(booleanLiteral:false),

    // Optional, for Escrow.
    "mp_is_escrow": "0", // Put "1" to enable escrow

    // Optional, for credit card BIN restrictions and campaigns.
    "mp_bin_lock": ["414170", "414171"],    

    // Optional, for mp_bin_lock alert error.
    "mp_bin_lock_err_msg": "Only UOB allowed",
    
    // WARNING! FOR TRANSACTION QUERY USE ONLY, DO NOT USE THIS ON PAYMENT PROCESS.
    // Optional, provide a valid cash channel transaction id here will display a payment instruction screen. Required if mp_request_type is 'Receipt'.
    "mp_transaction_id": "",
    // Optional, use 'Receipt' for Cash channels, and 'Status' for transaction status query.
    "mp_request_type": "",

    // Optional, use this to customize the UI theme for the payment info screen, the original XDK custom.css file can be obtained at https://github.com/MOLPay/molpay-mobile-xdk-examples/blob/master/custom.css.
    "mp_custom_css_url": Bundle.main.path(forResource: "custom.css", ofType: nil)!,

    // Optional, set the token id to nominate a preferred token as the default selection, set "new" to allow new card only.
    "mp_preferred_token": "",

    // Optional, credit card transaction type, set "AUTH" to authorize the transaction.
    "mp_tcctype": "",

    // Optional, required valid credit card channel, set true to process this transaction through the recurring api, please refer the MOLPay Recurring API pdf. 
    "mp_is_recurring": NSNumber.init(booleanLiteral:false),

    // Optional, show nominated channels.
    "mp_allowed_channels": ["credit", "credit3"],

    // Optional, simulate offline payment, set boolean value to enable. 
    "mp_sandbox_mode": NSNumber.init(booleanLiteral:true),

    // Optional, required a valid mp_channel value, this will skip the payment info page and go direct to the payment screen.
    "mp_express_mode": NSNumber.init(booleanLiteral:true),

    // Optional, extended email format validation based on W3C standards.
    "mp_advanced_email_validation_enabled": NSNumber.init(booleanLiteral:true),

    // Optional, extended phone format validation based on Google i18n standards.
    "mp_advanced_phone_validation_enabled": NSNumber.init(booleanLiteral:true),

    // Optional, explicitly force disable user input.
    "mp_bill_name_edit_disabled": NSNumber.init(booleanLiteral:true),
    "mp_bill_email_edit_disabled": NSNumber.init(booleanLiteral:true),
    "mp_bill_mobile_edit_disabled": NSNumber.init(booleanLiteral:true),
    "mp_bill_description_edit_disabled": NSNumber.init(booleanLiteral:true),

    // Optional, EN, MS, VI, TH, FIL, MY, KM, ID, ZH.
    "mp_language": "EN",

    // Optional, Cash channel payment request expiration duration in hour.
    "mp_cash_waittime": 48,
    
    // Optional, allow bypass of 3DS on some credit card channels.
    "mp_non_3DS": NSNumber.init(booleanLiteral:true),

    // Optional, disable card list option.
    "mp_card_list_disabled": NSNumber.init(booleanLiteral:true),

    // Optional for channels restriction, this option has less priority than mp_allowed_channels.
    "mp_disabled_channels": ["credit"]        
]

启动支付模块

对于 Objective-C

MOLPayLib mp = [[MOLPayLib alloc] initWithDelegate:self andPaymentDetails:paymentRequestDict];

对于 Swift

let mp = MOLPayLib(delegate:self, andPaymentDetails: paymentRequestDict)

显示支付UI

针对 Objective-C

[self presentViewController:mp animated:NO completion:nil];

针对 Swift

self.present(nc, animated: false) {}

关闭支付模块

针对 Objective-C

[mp closemolpay];

针对 Swift

mp.closemolpay()

* Note: The host application needs to implement the MOLPay payment module manually upon getting a final callback from the close event.

支付模块回调

针对 Objective-C

- (void)transactionResult: (NSDictionary *)result

针对 Swift

func transactionResult(_ result: [AnyHashable: Any]!) {}

支付结果

=========================================
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.

现金渠道支付流程(如何操作?)

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内置校验和验证器注意事项

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. 

私有密钥校验和验证公式

chksum = MD5(mp_merchant_ID + results.msgType + results.txn_ID + results.amount + results.status_code + merchant_private_secret_key)

支持

向此存储库提交问题或发送电子邮件至我们的 [email protected]

商家技术支持/客户关怀: [email protected]
销售/分销商咨询: [email protected]
市场活动: [email protected]
渠道/合作伙伴咨询: [email protected]
媒体联系: [email protected]
R&D 和技术相关建议: [email protected]
滥用报告: [email protected]