vantiv 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +16 -0
  3. data/.env.example +4 -2
  4. data/.rubocop.yml +1157 -0
  5. data/.ruby-version +1 -1
  6. data/CHANGELOG.md +10 -0
  7. data/README.md +42 -29
  8. data/bin/console +5 -3
  9. data/bin/generate_sandbox_fixtures +5 -3
  10. data/bin/paypage_server +5 -3
  11. data/cert_fixtures/{L_AU_1.json → ACCOUNT_UPDATER_100.json} +0 -0
  12. data/cert_fixtures/{L_AU_3.json → ACCOUNT_UPDATER_100A.json} +0 -0
  13. data/cert_fixtures/{L_AU_7.json → ACCOUNT_UPDATER_100B.json} +1 -1
  14. data/cert_fixtures/{L_AU_2.json → ACCOUNT_UPDATER_101.json} +0 -0
  15. data/cert_fixtures/{L_AU_4.json → ACCOUNT_UPDATER_101A.json} +0 -0
  16. data/cert_fixtures/{L_AU_5.json → ACCOUNT_UPDATER_102.json} +0 -0
  17. data/cert_fixtures/{L_AU_6.json → ACCOUNT_UPDATER_103.json} +0 -0
  18. data/cert_fixtures/{L_AC_1.json → AUTH_CAPTURE_1.json} +0 -0
  19. data/cert_fixtures/AUTH_CAPTURE_1A.json +8 -0
  20. data/cert_fixtures/{L_AC_2.json → AUTH_CAPTURE_2.json} +0 -0
  21. data/cert_fixtures/AUTH_CAPTURE_2A.json +8 -0
  22. data/cert_fixtures/{L_AC_3.json → AUTH_CAPTURE_3.json} +0 -0
  23. data/cert_fixtures/AUTH_CAPTURE_3A.json +8 -0
  24. data/cert_fixtures/{L_AC_4.json → AUTH_CAPTURE_4.json} +0 -0
  25. data/cert_fixtures/AUTH_CAPTURE_4A.json +8 -0
  26. data/cert_fixtures/{L_AC_5.json → AUTH_CAPTURE_5.json} +0 -0
  27. data/cert_fixtures/AUTH_CAPTURE_5A.json +8 -0
  28. data/cert_fixtures/{L_AC_6.json → AUTH_CAPTURE_6.json} +0 -0
  29. data/cert_fixtures/{L_AC_7.json → AUTH_CAPTURE_7.json} +0 -0
  30. data/cert_fixtures/{L_AC_8.json → AUTH_CAPTURE_8.json} +0 -0
  31. data/cert_fixtures/{L_AC_9.json → AUTH_CAPTURE_9.json} +0 -0
  32. data/cert_fixtures/{L_AR_1.json → AUTH_REVERSAL_32.json} +0 -0
  33. data/cert_fixtures/{L_AR_1A.json → AUTH_REVERSAL_32A.json} +1 -1
  34. data/cert_fixtures/AUTH_REVERSAL_32B.json +8 -0
  35. data/cert_fixtures/{L_AR_2.json → AUTH_REVERSAL_33.json} +0 -0
  36. data/cert_fixtures/AUTH_REVERSAL_33A.json +8 -0
  37. data/cert_fixtures/{L_AR_3.json → AUTH_REVERSAL_34.json} +0 -0
  38. data/cert_fixtures/AUTH_REVERSAL_34A.json +8 -0
  39. data/cert_fixtures/{L_AR_4.json → AUTH_REVERSAL_35.json} +0 -0
  40. data/cert_fixtures/{L_AR_4A.json → AUTH_REVERSAL_35A.json} +1 -1
  41. data/cert_fixtures/{L_AR_4B.json → AUTH_REVERSAL_35B.json} +1 -1
  42. data/cert_fixtures/{L_AR_5.json → AUTH_REVERSAL_36.json} +0 -0
  43. data/cert_fixtures/{L_AR_5A.json → AUTH_REVERSAL_36A.json} +1 -1
  44. data/cert_fixtures/{L_RC_1.json → CREDIT_1.json} +0 -0
  45. data/cert_fixtures/CREDIT_1A.json +8 -0
  46. data/cert_fixtures/CREDIT_1B.json +8 -0
  47. data/cert_fixtures/{L_RC_2.json → CREDIT_2.json} +0 -0
  48. data/cert_fixtures/CREDIT_2A.json +8 -0
  49. data/cert_fixtures/CREDIT_2B.json +8 -0
  50. data/cert_fixtures/{L_RC_3.json → CREDIT_3.json} +0 -0
  51. data/cert_fixtures/CREDIT_3A.json +8 -0
  52. data/cert_fixtures/CREDIT_3B.json +8 -0
  53. data/cert_fixtures/{L_RC_4.json → CREDIT_4.json} +0 -0
  54. data/cert_fixtures/CREDIT_4A.json +8 -0
  55. data/cert_fixtures/CREDIT_4B.json +8 -0
  56. data/cert_fixtures/{L_RC_5.json → CREDIT_5.json} +0 -0
  57. data/cert_fixtures/CREDIT_5A.json +8 -0
  58. data/cert_fixtures/CREDIT_5B.json +8 -0
  59. data/cert_fixtures/{L_RC_6.json → SALE_1.json} +0 -0
  60. data/cert_fixtures/{L_S_2.json → SALE_2.json} +0 -0
  61. data/cert_fixtures/{L_S_3.json → SALE_3.json} +0 -0
  62. data/cert_fixtures/{L_S_4.json → SALE_4.json} +0 -0
  63. data/cert_fixtures/{L_S_5.json → SALE_5.json} +0 -0
  64. data/cert_fixtures/{L_S_6.json → SALE_6.json} +0 -0
  65. data/cert_fixtures/{L_S_7.json → SALE_7.json} +0 -0
  66. data/cert_fixtures/{L_S_8.json → SALE_8.json} +0 -0
  67. data/cert_fixtures/{L_S_9.json → SALE_9.json} +0 -0
  68. data/cert_fixtures/{L_S_1.json → SECURITY_CODE_FILTER_R1.json} +9 -9
  69. data/cert_fixtures/SECURITY_CODE_FILTER_R2.json +27 -0
  70. data/cert_fixtures/{L_T_1.json → TOKENIZATION_1.json} +0 -0
  71. data/cert_fixtures/{L_T_10.json → TOKENIZATION_10.json} +0 -0
  72. data/cert_fixtures/{L_T_11.json → TOKENIZATION_11.json} +0 -0
  73. data/cert_fixtures/{L_T_2.json → TOKENIZATION_2.json} +0 -0
  74. data/cert_fixtures/{L_T_3.json → TOKENIZATION_3.json} +0 -0
  75. data/cert_fixtures/{L_T_4.json → TOKENIZATION_4.json} +0 -0
  76. data/cert_fixtures/{L_T_6.json → TOKENIZATION_6.json} +0 -0
  77. data/cert_fixtures/{L_T_7.json → TOKENIZATION_7.json} +0 -0
  78. data/cert_fixtures/{L_T_8.json → TOKENIZATION_8.json} +0 -0
  79. data/cert_fixtures/{L_T_9.json → TOKENIZATION_9.json} +1 -1
  80. data/cert_fixtures/{L_V_1.json → VOID_1.json} +0 -0
  81. data/cert_fixtures/VOID_1A.json +8 -0
  82. data/cert_fixtures/VOID_1B.json +8 -0
  83. data/cert_fixtures/VOID_1C.json +8 -0
  84. data/cert_fixtures/{L_V_2.json → VOID_2.json} +0 -0
  85. data/cert_fixtures/VOID_2A.json +8 -0
  86. data/cert_fixtures/{L_V_3.json → VOID_3.json} +0 -0
  87. data/cert_fixtures/VOID_3A.json +8 -0
  88. data/cert_fixtures/{L_V_4.json → VOID_4.json} +0 -0
  89. data/cert_fixtures/VOID_4A.json +8 -0
  90. data/cert_fixtures/{L_EP_1.json → ePROTECT_1.json} +0 -0
  91. data/cert_fixtures/{L_EP_2.json → ePROTECT_2.json} +0 -0
  92. data/cert_fixtures/{L_EP_3.json → ePROTECT_3.json} +0 -0
  93. data/cert_fixtures/{L_EP_4.json → ePROTECT_4.json} +1 -1
  94. data/cert_fixtures/{L_EP_5.json → ePROTECT_5.json} +1 -1
  95. data/cert_fixtures/{L_EP_6.json → ePROTECT_6.json} +0 -0
  96. data/cert_fixtures/{L_EP_7.json → ePROTECT_7.json} +0 -0
  97. data/exe/vantiv-certify-app +18 -12
  98. data/lib/monkey_patches/representable/xml.rb +12 -0
  99. data/lib/vantiv.rb +39 -14
  100. data/lib/vantiv/api.rb +13 -1
  101. data/lib/vantiv/api/account_updater_response.rb +24 -29
  102. data/lib/vantiv/api/address.rb +8 -0
  103. data/lib/vantiv/api/apple_pay_response.rb +9 -0
  104. data/lib/vantiv/api/capture_response.rb +1 -1
  105. data/lib/vantiv/api/card.rb +47 -0
  106. data/lib/vantiv/api/cardholder_authentication.rb +11 -0
  107. data/lib/vantiv/api/fraud_result.rb +7 -0
  108. data/lib/vantiv/api/live_transaction_response.rb +4 -5
  109. data/lib/vantiv/api/payment_account.rb +11 -0
  110. data/lib/vantiv/api/request.rb +72 -33
  111. data/lib/vantiv/api/request_body.rb +100 -97
  112. data/lib/vantiv/api/request_body_representer.rb +54 -0
  113. data/lib/vantiv/api/request_body_representer_xml.rb +19 -0
  114. data/lib/vantiv/api/response.rb +9 -29
  115. data/lib/vantiv/api/response_body.rb +12 -0
  116. data/lib/vantiv/api/response_body_representer.rb +23 -0
  117. data/lib/vantiv/api/response_body_representer_xml.rb +25 -0
  118. data/lib/vantiv/api/tied_transaction_response.rb +5 -5
  119. data/lib/vantiv/api/tokenization_response.rb +15 -9
  120. data/lib/vantiv/api/transaction.rb +42 -0
  121. data/lib/vantiv/api/transaction_request_representer_xml.rb +57 -0
  122. data/lib/vantiv/api/transaction_response.rb +9 -0
  123. data/lib/vantiv/api/transaction_response_representer.rb +64 -0
  124. data/lib/vantiv/api/transaction_response_representer_xml.rb +54 -0
  125. data/lib/vantiv/certification/paypage_server.rb +13 -2
  126. data/lib/vantiv/certification/response_cache.rb +4 -12
  127. data/lib/vantiv/certification/validation_test_runner.rb +29 -10
  128. data/lib/vantiv/mocked_sandbox.rb +3 -2
  129. data/lib/vantiv/mocked_sandbox/api_request.rb +56 -27
  130. data/lib/vantiv/mocked_sandbox/fixture_generator.rb +56 -50
  131. data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457000300000007.json.erb → auth--4457000300000007.json} +18 -16
  132. data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457000301100004.json.erb → auth--4457000301100004.json} +16 -14
  133. data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457002100000005.json.erb → auth--4457002100000005.json} +10 -10
  134. data/lib/vantiv/mocked_sandbox/fixtures/{auth--4457010000000009.json.erb → auth--4457010000000009.json} +11 -11
  135. data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112000101110009.json.erb → auth--5112000101110009.json} +16 -16
  136. data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112001600000006.json.erb → auth--5112001600000006.json} +10 -10
  137. data/lib/vantiv/mocked_sandbox/fixtures/{auth--5112001900000003.json.erb → auth--5112001900000003.json} +10 -10
  138. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457000300000007.json.erb → auth_capture--4457000300000007.json} +18 -16
  139. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457000301100004.json.erb → auth_capture--4457000301100004.json} +16 -14
  140. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457002100000005.json.erb → auth_capture--4457002100000005.json} +10 -10
  141. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--4457010000000009.json.erb → auth_capture--4457010000000009.json} +11 -11
  142. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112000101110009.json.erb → auth_capture--5112000101110009.json} +16 -16
  143. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112001600000006.json.erb → auth_capture--5112001600000006.json} +10 -10
  144. data/lib/vantiv/mocked_sandbox/fixtures/{auth_capture--5112001900000003.json.erb → auth_capture--5112001900000003.json} +10 -10
  145. data/lib/vantiv/mocked_sandbox/fixtures/auth_reversal.json +21 -0
  146. data/lib/vantiv/mocked_sandbox/fixtures/capture.json +21 -0
  147. data/lib/vantiv/mocked_sandbox/fixtures/credit.json +21 -0
  148. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000300000007.json +22 -0
  149. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000301100004.json +22 -0
  150. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457002100000005.json +22 -0
  151. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457010000000009.json +22 -0
  152. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112000101110009.json +22 -0
  153. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001600000006.json +22 -0
  154. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001900000003.json +22 -0
  155. data/lib/vantiv/mocked_sandbox/fixtures/tokenize--RGFQNCt6U1d1M21SeVByVTM4dHlHb1FsVkUrSmpnWXhNY0o5UkMzRlZFanZiUHVnYjN1enJXbG1WSDF4aXlNc.json +17 -0
  156. data/lib/vantiv/mocked_sandbox/fixtures/tokenize--mocked-valid-temporary-token.json +23 -0
  157. data/lib/vantiv/mocked_sandbox/fixtures/tokenize--pDZJcmd1VjNlYXNaSlRMTGpocVZQY1NWVXE4Z W5UTko4NU9KK3p1L1p1Vzg4YzVPQVlSUHNITG1 JN2I0Nzl.json +17 -0
  158. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000300000007.json +23 -0
  159. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000301100004.json +23 -0
  160. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json +23 -0
  161. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json +23 -0
  162. data/lib/vantiv/mocked_sandbox/fixtures/{tokenize_by_direct_post--4457010010900010.json.erb → tokenize_by_direct_post--4457010010900010.json} +8 -8
  163. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112000101110009.json +23 -0
  164. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json +23 -0
  165. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json +23 -0
  166. data/lib/vantiv/mocked_sandbox/fixtures/void.json +21 -0
  167. data/lib/vantiv/mocked_sandbox/mocked_response_representer.rb +11 -0
  168. data/lib/vantiv/paypage.rb +5 -1
  169. data/lib/vantiv/test_temporary_token.rb +20 -0
  170. data/lib/vantiv/version.rb +1 -1
  171. data/vantiv-ruby.gemspec +5 -1
  172. metadata +191 -129
  173. data/cert_fixtures/L_AC_1A.json +0 -8
  174. data/cert_fixtures/L_AC_2A.json +0 -8
  175. data/cert_fixtures/L_AC_3A.json +0 -8
  176. data/cert_fixtures/L_AC_4A.json +0 -8
  177. data/cert_fixtures/L_AC_5A.json +0 -8
  178. data/cert_fixtures/L_AR_1B.json +0 -8
  179. data/cert_fixtures/L_AR_2A.json +0 -8
  180. data/cert_fixtures/L_AR_3A.json +0 -8
  181. data/cert_fixtures/L_RC_1A.json +0 -8
  182. data/cert_fixtures/L_RC_1B.json +0 -8
  183. data/cert_fixtures/L_RC_2A.json +0 -8
  184. data/cert_fixtures/L_RC_2B.json +0 -8
  185. data/cert_fixtures/L_RC_3A.json +0 -8
  186. data/cert_fixtures/L_RC_3B.json +0 -8
  187. data/cert_fixtures/L_RC_4A.json +0 -8
  188. data/cert_fixtures/L_RC_4B.json +0 -8
  189. data/cert_fixtures/L_RC_5A.json +0 -8
  190. data/cert_fixtures/L_RC_5B.json +0 -8
  191. data/cert_fixtures/L_RC_6A.json +0 -8
  192. data/cert_fixtures/L_RC_7.json +0 -26
  193. data/cert_fixtures/L_RC_7A.json +0 -8
  194. data/cert_fixtures/L_RC_8.json +0 -18
  195. data/cert_fixtures/L_V_1A.json +0 -8
  196. data/cert_fixtures/L_V_1B.json +0 -8
  197. data/cert_fixtures/L_V_1C.json +0 -8
  198. data/cert_fixtures/L_V_2A.json +0 -8
  199. data/cert_fixtures/L_V_3A.json +0 -8
  200. data/cert_fixtures/L_V_4A.json +0 -8
  201. data/lib/vantiv/api/request_body_generator.rb +0 -43
  202. data/lib/vantiv/mocked_sandbox/dynamic_response_body.rb +0 -40
  203. data/lib/vantiv/mocked_sandbox/fixtures/auth_reversal.json.erb +0 -21
  204. data/lib/vantiv/mocked_sandbox/fixtures/capture.json.erb +0 -21
  205. data/lib/vantiv/mocked_sandbox/fixtures/credit.json.erb +0 -21
  206. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000300000007.json.erb +0 -22
  207. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457000301100004.json.erb +0 -22
  208. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457002100000005.json.erb +0 -22
  209. data/lib/vantiv/mocked_sandbox/fixtures/refund--4457010000000009.json.erb +0 -22
  210. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112000101110009.json.erb +0 -22
  211. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001600000006.json.erb +0 -22
  212. data/lib/vantiv/mocked_sandbox/fixtures/refund--5112001900000003.json.erb +0 -22
  213. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000300000007.json.erb +0 -23
  214. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457000301100004.json.erb +0 -23
  215. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457002100000005.json.erb +0 -23
  216. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--4457010000000009.json.erb +0 -23
  217. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112000101110009.json.erb +0 -23
  218. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001600000006.json.erb +0 -23
  219. data/lib/vantiv/mocked_sandbox/fixtures/tokenize_by_direct_post--5112001900000003.json.erb +0 -23
  220. data/lib/vantiv/mocked_sandbox/fixtures/void.json.erb +0 -21
