Sha256: b6b74cca3f238fa2ad7df2a197b3946db760ec92354913d4f1385c5ed48e712e

Contents?: true

Size: 1.01 KB

Versions: 10

Compression:

Stored size: 1.01 KB

Contents

module Alipay
  module Mobile
    module Service
      MOBILE_SECURITY_PAY_REQUIRED_PARAMS = %w( notify_url out_trade_no subject total_fee body )
      def self.mobile_securitypay_pay_string(params, options = {})
        params = Utils.stringify_keys(params)
        Alipay::Service.check_required_params(params, MOBILE_SECURITY_PAY_REQUIRED_PARAMS)
        sign_type = options[:sign_type] || Alipay.sign_type
        key = options[:key] || Alipay.key
        raise ArgumentError, "only support RSA sign_type" if sign_type != 'RSA'

        params = {
          'service'        => 'mobile.securitypay.pay',
          '_input_charset' => 'utf-8',
          'partner'        => options[:pid] || Alipay.pid,
          'seller_id'      => options[:pid] || Alipay.pid,
          'payment_type'   => '1'
        }.merge(params)

        string = Alipay::Mobile::Sign.params_to_string(params)
        sign = CGI.escape(Alipay::Sign::RSA.sign(key, string))

        %Q(#{string}&sign="#{sign}"&sign_type="RSA")
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
alipay-0.15.0 lib/alipay/mobile/service.rb
yl_alipay-0.15.3 lib/alipay/mobile/service.rb
yl_alipay-0.15.2 lib/alipay/mobile/service.rb
alipay-0.14.0 lib/alipay/mobile/service.rb
alipay-0.13.0 lib/alipay/mobile/service.rb
alipay-0.12.0 lib/alipay/mobile/service.rb
alipay-0.11.0 lib/alipay/mobile/service.rb
alipay-0.10.0 lib/alipay/mobile/service.rb
alipay-0.9.0 lib/alipay/mobile/service.rb
alipay-0.8.0 lib/alipay/mobile/service.rb