class PaymentGateway::ForAll::Card
Public Class Methods
new(card_data)
click to toggle source
{
"type": 1, "cardholderName": "JOHN SMITH", "cardNumber": "4024007126652816", "expirationDate": "0119", "securityCode": "123"
}
# File lib/payment_gateway/for_all/card.rb, line 12 def initialize(card_data) @card_data = card_data end
Public Instance Methods
get_nonce()
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 16 def get_nonce request(:post, endpoint_nonce, body: build_card_body) end
get_token()
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 20 def get_token response = get_nonce request(:post, endpoint_token, body: build_get_token_body(response[:cardNonce])) end
Private Instance Methods
build_card_body()
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 35 def build_card_body { "accessKey": access_key, "cardData": { "type": @card_data[:type], "cardholderName": @card_data[:cardholderName], "cardNumber": @card_data[:cardNumber], "expirationDate": @card_data[:expirationDate], "securityCode": @card_data[:securityCode] } } end
build_get_token_body(card_nonce)
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 48 def build_get_token_body(card_nonce) { cardNonce: card_nonce } end
endpoint_nonce()
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 27 def endpoint_nonce api_url + '/prepareCard' end
endpoint_token()
click to toggle source
# File lib/payment_gateway/for_all/card.rb, line 31 def endpoint_token api_url + '/createCardToken' end