Myclear
A unofficial myclear ruby gem.
Myclear official document: https://fpxexchange.myclear.org.my:8443/MerchantIntegrationKit/
note:Password is required when accessing the official document, please go to Myclear for the password.
Installation
Add this line to your application's Gemfile:
gem 'myclear'
or
gem 'myclear', github: 'lanceyb/myclear'
And then execute:
$ bundle
Or install it yourself as:
$ gem install myclear
Configuration
Myclear.fpx_version = '7.0'
Myclear.seller_exchange_id = 'YOUR SELLER EXCHANGE ID'
Myclear.seller_id = 'YOUR SELLER ID'
Myclear.private_key = 'YOUR RSA PRIVATE KEY'
Myclear.fpx_certification = 'THE FPX CERTIFICATION'
# Myclear.debug_mode = true # Enable parameter check. Default is true.
# Myclear.fpx_standby_certification = 'THE STANDBY FPX CERTIFICATIO
eg:
if Rails.env.production?
Myclear.fpx_version = '7.0'
Myclear.seller_exchange_id = 'YOUR SELLER EXCHANGE ID'
Myclear.seller_id = 'YOUR SELLER ID'
Myclear.private_key = 'YOUR RSA PRIVATE KEY'
Myclear.fpx_certification = 'THE FPX CERTIFICATION'
else
Myclear.fpx_version = '7.0'
Myclear.seller_exchange_id = 'EX00000000'
Myclear.seller_id = 'SE00000000'
Myclear.private_key = File.read(File.('./EX00000000.key', Rails.root))
Myclear.fpx_certification = File.read(File.('./fpxuat.cer', Rails.root))
end
Service
bank list(银行列表)
Myclear::Service.bank_list_enquiry
Authorization Request(申请支付)
Myclear::Service.authorization_request_params({ARGUMENTS})
Example
Myclear::Service.({
fpx_msgToken: '01',
fpx_sellerExOrderNo: 'EXORDERNO0000',
fpx_sellerTxnTime: '20170817140102',
fpx_sellerOrderNo: 'ORDERNO000000',
fpx_txnCurrency: 'MYR',
fpx_txnAmount: '1.00',
fpx_buyerEmail: '[email protected]',
fpx_buyerName: '',
fpx_buyerBankId: 'TEST0021',
fpx_buyerBankBranch: 'SBI BANK A',
fpx_buyerAccNo: '',
fpx_buyerId: '',
fpx_makerName: '',
fpx_buyerIban: '',
fpx_productDesc: '1 goods'
})
Arugments
Key | Allow Blank | Description |
---|---|---|
fpx_msgToken | N | Indicate business model. 01 - B2C / 02 - B2B1 / 03 - B2B2 |
fpx_sellerExOrderNo | N | Unique ID generate by Exchange for each transaction originating form an Exchange. Not Supported: Ampersan (&) and Apostrophe ('). |
fpx_sellerTxnTime | N | Date and time transaction originated from Merchant. YYYYMMDDHHmmSS (in MYT). |
fpx_sellerOrderNo | N | Order number generated by Merchant. Not Supported: Ampersan (&) and Apostrophe ('). |
fpx_txnCurrency | N | Transaction currency. Default value = MYR |
fpx_txnAmount | N | Total amount. |
fpx_buyerEmail | Y | Buyer email address. Allow blank. |
fpx_buyerName | Y | Buyer name. Allow blank. |
fpx_buyerBankId | N | Provided by FPX - ties to Bank that Buyer has an account in. |
fpx_buyerBankBranch | N | Bank's branch code that Buyer opened his account. Not Supported: Slash(/), Ampesand(&) and Apostrophe('). |
fpx_buyerAccNo | Y | Buyer account number |
fpx_buyerId | Y | Buyer identification number. Not Supported: Slash(/), Ampersand(&) and Apostrophe('). |
fpx_makerName | Y | Buyer representative (Maker) who initiate the transaction. |
pfx_buyerIban | Y | Buyer IBAN |
fpx_productDesc | Y | Product Description |
Authorization Enquiry
Myclear::Service.authorization_enquiry({ARGUMENTS})
Example
Myclear::Service.({
fpx_msgToken: '01',
fpx_sellerExOrderNo: 'EXORDERNO0000',
fpx_sellerTxnTime: '20170817140102',
fpx_sellerOrderNo: 'ORDERNO000000',
fpx_txnCurrency: 'MYR',
fpx_txnAmount: '1.00',
fpx_buyerEmail: '[email protected]',
fpx_buyerName: '',
fpx_buyerBankId: 'TEST0021',
fpx_buyerBankBranch: 'SBI BANK A',
fpx_buyerAccNo: '',
fpx_buyerId: '',
fpx_makerName: '',
fpx_buyerIban: '',
fpx_productDesc: '1 goods'
})
note : 请求AE接口的参数,保持与AR时一致
Arugments
Key | Allow Blank | Description |
---|---|---|
fpx_msgToken | N | Indicate business model. 01 - B2C / 02 - B2B1 / 03 - B2B2 |
fpx_sellerExOrderNo | N | Unique ID generate by Exchange for each transaction originating form an Exchange. Not Supported: Ampersan (&) and Apostrophe ('). |
fpx_sellerTxnTime | N | Date and time transaction originated from Merchant. YYYYMMDDHHmmSS (in MYT). |
fpx_sellerOrderNo | N | Order number generated by Merchant. Not Supported: Ampersan (&) and Apostrophe ('). |
fpx_txnCurrency | N | Transaction currency. Default value = MYR |
fpx_txnAmount | N | Total amount. |
fpx_buyerEmail | Y | Buyer email address. Allow blank. |
fpx_buyerName | Y | Buyer name. Allow blank. |
fpx_buyerBankId | N | Provided by FPX - ties to Bank that Buyer has an account in. |
fpx_buyerBankBranch | N | Bank's branch code that Buyer opened his account. Not Supported: Slash(/), Ampesand(&) and Apostrophe('). |
fpx_buyerAccNo | Y | Buyer account number |
fpx_buyerId | Y | Buyer identification number. Not Supported: Slash(/), Ampersand(&) and Apostrophe('). |
fpx_makerName | Y | Buyer representative (Maker) who initiate the transaction. |
pfx_buyerIban | Y | Buyer IBAN |
fpx_productDesc | Y | Product Description |
Verify callback(验证回调)
Myclear::Service.verify_params(params)
Contributing
Bug reports and pull requests are welcome.
Make a pull request
- Fork it
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
Please write unit test with your code if necessary.