Basic API client for Allpay credit card Web Service.
Add this line to your application's Gemfile:
gem 'allpay-web-service'
And then execute:
$ bundle
Or install it yourself as:
$ gem install allpay-web-service
require "allpay-web-service"
client = AllpayWebService::Client.new(
merchant_id: "2000214",
hash_key: "ejCk326UnaZWKisg",
hash_iv: "q9jcZX8Ib9LM8wYk"
)
-
OTP Trade
result = client.create_trade( ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=CreateTrade", MerchantTradeNo: "TEST000001", MerchantTradeDate: "2016/05/26 00:00:00", TotalAmount: 100, TradeDesc: "OTP Trade Test", CardNo: 4311952222222222, CardValidMM: "12", CardValidYY: "20", CardCVV2: 222, PhoneNumber: "0987654321" )
-
Non-OTP Trade
result = client.create_trade( ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=CreateTrade", MerchantTradeNo: "TEST000001", MerchantTradeDate: "2016/05/26 00:00:00", TotalAmount: 100, TradeDesc: "Non-OTP Trade Test", CardNo: 4311952222222222, CardValidMM: "12", CardValidYY: "20", CardCVV2: 222 )
result = client.verify_order_by_otp(
ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=QueryTrade",
MerchantTradeNo: "TEST000001",
TradeNo: "3c4c591f65153095b01",
OtpCode: "1234"
)
result = client.resend_otp(
ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=ResendOtp",
MerchantTradeNo: "TEST000001",
TradeNo: "3c4c591f65153095b01"
)
-
Query Trade
result = client.query_trade( ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=QueryTrade", MerchantTradeNo: "TEST000001" )
-
Platform Query Trade
result = client.query_trade( ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=QueryTrade", MerchantTradeNo: "TEST000001", PlatformID: "9999999" )
result = client.do_action(
ServiceURL: "http://pay-stage.allpay.com.tw/CreditDetail/DoAction",
MerchantTradeNo: "TEST000001",
TradeNo: "3c4c591f65153095b01",
Action: "C",
TotalAmount: 100
)
All methods are return XML/Hash format result.
result["Xml"]
: XML format result.
result["Hash"]
: Hash format result.
Bug reports and pull requests are welcome on GitHub at https://github.com/CalvertYang/allpay-web-service.
The gem is available as open source under the terms of the MIT License.