@@ -0,0 +1,54 @@
1
+ require 'representable/json'
2
+ require 'vantiv/api/card'
3
+ require 'vantiv/api/transaction'
4
+ require 'vantiv/api/payment_account'
5
+ require 'vantiv/api/address'
6
+
7
+ class RequestBodyRepresenter < Representable::Decorator
8
+ include Representable::JSON
9
+
10
+ nested :Credentials do
11
+ property :merchant_id, as: :AcceptorID
12
+ end
13
+
14
+ nested :Reports do
15
+ property :report_group, as: :ReportGroup
16
+ end
17
+
18
+ nested :Application do
19
+ property :application_id, as: :ApplicationID
20
+ end
21
+
22
+ property :transaction, as: :Transaction, class: Vantiv::Api::Transaction do
23
+ property :id, as: :TransactionID
24
+ property :order_id, as: :ReferenceNumber
25
+ property :amount, as: :TransactionAmount
26
+ property :order_source, as: :OrderSource
27
+ property :customer_id, as: :CustomerID
28
+ property :partial_approved_flag, as: :PartialApprovedFlag
29
+ end
30
+
31
+ property :card, as: :Card, class: Vantiv::Api::Card do
32
+ property :card_number, as: :CardNumber
33
+ property :account_number, as: :AccountNumber
34
+ property :expiry_month, as: :ExpirationMonth
35
+ property :expiry_year, as: :ExpirationYear
36
+ property :cvv, as: :CVV
37
+ property :type, as: :Type
38
+ property :paypage_registration_id, as: :PaypageRegistrationID
39
+ end
40
+
41
+ property :payment_account, as: :PaymentAccount, class: Vantiv::Api::PaymentAccount do
42
+ property :id, as: :PaymentAccountID
43
+ end
44
+
45
+ property :address, as: :Address, class: Vantiv::Api::Address do
46
+ property :billing_name, as: :BillingName
47
+ property :billing_address_1, as: :BillingAddress1
48
+ property :billing_address_2, as: :BillingAddress2
49
+ property :billing_city, as: :BillingCity
50
+ property :billing_state, as: :BillingState
51
+ property :billing_zipcode, as: :BillingZipcode
52
+ property :billing_country, as: :BillingCountry
53
+ end
54
+ end
@@ -0,0 +1,19 @@
1
+ require 'vantiv/api/transaction'
2
+ require 'vantiv/api/request_body'
3
+ require 'vantiv/api/transaction_request_representer_xml'
4
+
5
+ class RequestBodyRepresenterXml < Representable::Decorator
6
+ include Representable::XML
7
+ self.representation_wrap = :litleOnlineRequest
8
+
9
+ property :version, attribute: true
10
+ property :xmlns, attribute: true
11
+ property :merchant_id, as: :merchantId, attribute: true
12
+
13
+ property :authentication, class: Vantiv::Api::Authentication, as: :authentication do
14
+ property :user
15
+ property :password
16
+ end
17
+
18
+ property :transaction, class: Vantiv::Api::Transaction, decorator: TransactionRequestRepresenterXml
19
+ end
@@ -1,60 +1,40 @@
1
+ require "forwardable"
2
+
1
3
  module Vantiv
