Class: PciProxy::Token
Constant Summary collapse
- SANDBOX_ENDPOINT =
'https://api.sandbox.datatrans.com/upp/services/v1/inline/token'.freeze
- LIVE_ENDPOINT =
'https://api.datatrans.com/upp/services/v1/inline/token'.freeze
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#api_endpoint, #api_password, #api_username
Instance Method Summary collapse
-
#execute(transaction_id:, return_payment_method: true, cvv_mandatory: false) ⇒ PciProxy::Model::TokenisedCard
Perform a token API request to turn the specified
transaction_id
into card and CVV tokens. -
#initialize(api_username:, api_password:, endpoint: SANDBOX_ENDPOINT) ⇒ Token
constructor
Initialise with the specified
api_username
andapi_password
from PCI Proxy.
Methods inherited from Base
#api_get, #api_post, #client, #error_class
Constructor Details
#initialize(api_username:, api_password:, endpoint: SANDBOX_ENDPOINT) ⇒ Token
Initialise with the specified api_username
and api_password
from PCI Proxy.
Defaults to the sandbox API endpoint - to use the live environment, supply the LIVE_ENDPOINT constant as the value of the endpoint
kwarg
12 13 14 15 16 |
# File 'lib/pci_proxy/token.rb', line 12 def initialize(api_username:, api_password:, endpoint: SANDBOX_ENDPOINT) @api_endpoint = endpoint @api_username = api_username @api_password = api_password end |
Instance Method Details
#execute(transaction_id:, return_payment_method: true, cvv_mandatory: false) ⇒ PciProxy::Model::TokenisedCard
Perform a token API request to turn the specified transaction_id
into card and CVV tokens
26 27 28 29 30 31 32 33 |
# File 'lib/pci_proxy/token.rb', line 26 def execute(transaction_id:, return_payment_method: true, cvv_mandatory: false) raise "transaction_id is required" unless transaction_id && !transaction_id.empty? PciProxy::Model::TokenisedCard.new(api_get(params: { transactionId: transaction_id, returnPaymentMethod: return_payment_method, mandatoryAliasCVV: cvv_mandatory })) end |