Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkout.com V2: Support tokenized and saved credit cards #3215

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Prev Previous commit
Support Checkout payment IDs
  • Loading branch information
obahareth committed May 20, 2019
commit efa8a55e970ccf03a04cc5a65b50ea75079c0abd
16 changes: 15 additions & 1 deletion lib/active_merchant/billing/gateways/checkout_v2.rb
Original file line number Diff line number Diff line change
@@ -2,7 +2,13 @@ module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class CheckoutPaymentToken < PaymentToken
def type
'checkout'
'checkout_token'
end
end

class CheckoutPaymentId < PaymentToken
def type
'checkout_id'
end
end

@@ -142,6 +148,9 @@ def add_payment_method(post, payment_method)

elsif payment_method.is_a?(CheckoutPaymentToken)
add_payment_token(post, payment_method)

elsif payment_method.is_a?(CheckoutPaymentId)
add_payment_id(post, payment_method)
end
end

@@ -159,6 +168,11 @@ def add_payment_token(post, token)
post[:source][:token] = token.payment_data
end

def add_payment_id(post, id)
post[:source][:type] = 'id'
post[:source][:id] = id.payment_data
end

def build_billing_address(address)
return {} if address.blank?