2
4
  module Api
3
5
  class Response
4
- attr_reader :httpok, :http_response_code, :body
6
+ extend Forwardable
5
7
 
6
- def load(httpok:, http_response_code:, body:)
7
- @httpok = httpok
8
- @http_response_code = http_response_code
9
- @body = body
10
- end
8
+ attr_accessor :httpok, :http_response_code, :body, :raw_body
11
9
 
12
- # Only returned by cert API?
13
- def request_id
14
- body["RequestID"]
15
- end
10
+ def_delegators :litle_transaction_response, :message, :response_code, :transaction_id
16
11
 
17
12
  def api_level_failure?
18
13
  !httpok || litle_response_has_error?
19
14
  end
20
15
 
21
- def message
22
- litle_transaction_response["message"]
23
- end
24
-
25
16
  def error_message
26
17
  api_level_failure? ? api_level_error_message : message
27
18
  end
28
19
 
29
- def response_code
30
- litle_transaction_response["response"]
31
- end
32
-
33
- def transaction_id
34
- litle_transaction_response["TransactionID"]
35
- end
36
-
37
20
  private
38
21
 
39
22
  def litle_response_has_error?
23
+ body.response == "3" ||
40
24
  # NOTE: this kind of sucks, but at the commit point, the DevHub
41
25
  # Api sometimes gives 200OK when litle had a parse issue and returns
