Module: Vantiv::Api::RequestBody

Defined in:
lib/vantiv/api/request_body.rb

Class Method Summary collapse

Class Method Details

.card_element_for_tokenization(paypage_registration_id) ⇒ Object



69
70
71
72
73
74
75
# File 'lib/vantiv/api/request_body.rb', line 69

def self.card_element_for_tokenization(paypage_registration_id)
  {
    "Card" => {
      "PaypageRegistrationID" => paypage_registration_id
    }
  }
end

.for_auth_or_sale(amount:, customer_id:, order_id:, payment_account_id:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/vantiv/api/request_body.rb', line 4

def self.for_auth_or_sale(amount:, customer_id:, order_id:, payment_account_id:)
  RequestBodyGenerator.run(
    transaction_element(
      amount: amount,
      order_id: order_id,
      customer_id: customer_id
    ),
    (payment_account_id: )
  )
end

.for_auth_reversal(transaction_id:, amount: nil) ⇒ Object



15
16
17
18
19
# File 'lib/vantiv/api/request_body.rb', line 15

def self.for_auth_reversal(transaction_id:, amount: nil)
  RequestBodyGenerator.run(
    tied_transaction_element(transaction_id: transaction_id, amount: amount)
  )
end

.for_capture(transaction_id:, amount: nil) ⇒ Object



21
22
23
24
25
# File 'lib/vantiv/api/request_body.rb', line 21

def self.for_capture(transaction_id:, amount: nil)
  RequestBodyGenerator.run(
    tied_transaction_element(transaction_id: transaction_id, amount: amount)
  )
end

.for_credit(transaction_id:, amount: nil) ⇒ Object



27
28
29
30
31
# File 'lib/vantiv/api/request_body.rb', line 27

def self.for_credit(transaction_id:, amount: nil)
  RequestBodyGenerator.run(
    tied_transaction_element(transaction_id: transaction_id, amount: amount)
  )
end

.for_direct_post_tokenization(card_number:, expiry_month:, expiry_year:, cvv:) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/vantiv/api/request_body.rb', line 52

def self.for_direct_post_tokenization(card_number:, expiry_month:, expiry_year:, cvv:)
  RequestBodyGenerator.run(
    {
      "Card" => {
        "AccountNumber" => card_number,
        "ExpirationMonth" => expiry_month,
        "ExpirationYear" => expiry_year,
        "CVV" => cvv
      }
    }
  )
end

.for_return(amount:, customer_id:, order_id:, payment_account_id:) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/vantiv/api/request_body.rb', line 33

def self.for_return(amount:, customer_id:, order_id:, payment_account_id:)
  transaction = transaction_element(
    amount: amount,
    order_id: order_id,
    customer_id: customer_id
  )
  transaction["Transaction"].delete("PartialApprovedFlag")
  RequestBodyGenerator.run(
    transaction,
    (payment_account_id: )
  )
end

.for_tokenization(paypage_registration_id:) ⇒ Object



46
47
48
49
50
# File 'lib/vantiv/api/request_body.rb', line 46

def self.for_tokenization(paypage_registration_id:)
  RequestBodyGenerator.run(
    card_element_for_tokenization(paypage_registration_id)
  )
end

.for_void(transaction_id:) ⇒ Object



65
66
67
# File 'lib/vantiv/api/request_body.rb', line 65

def self.for_void(transaction_id:)
  RequestBodyGenerator.run(tied_transaction_element(transaction_id: transaction_id))
end

.payment_account_element(payment_account_id:) ⇒ Object



101
102
103
104
105
106
107
# File 'lib/vantiv/api/request_body.rb', line 101

def self.(payment_account_id:)
  {
    "PaymentAccount" => {
      "PaymentAccountID" => 
    }
  }
end

.tied_transaction_element(transaction_id:, amount: nil) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
# File 'lib/vantiv/api/request_body.rb', line 77

def self.tied_transaction_element(transaction_id:, amount: nil)
  res = {
    "Transaction" => {
      "TransactionID" => transaction_id
    }
  }
  if amount
    res["Transaction"]["TransactionAmount"] = '%.2f' % (amount / 100.0)
  end
  res
end

.transaction_element(amount:, customer_id:, order_id:) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/vantiv/api/request_body.rb', line 89

def self.transaction_element(amount:, customer_id:, order_id:)
  {
    "Transaction" => {
      "ReferenceNumber" => order_id,
      "TransactionAmount" => '%.2f' % (amount / 100.0),
      "OrderSource" => Vantiv.order_source,
      "CustomerID" => customer_id,
      "PartialApprovedFlag" => false
    }
  }
end