From 199734cf2f6caabb5afd8859f4f92241f174fc32 Mon Sep 17 00:00:00 2001 From: Rory Sinclair Date: Thu, 16 Jan 2020 18:53:56 +0000 Subject: [PATCH] release 1.1.0 --- lib/pci_proxy/model/tokenised_card.rb | 43 +++++++++++++++++++++++++++ lib/pci_proxy/token.rb | 3 +- lib/pci_proxy/version.rb | 2 +- 3 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 lib/pci_proxy/model/tokenised_card.rb diff --git a/lib/pci_proxy/model/tokenised_card.rb b/lib/pci_proxy/model/tokenised_card.rb new file mode 100644 index 0000000..767bc82 --- /dev/null +++ b/lib/pci_proxy/model/tokenised_card.rb @@ -0,0 +1,43 @@ +module PciProxy + module Model + class TokenisedCard + + attr_reader :pan_token, :cvv_token, :type_slug, :response + + def initialize(response) + @response = response + @pan_token = response["aliasCC"] + @cvv_token = response["aliasCVV"] + @type_slug = slug_for(response["paymentMethod"]) + end + + private + + def slug_for(payment_method) + return nil if payment_method.nil? + + case payment_method + when 'VIS' + :visa + when 'ECA' + :mastercard + when 'AMX' + :amex + when 'DIN' + :diners + when 'DIS' + :discovery + when 'JCB' + :jcb + when 'ELO' + :elo + when 'CUP' + :cup + else + :unknown + end + + end + end + end +end \ No newline at end of file diff --git a/lib/pci_proxy/token.rb b/lib/pci_proxy/token.rb index 58e8bb8..7503590 100644 --- a/lib/pci_proxy/token.rb +++ b/lib/pci_proxy/token.rb @@ -18,7 +18,8 @@ def initialize(api_username:, api_password:) # @raise [PciProxyAPIError] in cases where the API responds with a non-200 response code # @return [Hash] result from PCI Proxy, decoded from JSON def execute(transaction_id:, return_payment_method: true, cvv_mandatory: false) - request(params: { transactionId: transaction_id, returnPaymentMethod: return_payment_method, mandatoryAliasCVV: cvv_mandatory }) + response = request(params: { transactionId: transaction_id, returnPaymentMethod: return_payment_method, mandatoryAliasCVV: cvv_mandatory }) + PciProxy::Model::TokenisedCard.new(response) end end diff --git a/lib/pci_proxy/version.rb b/lib/pci_proxy/version.rb index eaab0d8..6853300 100644 --- a/lib/pci_proxy/version.rb +++ b/lib/pci_proxy/version.rb @@ -1,3 +1,3 @@ module PciProxy - VERSION = "1.0.1" + VERSION = "1.1.0" end