42
26
  # 'Error validating xml data...' instead of an actual error
43
- !!@body["litleOnlineResponse"]["@message"].match(/error/i)
27
+ !!body.body_message.match(/error/i)
44
28
  end
45
29
 
46
30
  def api_level_error_message
47
- body["errormsg"]
31
+ "API level error"
48
32
  end
49
33
 
50
34
  attr_reader :transaction_response_name
51
35
 
52
- def litle_response
53
- api_level_failure? ? {} : body["litleOnlineResponse"]
54
- end
55
-
56
36
  def litle_transaction_response
57
- api_level_failure? ? {} : litle_response[transaction_response_name]
37
+ api_level_failure? ? TransactionResponse.new : body.send(transaction_response_name)
58
38
  end
59
39
  end
60
40
  end
@@ -0,0 +1,12 @@
1
+ module Vantiv
2
+ module Api
3
+ class ResponseBody
4
+ attr_writer :message, :response_code
5
+
6
+ attr_accessor :body_message, :response, :version, :request_id
7
+
8
+ attr_accessor :authorization_response, :sale_response, :credit_response, :void_response,
9
+ :auth_reversal_response, :capture_response, :register_token_response
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require 'representable/json'
2
+ require 'vantiv/api/transaction_response_representer'
3
+ require 'vantiv/api/response'
4
+
5
+ class ResponseBodyRepresenter < Representable::Decorator
6
+ include Representable::JSON
7
+
8
+ nested :litleOnlineResponse do
9
+ property :body_message, as: :@message
10
+ property :response, as: :@response
11
+ property :version, as: :@version
12
+
13
+ property :authorization_response, as: :authorizationResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
14
+ property :sale_response, as: :saleResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
15
+ property :credit_response, as: :creditResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
16
+ property :void_response, as: :voidResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
17
+ property :auth_reversal_response, as: :authReversalResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
18
+ property :capture_response, as: :captureResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
19
+ property :register_token_response, as: :registerTokenResponse, decorator: TransactionResponseRepresenter, class: Vantiv::Api::TransactionResponse
20
+ end
21
+
22
+ property :request_id, as: :RequestID
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'vantiv/api/transaction_response_representer_xml'
2
+ require 'vantiv/api/response'
3
+
4
+ class ResponseBodyRepresenterXml < Representable::Decorator
5
+ include Representable::XML
6
+
7
+ self.representation_wrap = :litleOnlineResponse
8
+ remove_namespaces!
9
+
10
+ property :body_message, as: :@message
11
+ property :response, as: :@response
12
+ property :version, as: :@version
13
+
14
+ property :authorization_response, as: :authorizationResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
15
+ property :sale_response, as: :saleResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
16
+ property :credit_response, as: :creditResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
17
+ property :void_response, as: :voidResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
18
+ property :auth_reversal_response, as: :authReversalResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
19
+ property :capture_response, as: :captureResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
20
+
21
+ property :register_token_response, as: :registerTokenResponse, decorator: TransactionResponseRepresenterXml, class: Vantiv::Api::TransactionResponse
22
+
23
+
24
+ property :request_id, as: :RequestID
25
+ end
@@ -6,11 +6,11 @@ module Vantiv
6
6
  }.freeze
