Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Basic API client for Allpay credit card Web Service.

License

Notifications You must be signed in to change notification settings

calvertyang/allpay-web-service

Repository files navigation

Gem Version Analytics

Allpay Web Service

Basic API client for Allpay credit card Web Service.

Installation

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

Usage

Initialize

require "allpay-web-service"

client = AllpayWebService::Client.new(
  merchant_id: "2000214",
  hash_key: "ejCk326UnaZWKisg",
  hash_iv: "q9jcZX8Ib9LM8wYk"
)

Example

Create Trade

  • 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
    )

Verify Order By OTP

result = client.verify_order_by_otp(
  ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=QueryTrade",
  MerchantTradeNo: "TEST000001",
  TradeNo: "3c4c591f65153095b01",
  OtpCode: "1234"
)

Resend OTP code

result = client.resend_otp(
  ServiceURL: "http://pay-stage.allpay.com.tw/merchantapi/creditcard.asmx?op=ResendOtp",
  MerchantTradeNo: "TEST000001",
  TradeNo: "3c4c591f65153095b01"
)

Query Trade / Platform Query Trade

  • 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"
    )

Do Action

result = client.do_action(
  ServiceURL: "http://pay-stage.allpay.com.tw/CreditDetail/DoAction",
  MerchantTradeNo: "TEST000001",
  TradeNo: "3c4c591f65153095b01",
  Action: "C",
  TotalAmount: 100
)

Result

All methods are return XML/Hash format result.

result["Xml"]: XML format result.

result["Hash"]: Hash format result.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/CalvertYang/allpay-web-service.

License

The gem is available as open source under the terms of the MIT License.

About

Basic API client for Allpay credit card Web Service.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published