lib/alipay/service.rb in alipay-0.6.0.beta3 vs lib/alipay/service.rb in alipay-0.6.0
- old
+ new
@@ -161,19 +161,37 @@
}.merge(params)
Net::HTTP.get(request_uri(params, options))
end
+ MOBILD_SECURITY_PAY_REQUIRED_PARAMS = %w( notify_url out_trade_no subject total_fee body )
+ def self.mobile_security_pay_url(params, options = {})
+ params = Utils.stringify_keys(params)
+ check_required_params(params, MOBILD_SECURITY_PAY_REQUIRED_PARAMS)
+ sign_type = options[:sign_type] || Alipay.sign_type
+ raise ArgumentError, "only support RSA sign_type" if sign_type != 'RSA'
+
+ params = {
+ '_input_charset' => 'utf-8',
+ 'partner' => options[:pid] || Alipay.pid,
+ 'seller_id' => options[:seller_email] || Alipay.seller_email,
+ 'payment_type' => '1',
+ 'service' => 'mobile.securitypay.pay'
+ }.merge(params)
+
+ request_uri(params, options).to_s
+ end
+
def self.request_uri(params, options = {})
uri = URI(GATEWAY_URL)
uri.query = URI.encode_www_form(sign_params(params, options))
uri
end
- def self.sign_params(params, optinos = {})
+ def self.sign_params(params, options = {})
params.merge(
- 'sign_type' => (optinos[:sign_type] || Alipay.sign_type),
- 'sign' => Alipay::Sign.generate(params, optinos)
+ 'sign_type' => (options[:sign_type] || Alipay.sign_type),
+ 'sign' => Alipay::Sign.generate(params, options)
)
end
def self.check_required_params(params, names)
return if !Alipay.debug_mode?