7
7
 
8
8
  TIED_TRANSACTION_RESPONSE_NAMES = {
9
- auth_reversal: 'authReversalResponse',
10
- capture: "captureResponse",
11
- credit: "creditResponse",
12
- return: "creditResponse",
13
- void: "voidResponse"
9
+ auth_reversal: 'auth_reversal_response',
10
+ capture: "capture_response",
11
+ credit: "credit_response",
12
+ return: "credit_response",
13
+ void: "void_response"
14
14
  }
15
15
 
16
16
  def initialize(transaction_name)
@@ -1,6 +1,10 @@
1
+ require "forwardable"
2
+
1
3
  module Vantiv
2
4
  module Api
3
5
  class TokenizationResponse < Api::Response
6
+ extend Forwardable
7
+
4
8
  RESPONSE_CODES = {
5
9
  account_successfully_registered: '801',
6
10
  account_already_registered: '802',
@@ -14,6 +18,12 @@ module Vantiv
14
18
  generic_token_use_error: '899'
15
19
  }.freeze
16
20
 
21
+ def_delegators :litle_transaction_response, :payment_account_id
22
+
23
+ def card_type
24
+ litle_transaction_response.type
25
+ end
26
+
17
27
  def success?
18
28
  !api_level_failure? && tokenization_successful?
