Installation
Add this line to your application's Gemfile:
gem 'upop', :git => 'https://github.com/oldfritter/upop'
And then execute:
$ bundle install
Usage
Config
Upop.store_no = '105550149170027' # Your store NO.
Upop.store_name = '上海一树网络科技有限公司' # Your company name.
Upop.key = '88888888' # Your key.
Upop.UPOP_TRADE_URL = 'http://58.246.226.99' # This is the test Gateway.
Generate payment options
@option = {
merId: Upop.store_no,
backEndUrl: orders.first.call_back_url{payment = 'upop'},
frontEndUrl: orders.first.call_back_url{payment = 'upop'},
orderTime: Time.now.strftime('%Y%m%d%H%M%S'),
orderNumber: orders.first.payment_sn,
orderAmount: (orders.collect{|order|order.order_total_price}.sum * 100).to_i,
orderCurrency: 156,
customerIp: orders.first.customer.ip
} # 构建option
@options = Upop::Service.desktop_payment @option
Payment form
<form id="union_pay_form" action="<%= Upop.UPOP_TRADE_URL %>/UpopWeb/api/Pay.action" method='POST'> <input type="hidden" name='backEndUrl' value='<%= @options['backEndUrl'] %>'/> <input type="hidden" name='charset' value='<%= @options['charset'] %>'/> <input type="hidden" name='customerIp' value='<%= @options['customerIp'] %>'/> <input type="hidden" name='frontEndUrl' value='<%= @options['frontEndUrl'] %>'/> <input type="hidden" name='merAbbr' value='<%= @options['merAbbr'] %>'/> <input type="hidden" name='merId' value='<%= @options['merId'] %>'/> <input type="hidden" name='orderAmount' value='<%= @options['orderAmount'] %>'/> <input type="hidden" name='orderCurrency' value='<%= @options['orderCurrency'] %>'/> <input type="hidden" name='orderNumber' value='<%= @options['orderNumber'] %>'/> <input type="hidden" name='orderTime' value='<%= @options['orderTime'] %>'/> <input type="hidden" name='orderTimeout' value='<%= @options['orderTimeout'] %>'/> <input type="hidden" name='signMethod' value='<%= @options['signMethod'] %>'/> <input type="hidden" name='signature' value='<%= @options['signature'] %>'/> <input type="hidden" name='transType' value='<%= @options['transType'] %>'/> <input type="hidden" name='version' value='<%= @options['version'] %>'/> <input type='submit'/> </form>
Verify
def upop_notify return false unless Upop::Sign.verify? params.except('action', 'controller') # Do something. render text: 'success' end def upop_success return false unless Upop::Sign.verify? params.except('action', 'controller') # Do something. redirect_to #your success page. end
相关推荐
ruby实现邮件收发
twitter-cldr-rb - ICU的Ruby实现
ruby-snmp, SNMP ( 简单网络管理协议)的ruby 实现 用于 ruby的 SNMP库摘要这里库实现 SNMP ( 简单网络管理协议) 。 它在纯 ruby 中实现,因此不依赖于的外部库( 如 ) 。 你可以在 ruby 可以运行的任何地方运行这里库...
本资源是飞机大战类射击游戏的ruby实现,需要安装rpg maker xp 1.03才可打开本游戏。
ruby实现文件对比资料收集,看完之后写一个文件对比的脚本或者输出报告没有问题,可以看看,
Whois一个智能纯Ruby实现的WHOIS客户端与解析器
Http-2 - HTTP/2协议的纯Ruby实现
基于ruby实现的音乐推荐网站.zip基于ruby实现的音乐推荐网站.zip基于ruby实现的音乐推荐网站.zip
ruby_使用ruby实现的排序算法_sorting
ruby_使用ruby实现的算法之冒泡排序
ruby_使用ruby实现的算法之加密解密算法
CuckooFilter是Cuckoo Filter的纯Ruby实现
一些图形算法的Ruby实现_Ruby_下载.zip
迁移 SSDB 到 Redis/Pika 工具集,Ruby 实现
SlopeOne推荐算法的Ruby实现_Ruby_下载.zip
ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码ruby代码
用ROR框架写的,用分页查询,查找,插件等一些功能。
云片短息ruby 服务器端api