lib/alipay/service.rb in alipay-0.4.1 vs lib/alipay/service.rb in alipay-0.5.0

- old
+ new

@@ -80,10 +80,29 @@ }.merge(options) "#{GATEWAY_URL}?#{query_string(options)}" end + CREATE_FOREX_SINGLE_REFUND_URL_REQUIRED_OPTIONS = %w( out_return_no out_trade_no return_amount currency reason ) + # 支付宝境外收单单笔退款接口 + # out_return_no 退款流水单号 + # out_trade_no 交易创建时的订单号 + # return_amount 退款金额 + # currency 退款币种,与交易创建时的币种一致 + def self.create_forex_single_refund_url(options) + options = { + 'service' => 'forex_refund', + 'partner' => Alipay.pid, + '_input_charset' => 'utf-8', + 'gmt_return' => Time.now.strftime('%Y%m%d%H%M%S') + }.merge(Utils.stringify_keys(options)) + + check_required_options(options, CREATE_FOREX_SINGLE_REFUND_URL_REQUIRED_OPTIONS) + + "#{GATEWAY_URL}?#{query_string(options)}" + end + SEND_GOODS_CONFIRM_BY_PLATFORM_REQUIRED_OPTIONS = %w( service partner _input_charset trade_no logistics_name ) def self.send_goods_confirm_by_platform(options) options = { 'service' => 'send_goods_confirm_by_platform', 'partner' => Alipay.pid, @@ -148,15 +167,18 @@ "#{CGI.escape(key.to_s)}=#{CGI.escape(value.to_s)}" end.join('&') end def self.check_required_options(options, names) + return if !Alipay.debug_mode? + names.each do |name| warn("Ailpay Warn: missing required option: #{name}") unless options.has_key?(name) end end def self.check_optional_options(options, names) + return if !Alipay.debug_mode? warn("Ailpay Warn: must specify either #{names.join(' or ')}") if names.all? {|name| options[name].nil? } end end end