19
29
  end
@@ -22,18 +32,14 @@ module Vantiv
22
32
  !success?
23
33
  end
24
34
 
25
- def payment_account_id
26
- success? ? litle_transaction_response["PaymentAccountID"] : nil
27
- end
28
-
29
- def card_type
30
- success? ? litle_transaction_response["Type"] : nil
31
- end
32
-
33
35
  def invalid_card_number?
34
36
  response_code == RESPONSE_CODES[:credit_card_number_invalid]
35
37
  end
36
38
 
39
+ def apple_pay
40
+ @apple_pay ||=
41
+ litle_transaction_response.apple_pay_response || ApplePayResponse.new
42
+ end
37
43
  private
38
44
 
39
45
  def tokenization_successful?
@@ -42,7 +48,7 @@ module Vantiv
42
48
  end
43
49
 
44
50
  def transaction_response_name
45
- "registerTokenResponse"
51
+ "register_token_response"
46
52
  end
47
53
  end
48
54
  end
@@ -0,0 +1,42 @@
1
+ module Vantiv
2
+ module Api
3
+ class Transaction
4
+ attr_accessor :id, :order_id, :customer_id, :order_source, :partial_approved_flag,
5
+ :amount_in_cents, :report_group, :card, :type, :application_id, :address,
6
+ :cardholder_authentication
7
+
8
+ def initialize(id: nil, amount_in_cents: nil, order_id: nil, customer_id: nil,
9
+ partial_approved_flag: nil, order_source: nil, cardholder_authentication: nil)
10
+ @id = id
11
+ @amount_in_cents = amount_in_cents
12
+ @order_id = order_id
13
+ @customer_id = customer_id
14
+ @partial_approved_flag = partial_approved_flag
15
+ @order_source = order_source
16
+ @cardholder_authentication = cardholder_authentication
17
+ end
18
+
19
+ def amount
20
+ format_cents_to_decimal(@amount_in_cents) if @amount_in_cents
21
+ end
22
+
23
+ def amount=(value)
24
+ @amount_in_cents = decimal_string_to_cents(value)
25
+ end
26
+
27
+ def order_id
28
+ @order_id.to_s if @order_id
29
+ end
30
+
31
+ private
32
+
33
+ def decimal_string_to_cents(string)
34
+ (string.to_f * 100.0).to_i
35
+ end
36
+
37
+ def format_cents_to_decimal(cents)
38
+ '%.2f' % (cents / 100.0)
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,57 @@
1
+ class TransactionRequestRepresenterXml < Representable::Decorator
2
+ include Representable::XML
3
+
4
+ self.representation_wrap = ->(_) { type }
5
+
6
+ property :application_id, as: :id, attribute: true
7
+ property :id, as: :litleTxnId
8
+ property :report_group, as: :reportGroup, attribute: true
9
+ property :customer_id, as: :customerId, attribute: true
10
+ property :order_id, as: :orderId
11
+ property :amount_in_cents, as: :amount
12
+ property :order_source, as: :orderSource
13
+
14
+ property :address, class: Vantiv::Api::Address do
15
+ self.representation_wrap = :billToAddress
16
+
17
+ property :billing_name, as: :name
18
+ property :billing_address_1, as: :addressLine1
19
+ property :billing_address_2, as: :addressLine2
20
+ property :billing_city, as: :city
21
+ property :billing_state, as: :state
22
+ property :billing_zipcode, as: :zip
23
+ property :billing_country, as: :country
24
+ end
25
+
26
+ property :card, class: Vantiv::Api::Card, if: ->(_) { type != :registerTokenRequest && !card&.paypage_registration_id } do
27
+ self.representation_wrap = ->(_) { !!payment_account_id ? :token : :card }
28
+
29
+ property :type
30
+ property :card_number, as: :number
31
+ property :account_number, as: :number
32
+ property :payment_account_id, as: :litleToken
33
+ property :expDate,
34
+ getter: ->(represented:, **) { represented.expiry_month.to_s + represented.expiry_year.to_s },
35
+ if: ->(_) { expiry_month && expiry_year }
36
+ property :cvv, as: :cardValidationNum
37
+ end
38
+
39
+ property :accountNumber,
40
+ if: ->(_) { type == :registerTokenRequest },
41
+ getter: ->(represented:, **) { represented.card&.account_number }
42
+
43
+ property :cardValidationNum,
44
+ if: ->(_) { type == :registerTokenRequest },
45
+ getter: ->(represented:, **) { represented.card&.cvv }
46
+
47
+ property :paypageRegistrationId,
48
+ getter: ->(represented:, **) { represented.card&.paypage_registration_id }
49
+
50
+ property :cardholder_authentication, class: Vantiv::Api::CardholderAuthentication do
51
+ self.representation_wrap = :cardholderAuthentication
52
+
53
+ property :authentication_value, as: :authenticationValue
54
+ end
55
+
56
+ property :partial_approved_flag, as: :allowPartialAuth
57
+ end
@@ -0,0 +1,9 @@
1
+ module Vantiv
2
+ module Api
3
+ class TransactionResponse
4
+ attr_accessor :message, :response_code, :transaction_id, :response_time, :id, :report_group, :payment_account_id,
5
+ :post_date, :type, :bin, :auth_code, :customer_id, :order_id, :token_response_code, :token_message,
6
+ :fraud_result, :account_updater, :token_response, :apple_pay_response
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,64 @@
1
+ require 'representable/json'
2
+ require 'vantiv/api/account_updater_response'
3
+ require 'vantiv/api/apple_pay_response'
4
+
5
+ class TransactionResponseRepresenter < Representable::Decorator
6
+ include Representable::JSON
7
+
8
+ property :auth_code, as: :authCode
9
+ property :customer_id, as: :@customerId
10
+ property :order_id, as: :orderId
11
+
12
+ property :response_code, as: :response
13
+ property :response_time, as: :responseTime
14
+ property :post_date, as: :postDate
15
+ property :id, as: :@id
16
+
17
+ property :fraud_result, as: :fraudResult, class: Vantiv::Api::FraudResult do
18
+ property :avs_result, as: :avsResult
19
+ property :card_validation_result, as: :cardValidationResult
20
+ end
21
+
22
+ property :message
23
+ property :report_group, as: :@reportGroup
24
+ property :transaction_id, as: :TransactionID
25
+
26
+ property :token_response_code, as: :tokenResponseCode
27
+ property :token_message, as: :tokenMessage
28
+ property :type, as: :Type
29
+ property :bin
30
+ property :payment_account_id, as: :PaymentAccountID
31
+
32
+ property :account_updater, as: :accountUpdater, class: Vantiv::Api::AccountUpdaterResponse do
33
+ property :original_card_token_info, as: :originalCardTokenInfo, class: Vantiv::Api::CardTokenInfo do
34
+ property :bin
35
+ property :card_type, as: :Type
36
+ property :payment_account_id, as: :PaymentAccountID
37
+ property :expiry_month, as: :ExpirationMonth
38
+ property :expiry_year, as: :ExpirationYear
39
+ end
40
+
41
+ property :new_card_token_info, as: :newCardTokenInfo, class: Vantiv::Api::CardTokenInfo do
42
+ property :bin
43
+ property :card_type, as: :Type
44
+ property :payment_account_id, as: :PaymentAccountID
45
+ property :expiry_month, as: :ExpirationMonth
46
+ property :expiry_year, as: :ExpirationYear
47
+ end
48
+
49
+ property :extended_card_response, as: :extendedCardResponse, class: Vantiv::Api::ExtendedCardResponse do
50
+ property :code
51
+ property :message
52
+ end
53
+ end
54
+
55
+ property :token_response, as: :tokenResponse, class: Vantiv::Api::CardTokenInfo do
56
+ property :bin
57
+ property :card_type, as: :Type
58
+ property :payment_account_id, as: :PaymentAccountID
59
+ end
60
+
61
+ property :apple_pay_response, as: :applepayResponse, class: Vantiv::Api::ApplePayResponse do
62
+ property :online_payment_cryptogram, as: :onlinePaymentCryptogram
63
+ end
64
+ end