Sha256: eb2173356e2912fcd82fd9263d048baec75b5bda7dc45e4bc6a3e6da2bb88f51

Contents?: true

Size: 934 Bytes

Versions: 2

Compression:

Stored size: 934 Bytes

Contents

module Alipay
  module App
    module Service
      ALIPAY_TRADE_APP_PAY_REQUIRED_PARAMS = %w( app_id biz_content notify_url )

      def self.alipay_trade_app_pay(params, options = {})
        params = Utils.stringify_keys(params)
        Alipay::Service.check_required_params(params, ALIPAY_TRADE_APP_PAY_REQUIRED_PARAMS)
        key = options[:key] || Alipay.key

        params = {
          'method'         => 'alipay.trade.app.pay',
          'charset'        => 'utf-8',
          'version'        => '1.0',
          'timestamp'      => Time.now.utc.strftime('%Y-%m-%d %H:%M:%S').to_s,
          'sign_type'      => 'RSA'
        }.merge(params)

        string = Alipay::App::Sign.params_to_sorted_string(params)
        sign = CGI.escape(Alipay::Sign::RSA.sign(key, string))
        encoded_string = Alipay::App::Sign.params_to_encoded_string(params)

        %Q(#{encoded_string}&sign=#{sign})
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alipay-0.14.0 lib/alipay/app/service.rb
alipay-0.13.0 lib/alipay/app/service.rb