module Vantiv

Constants

VERSION

Public Class Methods

auth(amount:, payment_account_id:, customer_id:, order_id:, expiry_month:, expiry_year:, order_source: Vantiv.default_order_source, use_temporarily_stored_security_code: false, online_payment_cryptogram: nil, original_network_transaction_id: nil, processing_type: nil, original_transaction_amount: nil) click to toggle source
# File lib/vantiv.rb, line 44
def self.auth(amount:, payment_account_id:, customer_id:, order_id:, expiry_month:, expiry_year:,
  order_source: Vantiv.default_order_source, use_temporarily_stored_security_code: false,
  online_payment_cryptogram: nil, original_network_transaction_id: nil, processing_type: nil,
  original_transaction_amount: nil)

  # RE use_temporarily_stored_security_code
  # From XML Docs:
  # When you submit the CVV2/CVC2/CID in a registerTokenRequest, the platform encrypts
  # and stores the value on a temporary basis for later use in a tokenized Auth/Sale
  # transaction submitted without the value. To use the store value when
  # submitting an Auth/Sale transaction, set the cardValidationNum value to 000.

  cvv = use_temporarily_stored_security_code ? '000' : nil

  body = Api::RequestBody.for_auth_or_sale(
    amount: amount,
    order_id: order_id,
    customer_id: customer_id,
    payment_account_id: payment_account_id,
    expiry_month: expiry_month,
    expiry_year: expiry_year,
    cvv: cvv,
    order_source: order_source,
    online_payment_cryptogram: online_payment_cryptogram,
    original_network_transaction_id: original_network_transaction_id,
    original_transaction_amount: original_transaction_amount,
    processing_type: processing_type
  )
  Api::Request.new(
    endpoint: Api::Endpoints::AUTHORIZATION,
    body: body,
    response_object: Api::LiveTransactionResponse.new(:auth)
  ).run
end
auth_capture(amount:, payment_account_id:, customer_id:, order_id:, expiry_month:, expiry_year:, order_source: Vantiv.default_order_source, online_payment_cryptogram: nil, original_network_transaction_id: nil, processing_type: nil, original_transaction_amount: nil) click to toggle source
# File lib/vantiv.rb, line 105
def self.auth_capture(amount:, payment_account_id:, customer_id:, order_id:,
    expiry_month:, expiry_year:, order_source: Vantiv.default_order_source,
    online_payment_cryptogram: nil, original_network_transaction_id: nil, processing_type: nil,
    original_transaction_amount: nil)
  body = Api::RequestBody.for_auth_or_sale(
    amount: amount,
    order_id: order_id,
    customer_id: customer_id,
    payment_account_id: payment_account_id,
    expiry_month: expiry_month,
    expiry_year: expiry_year,
    order_source: order_source,
    online_payment_cryptogram: online_payment_cryptogram,
    original_network_transaction_id: original_network_transaction_id,
    original_transaction_amount: original_transaction_amount,
    processing_type: processing_type
  )
  Api::Request.new(
    endpoint: Api::Endpoints::SALE,
    body: body,
    response_object: Api::LiveTransactionResponse.new(:sale)
  ).run
end
auth_reversal(transaction_id:, amount: nil) click to toggle source
# File lib/vantiv.rb, line 79
def self.auth_reversal(transaction_id:, amount: nil)
  body = Api::RequestBody.for_auth_reversal(
    transaction_id: transaction_id,
    amount: amount
  )

  Api::Request.new(
    endpoint: Api::Endpoints::AUTH_REVERSAL,
    body: body,
    response_object: Api::TiedTransactionResponse.new(:auth_reversal)
  ).run
end
capture(transaction_id:, amount: nil) click to toggle source
# File lib/vantiv.rb, line 92
def self.capture(transaction_id:, amount: nil)
  body = Api::RequestBody.for_capture(
    transaction_id: transaction_id,
    amount: amount
  )

  Api::Request.new(
    endpoint: Api::Endpoints::CAPTURE,
    body: body,
    response_object: Api::TiedTransactionResponse.new(:capture)
  ).run
end
configure() { |self| ... } click to toggle source
# File lib/vantiv.rb, line 174
def self.configure
  yield self
end
credit(transaction_id:, amount: nil) click to toggle source

NOTE: ActiveMerchant's refund… only for use on a capture or sale it seems

-> 'returns' are refunds too, credits are tied to a sale/capture, returns can be willy nilly
# File lib/vantiv.rb, line 131
def self.credit(transaction_id:, amount: nil)
  body = Api::RequestBody.for_credit(
    amount: amount,
    transaction_id: transaction_id
  )
  Api::Request.new(
    endpoint: Api::Endpoints::CREDIT,
    body: body,
    response_object: Api::TiedTransactionResponse.new(:credit)
  ).run
end
get_error_description(code:) click to toggle source
# File lib/vantiv.rb, line 170
def self.get_error_description(code:)
  ResponseCodeMap.get_error_description(code: code)
end
refund(amount:, payment_account_id:, customer_id:, order_id:, expiry_month:, expiry_year:, order_source: Vantiv.default_order_source) click to toggle source
# File lib/vantiv.rb, line 143
def self.refund(amount:, payment_account_id:, customer_id:, order_id:,
    expiry_month:, expiry_year:, order_source: Vantiv.default_order_source)
  body = Api::RequestBody.for_return(
    amount: amount,
    customer_id: customer_id,
    order_id: order_id,
    payment_account_id: payment_account_id,
    expiry_month: expiry_month,
    expiry_year: expiry_year,
    order_source: order_source
  )
  Api::Request.new(
    endpoint: Api::Endpoints::RETURN,
    body: body,
    response_object: Api::TiedTransactionResponse.new(:return)
  ).run
end
root() click to toggle source
# File lib/vantiv.rb, line 192
def self.root
  File.dirname __dir__
end
tokenize(temporary_token:) click to toggle source
# File lib/vantiv.rb, line 14
def self.tokenize(temporary_token:)
  if temporary_token == "" or temporary_token == nil
    raise ArgumentError.new("Blank temporary token (PaypageRegistrationID): \n
                             Check that paypage error handling is implemented correctly.")
  end

  body = Api::RequestBody.for_tokenization(
    paypage_registration_id: temporary_token
  )
  Api::Request.new(
    endpoint: Api::Endpoints::TOKENIZATION,
    body: body,
    response_object: Api::TokenizationResponse.new
  ).run
end
tokenize_by_direct_post(card_number:, expiry_month:, expiry_year:, cvv:) click to toggle source
# File lib/vantiv.rb, line 30
def self.tokenize_by_direct_post(card_number:, expiry_month:, expiry_year:, cvv:)
  body = Api::RequestBody.for_direct_post_tokenization(
    card_number: card_number,
    expiry_month: expiry_month,
    expiry_year: expiry_year,
    cvv: cvv
  )
  Api::Request.new(
    endpoint: Api::Endpoints::TOKENIZATION,
    body: body,
    response_object: Api::TokenizationResponse.new
  ).run
end
void(transaction_id:) click to toggle source

NOTE: can void credits

# File lib/vantiv.rb, line 162
def self.void(transaction_id:)
  Api::Request.new(
    endpoint: Api::Endpoints::VOID,
    body: Api::RequestBody.for_void(transaction_id: transaction_id),
    response_object: Api::TiedTransactionResponse.new(:void)
  ).run
end