lib/active_merchant/billing/gateways/stripe.rb in jelaniharris-activemerchant-1.24.1 vs lib/active_merchant/billing/gateways/stripe.rb in jelaniharris-activemerchant-1.29.1

- old
+ new

@@ -1,11 +1,11 @@ require 'json' module ActiveMerchant #:nodoc: module Billing #:nodoc: class StripeGateway < Gateway - LIVE_URL = 'https://api.stripe.com/v1/' + self.live_url = 'https://api.stripe.com/v1/' AVS_CODE_TRANSLATOR = { 'line1: pass, zip: pass' => 'Y', 'line1: pass, zip: fail' => 'A', 'line1: pass, zip: unchecked' => 'B', @@ -19,11 +19,11 @@ 'pass' => 'M', 'fail' => 'N', 'unchecked' => 'P' } - self.supported_countries = ['US'] + self.supported_countries = ['US', 'CA'] self.default_currency = 'USD' self.money_format = :cents self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club] self.homepage_url = 'https://stripe.com/' @@ -46,10 +46,11 @@ post = {} add_amount(post, money, options) add_creditcard(post, creditcard, options) add_customer(post, options) + add_customer_data(post,options) post[:description] = options[:description] || options[:email] add_flags(post, options) meta = generate_meta(options) @@ -103,22 +104,26 @@ post[:amount] = amount(money) post[:currency] = (options[:currency] || currency(money)).downcase end def add_customer_data(post, options) - post[:description] = options[:description] - post[:email] = options[:email] + metadata_options = [:description,:browser_ip,:user_agent,:referrer] + post.update(options.slice(*metadata_options)) + + post[:external_id] = options[:order_id] + post[:payment_user_agent] = "Stripe/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}" end def add_address(post, options) return unless post[:card] && post[:card].kind_of?(Hash) if address = options[:billing_address] || options[:address] post[:card][:address_line1] = address[:address1] if address[:address1] post[:card][:address_line2] = address[:address2] if address[:address2] post[:card][:address_country] = address[:country] if address[:country] post[:card][:address_zip] = address[:zip] if address[:zip] post[:card][:address_state] = address[:state] if address[:state] + post[:card][:address_city] = address[:city] if address[:city] end end def add_creditcard(post, creditcard, options) if creditcard.respond_to?(:number) @@ -189,10 +194,10 @@ def commit(method, url, parameters=nil, meta={}) raw_response = response = nil success = false begin - raw_response = ssl_request(method, LIVE_URL + url, post_data(parameters), headers(meta)) + raw_response = ssl_request(method, self.live_url + url, post_data(parameters), headers(meta)) response = parse(raw_response) success = !response.key?("error") rescue ResponseError => e raw_response = e.response.body response = response_error(raw_response)