ruby实现桌面端银联支付

阅读更多

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

'/> '/> '/> '/> '/> '/> '/> '/> '/> '/> '/> '/> '/> '/> '/>

 

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

 

你可能感兴趣的:(UnionPay,ruby,支付,银联)