0.01
No commit activity in last 3 years
No release in over 3 years
An unofficial simple unionpay_app gem
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

该gem是一个银联手机控件支付接口

Installation

######Add this line to your application's Gemfile:

gem 'unionpay_app', '~> 0.9.0'

######or development version

$ bundle

######Usage

Config

UnionpayApp.front_url = Settings.union.frontUrl
UnionpayApp.back_url = Settings.union.backUrl
UnionpayApp.mer_id = Settings.union.merId
UnionpayApp.uri = Settings.union.uri
UnionpayApp.query_uri = Settings.union.query_uri
UnionpayApp.private_key = Settings.union.private_key
UnionpayApp.cer = Settings.union.cer
UnionpayApp.cert_id = Settings.union.certId

Generate payment url for web

    1. 银联签名 返回hash {time: "交易时间", sign: "post给银联的hash"}
UnionpayApp::Service.sign txtAmt, orderId 
#如下使用
options = UnionpayApp::Service.sign("100", "20150415122801272")
    1. 发送给银联post请求 换取tn值
UnionpayApp::Service.post UnionpayApp::Service.sign(txtAmt, orderId)
#如下使用 会返回tn值
UnionpayApp::Service.post(options)
  • 3.银联验签:当请求银联获取tn后,或者请求银联查询交易后,或者当交易完成后,银联通过backUrl、frontUrl返回你结果时要进行验签
  UnionpayApp::Service.verify options
    1. 查询交易是否成功 传入参数order_id
UnionpayApp::Service.query order_id, UnionpayApp::Service.sign(txtAmt, orderId)[:time] 
# 不要再做一次签名 取之前的options
UnionpayApp::Service.query "20150415122801272", options[:time]