lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb in activemerchant-1.66.0 vs lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb in activemerchant-1.67.0

- old
+ new

@@ -14,29 +14,37 @@ super end def purchase(money, credit_card_or_reference, options = {}) MultiResponse.run(true) do |r| + if credit_card_or_reference.is_a?(String) + r.process { create_token(credit_card_or_reference, options) } + credit_card_or_reference = r.authorization + end r.process { create_payment(money, options) } r.process { post = authorization_params(money, credit_card_or_reference, options) add_autocapture(post, false) - commit(synchronized_path("/payments/#{r.authorization}/authorize"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post) } r.process { post = capture_params(money, credit_card_or_reference, options) - commit(synchronized_path("/payments/#{r.authorization}/capture"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/capture"), post) } end end def authorize(money, credit_card_or_reference, options = {}) MultiResponse.run(true) do |r| + if credit_card_or_reference.is_a?(String) + r.process { create_token(credit_card_or_reference, options) } + credit_card_or_reference = r.authorization + end r.process { create_payment(money, options) } r.process { post = authorization_params(money, credit_card_or_reference, options) - commit(synchronized_path("/payments/#{r.authorization}/authorize"), post) + commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post) } end end def void(identification, _options = {}) @@ -69,16 +77,14 @@ def store(credit_card, options = {}) MultiResponse.run do |r| r.process { create_store(options) } r.process { authorize_store(r.authorization, credit_card, options)} - r.process { create_token(r.authorization, options.merge({id: r.authorization}))} end end def unstore(identification) - identification = identification.split(";").last commit(synchronized_path "/cards/#{identification}/cancel") end def supports_scrubbing? true @@ -91,15 +97,15 @@ gsub(%r(("cvd\\?":\\?")\d+), '\1[FILTERED]') end private - def authorization_params(money, credit_card, options = {}) + def authorization_params(money, credit_card_or_reference, options = {}) post = {} add_amount(post, money, options) - add_credit_card_or_reference(post, credit_card) + add_credit_card_or_reference(post, credit_card_or_reference) add_additional_params(:authorize, post, options) post end @@ -124,11 +130,11 @@ commit(synchronized_path("/cards/#{identification}/authorize"), post) end def create_token(identification, options) post = {} - post[:id] = options[:id] + # post[:id] = options[:id] commit(synchronized_path("/cards/#{identification}/tokens"), post) end def create_payment(money, options = {}) post = {} @@ -148,19 +154,19 @@ response = json_error(response) end Response.new(success, message_from(success, response), response, :test => test?, - :authorization => authorization_from(response, params[:id]) + :authorization => authorization_from(response) ) end - def authorization_from(response, auth_id) + def authorization_from(response) if response["token"] - "#{response["token"]};#{auth_id}" + response["token"].to_s else - response["id"] + response["id"].to_s end end def add_currency(post, money, options) post[:currency] = options[:currency] || currency(money) @@ -203,11 +209,10 @@ end def add_credit_card_or_reference(post, credit_card_or_reference, options = {}) post[:card] ||= {} if credit_card_or_reference.is_a?(String) - reference = credit_card_or_reference.split(";").first - post[:card][:token] = reference + post[:card][:token] = credit_card_or_reference else post[:card][:number] = credit_card_or_reference.number post[:card][:cvd] = credit_card_or_reference.verification_value post[:card][:expiration] = expdate(credit_card_or_reference) post[:card][:issued_to] = credit_card_or_reference.name