spreedly 2.0.11 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY.md +29 -0
  3. data/README.md +17 -6
  4. data/lib/spreedly.rb +4 -0
  5. data/lib/spreedly/connection.rb +0 -1
  6. data/lib/spreedly/environment.rb +61 -3
  7. data/lib/spreedly/gateway_class.rb +4 -3
  8. data/lib/spreedly/payment_methods/credit_card.rb +2 -1
  9. data/lib/spreedly/receiver.rb +30 -0
  10. data/lib/spreedly/transactions/deliver_payment_method.rb +31 -0
  11. data/lib/spreedly/transactions/recache_sensitive_data.rb +17 -0
  12. data/lib/spreedly/transactions/transaction.rb +6 -0
  13. data/lib/spreedly/transactions/verification.rb +12 -0
  14. data/lib/spreedly/urls.rb +12 -0
  15. data/lib/spreedly/version.rb +1 -1
  16. data/test/remote/remote_add_gateway_test.rb +1 -3
  17. data/test/remote/remote_add_receiver_test.rb +40 -0
  18. data/test/remote/remote_deliver_payment_method_test.rb +65 -0
  19. data/test/remote/remote_update_credit_card_test.rb +3 -1
  20. data/test/remote/remote_verify_test.rb +48 -0
  21. data/test/unit/add_receiver_test.rb +53 -0
  22. data/test/unit/deliver_payment_method_test.rb +73 -0
  23. data/test/unit/find_payment_method_test.rb +1 -0
  24. data/test/unit/gateway_options_test.rb +1 -0
  25. data/test/unit/response_stubs/add_credit_card_stubs.rb +3 -0
  26. data/test/unit/response_stubs/add_gateway_stubs.rb +1 -0
  27. data/test/unit/response_stubs/add_receiver_stubs.rb +26 -0
  28. data/test/unit/response_stubs/authorization_stubs.rb +4 -0
  29. data/test/unit/response_stubs/deliver_payment_method_stubs.rb +80 -0
  30. data/test/unit/response_stubs/find_gateway_stubs.rb +1 -0
  31. data/test/unit/response_stubs/find_payment_method_stubs.rb +5 -1
  32. data/test/unit/response_stubs/find_transaction_stubs.rb +4 -0
  33. data/test/unit/response_stubs/gateway_options_stubs.rb +4 -0
  34. data/test/unit/response_stubs/list_gateways_stubs.rb +2 -0
  35. data/test/unit/response_stubs/list_payment_methods_stubs.rb +4 -0
  36. data/test/unit/response_stubs/list_transactions_stubs.rb +2 -0
  37. data/test/unit/response_stubs/purchase_stubs.rb +4 -0
  38. data/test/unit/response_stubs/redact_gateway_stubs.rb +1 -0
  39. data/test/unit/response_stubs/redact_payment_method_stubs.rb +2 -0
  40. data/test/unit/response_stubs/retain_payment_method_stubs.rb +4 -0
  41. data/test/unit/response_stubs/update_credit_card_stubs.rb +2 -0
  42. data/test/unit/response_stubs/verification_stubs.rb +143 -0
  43. data/test/unit/verify_test.rb +81 -0
  44. metadata +25 -4
  45. data/lib/certs/cacert.pem +0 -7815
@@ -13,6 +13,7 @@ module FindGatewayStubs
13
13
  <supports_authorize type="boolean">true</supports_authorize>
14
14
  <supports_capture type="boolean">true</supports_capture>
15
15
  <supports_credit type="boolean">false</supports_credit>
16
+ <supports_general_credit type="boolean">false</supports_general_credit>
16
17
  <supports_void type="boolean">false</supports_void>
17
18
  <supports_reference_purchase type="boolean">false</supports_reference_purchase>
18
19
  <supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
@@ -12,6 +12,7 @@ module FindPaymentMethodStubs
12
12
  </data>
13
13
  <storage_state>retained</storage_state>
14
14
  <last_four_digits>4445</last_four_digits>
15
+ <first_six_digits>411111</first_six_digits>
15
16
  <card_type>master</card_type>
16
17
  <first_name>Alcatraz</first_name>
17
18
  <last_name>Smedry</last_name>
@@ -26,6 +27,7 @@ module FindPaymentMethodStubs
26
27
  <phone_number>201.344.7712</phone_number>
27
28
  <full_name>Alcatraz Smedry</full_name>
28
29
  <payment_method_type>credit_card</payment_method_type>
30
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
29
31
  <errors>
30
32
  </errors>
31
33
  <verification_value></verification_value>
@@ -45,7 +47,8 @@ module FindPaymentMethodStubs
45
47
  <how_many>2</how_many>
46
48
  </data>
47
49
  <storage_state>redacted</storage_state>
48
- <last_four_digits>1881</last_four_digits>
50
+ <last_four_digits></last_four_digits>
51
+ <first_six_digits></first_six_digits>
49
52
  <card_type nil="true"/>
50
53
  <first_name></first_name>
51
54
  <last_name></last_name>
@@ -60,6 +63,7 @@ module FindPaymentMethodStubs
60
63
  <phone_number nil="true"/>
61
64
  <full_name></full_name>
62
65
  <payment_method_type>credit_card</payment_method_type>
66
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
63
67
  <errors>
64
68
  <error attribute="first_name" key="errors.blank">First name can't be blank</error>
65
69
  <error attribute="last_name" key="errors.blank">Last name can't be blank</error>
@@ -19,6 +19,7 @@ module FindTransactionStubs
19
19
  <data nil="true"/>
20
20
  <storage_state>retained</storage_state>
21
21
  <last_four_digits>4444</last_four_digits>
22
+ <first_six_digits>411111</first_six_digits>
22
23
  <card_type>master</card_type>
23
24
  <first_name>Perrin</first_name>
24
25
  <last_name>Aybara</last_name>
@@ -33,6 +34,7 @@ module FindTransactionStubs
33
34
  <phone_number nil="true"/>
34
35
  <full_name>Perrin Aybara</full_name>
35
36
  <payment_method_type>credit_card</payment_method_type>
37
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
36
38
  <errors>
37
39
  </errors>
38
40
  <verification_value></verification_value>
@@ -72,6 +74,7 @@ module FindTransactionStubs
72
74
  <data nil="true"/>
73
75
  <storage_state>retained</storage_state>
74
76
  <last_four_digits>2111</last_four_digits>
77
+ <first_six_digits>411111</first_six_digits>
75
78
  <card_type>visa</card_type>
76
79
  <first_name>Jonathan</first_name>
77
80
  <last_name>Phaedrus</last_name>
@@ -86,6 +89,7 @@ module FindTransactionStubs
86
89
  <phone_number nil="true"/>
87
90
  <full_name>Jonathan Phaedrus</full_name>
88
91
  <payment_method_type>credit_card</payment_method_type>
92
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
89
93
  <errors>
90
94
  </errors>
91
95
  <verification_value></verification_value>
@@ -67,7 +67,9 @@ module GatewayOptionsStubs
67
67
  <supports_authorize type="boolean">true</supports_authorize>
68
68
  <supports_capture type="boolean">true</supports_capture>
69
69
  <supports_credit type="boolean">true</supports_credit>
70
+ <supports_general_credit type="boolean">true</supports_general_credit>
70
71
  <supports_void type="boolean">true</supports_void>
72
+ <supports_verify type="boolean">true</supports_verify>
71
73
  <supports_reference_purchase type="boolean">true</supports_reference_purchase>
72
74
  <supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
73
75
  <supports_offsite_purchase type="boolean">true</supports_offsite_purchase>
@@ -115,7 +117,9 @@ module GatewayOptionsStubs
115
117
  <supports_authorize type="boolean">true</supports_authorize>
116
118
  <supports_capture type="boolean">true</supports_capture>
117
119
  <supports_credit type="boolean">true</supports_credit>
120
+ <supports_general_credit type="boolean">true</supports_general_credit>
118
121
  <supports_void type="boolean">true</supports_void>
122
+ <supports_verify type="boolean">true</supports_verify>
119
123
  <supports_reference_purchase type="boolean">true</supports_reference_purchase>
120
124
  <supports_purchase_via_preauthorization type="boolean">false</supports_purchase_via_preauthorization>
121
125
  <supports_offsite_purchase type="boolean">false</supports_offsite_purchase>
@@ -12,6 +12,7 @@ module ListGatewaysStubs
12
12
  <supports_authorize type="boolean">true</supports_authorize>
13
13
  <supports_capture type="boolean">true</supports_capture>
14
14
  <supports_credit type="boolean">true</supports_credit>
15
+ <supports_general_credit type="boolean">true</supports_general_credit>
15
16
  <supports_void type="boolean">true</supports_void>
16
17
  <supports_reference_purchase type="boolean">true</supports_reference_purchase>
17
18
  <supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
@@ -45,6 +46,7 @@ module ListGatewaysStubs
45
46
  <supports_authorize type="boolean">true</supports_authorize>
46
47
  <supports_capture type="boolean">true</supports_capture>
47
48
  <supports_credit type="boolean">true</supports_credit>
49
+ <supports_general_credit type="boolean">true</supports_general_credit>
48
50
  <supports_void type="boolean">true</supports_void>
49
51
  <supports_reference_purchase type="boolean">true</supports_reference_purchase>
50
52
  <supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
@@ -11,6 +11,7 @@ module ListPaymentMethodsStubs
11
11
  <data nil="true"/>
12
12
  <storage_state>retained</storage_state>
13
13
  <last_four_digits>4444</last_four_digits>
14
+ <first_six_digits>411111</first_six_digits>
14
15
  <card_type>master</card_type>
15
16
  <first_name>Perrin</first_name>
16
17
  <last_name>Aybara</last_name>
@@ -25,6 +26,7 @@ module ListPaymentMethodsStubs
25
26
  <phone_number nil="true"/>
26
27
  <full_name>Perrin Aybara</full_name>
27
28
  <payment_method_type>credit_card</payment_method_type>
29
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
28
30
  <errors>
29
31
  </errors>
30
32
  <verification_value></verification_value>
@@ -38,6 +40,7 @@ module ListPaymentMethodsStubs
38
40
  <data nil="true"/>
39
41
  <storage_state>retained</storage_state>
40
42
  <last_four_digits>4444</last_four_digits>
43
+ <first_six_digits>411111</first_six_digits>
41
44
  <card_type>master</card_type>
42
45
  <first_name>Mat</first_name>
43
46
  <last_name>Cauthon</last_name>
@@ -52,6 +55,7 @@ module ListPaymentMethodsStubs
52
55
  <phone_number nil="true"/>
53
56
  <full_name>Mat Cauthon</full_name>
54
57
  <payment_method_type>credit_card</payment_method_type>
58
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
55
59
  <errors>
56
60
  </errors>
57
61
  <verification_value></verification_value>
@@ -45,6 +45,7 @@ module ListTransactionsStubs
45
45
  <data nil="true"/>
46
46
  <storage_state>retained</storage_state>
47
47
  <last_four_digits>4444</last_four_digits>
48
+ <first_six_digits>411111</first_six_digits>
48
49
  <card_type>master</card_type>
49
50
  <first_name>Perrin</first_name>
50
51
  <last_name>Aybara</last_name>
@@ -59,6 +60,7 @@ module ListTransactionsStubs
59
60
  <phone_number nil="true"/>
60
61
  <full_name>Perrin Aybara</full_name>
61
62
  <payment_method_type>credit_card</payment_method_type>
63
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
62
64
  <errors>
63
65
  </errors>
64
66
  <verification_value></verification_value>
@@ -44,6 +44,7 @@ module PurchaseStubs
44
44
  <data nil="true"/>
45
45
  <storage_state>retained</storage_state>
46
46
  <last_four_digits>4444</last_four_digits>
47
+ <first_six_digits>411111</first_six_digits>
47
48
  <card_type>master</card_type>
48
49
  <first_name>Perrin</first_name>
49
50
  <last_name>Aybara</last_name>
@@ -58,6 +59,7 @@ module PurchaseStubs
58
59
  <phone_number nil="true"/>
59
60
  <full_name>Perrin Aybara</full_name>
60
61
  <payment_method_type>credit_card</payment_method_type>
62
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
61
63
  <errors>
62
64
  </errors>
63
65
  <verification_value></verification_value>
@@ -113,6 +115,7 @@ module PurchaseStubs
113
115
  <data nil="true"/>
114
116
  <storage_state>retained</storage_state>
115
117
  <last_four_digits>1881</last_four_digits>
118
+ <first_six_digits>411111</first_six_digits>
116
119
  <card_type>visa</card_type>
117
120
  <first_name>Perrin</first_name>
118
121
  <last_name>Aybara</last_name>
@@ -127,6 +130,7 @@ module PurchaseStubs
127
130
  <phone_number nil="true"/>
128
131
  <full_name>Perrin Aybara</full_name>
129
132
  <payment_method_type>credit_card</payment_method_type>
133
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
130
134
  <errors>
131
135
  </errors>
132
136
  <verification_value></verification_value>
@@ -18,6 +18,7 @@ module RedactGatewayStubs
18
18
  <supports_authorize type="boolean">true</supports_authorize>
19
19
  <supports_capture type="boolean">true</supports_capture>
20
20
  <supports_credit type="boolean">true</supports_credit>
21
+ <supports_general_credit type="boolean">true</supports_general_credit>
21
22
  <supports_void type="boolean">true</supports_void>
22
23
  <supports_reference_purchase type="boolean">true</supports_reference_purchase>
23
24
  <supports_purchase_via_preauthorization type="boolean">true</supports_purchase_via_preauthorization>
@@ -23,6 +23,7 @@ module RedactPaymentMethodStubs
23
23
  <data nil="true"/>
24
24
  <storage_state>redacted</storage_state>
25
25
  <last_four_digits>4444</last_four_digits>
26
+ <first_six_digits>411111</first_six_digits>
26
27
  <card_type>master</card_type>
27
28
  <first_name>Perrin</first_name>
28
29
  <last_name>Aybara</last_name>
@@ -37,6 +38,7 @@ module RedactPaymentMethodStubs
37
38
  <phone_number nil="true"/>
38
39
  <full_name>Perrin Aybara</full_name>
39
40
  <payment_method_type>credit_card</payment_method_type>
41
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
40
42
  <errors>
41
43
  </errors>
42
44
  <verification_value></verification_value>
@@ -18,6 +18,7 @@ module RetainPaymentMethodStubs
18
18
  <data nil="true"/>
19
19
  <storage_state>retained</storage_state>
20
20
  <last_four_digits>4444</last_four_digits>
21
+ <first_six_digits>411111</first_six_digits>
21
22
  <card_type>master</card_type>
22
23
  <first_name>Perrin</first_name>
23
24
  <last_name>Aybara</last_name>
@@ -32,6 +33,7 @@ module RetainPaymentMethodStubs
32
33
  <phone_number nil="true"/>
33
34
  <full_name>Perrin Aybara</full_name>
34
35
  <payment_method_type>credit_card</payment_method_type>
36
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
35
37
  <errors>
36
38
  </errors>
37
39
  <verification_value></verification_value>
@@ -59,6 +61,7 @@ module RetainPaymentMethodStubs
59
61
  <data nil="true"/>
60
62
  <storage_state>redacted</storage_state>
61
63
  <last_four_digits>4444</last_four_digits>
64
+ <first_six_digits>411111</first_six_digits>
62
65
  <card_type>master</card_type>
63
66
  <first_name>Perrin</first_name>
64
67
  <last_name>Aybara</last_name>
@@ -73,6 +76,7 @@ module RetainPaymentMethodStubs
73
76
  <phone_number nil="true"/>
74
77
  <full_name>Perrin Aybara</full_name>
75
78
  <payment_method_type>credit_card</payment_method_type>
79
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
76
80
  <errors>
77
81
  </errors>
78
82
  <verification_value></verification_value>
@@ -10,6 +10,7 @@ module UpdateCreditCardStubs
10
10
  <data nil="true"/>
11
11
  <storage_state>retained</storage_state>
12
12
  <last_four_digits>4444</last_four_digits>
13
+ <first_six_digits>411111</first_six_digits>
13
14
  <card_type>master</card_type>
14
15
  <first_name>Mat</first_name>
15
16
  <last_name>Cauthon</last_name>
@@ -24,6 +25,7 @@ module UpdateCreditCardStubs
24
25
  <phone_number nil="true"/>
25
26
  <full_name>Mat Cauthon</full_name>
26
27
  <payment_method_type>credit_card</payment_method_type>
28
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
27
29
  <errors>
28
30
  </errors>
29
31
  <verification_value></verification_value>
@@ -0,0 +1,143 @@
1
+ module VerificationStubs
2
+
3
+ def successful_verify_response
4
+ StubResponse.succeeded <<-XML
5
+ <transaction>
6
+ <on_test_gateway type="boolean">true</on_test_gateway>
7
+ <created_at type="datetime">2014-07-03T19:43:19Z</created_at>
8
+ <updated_at type="datetime">2014-07-03T19:43:20Z</updated_at>
9
+ <succeeded type="boolean">true</succeeded>
10
+ <token>CSCoubzCMgrD4FAv1CRmucVTxTQ</token>
11
+ <state>succeeded</state>
12
+ <retain_on_success type="boolean">false</retain_on_success>
13
+ <gateway_specific_fields nil="true"/>
14
+ <gateway_specific_response_fields nil="true"/>
15
+ <transaction_type>Verification</transaction_type>
16
+ <order_id>99a1</order_id>
17
+ <ip>182.129.106.102</ip>
18
+ <description>LotsOCoffee</description>
19
+ <merchant_name_descriptor>My Writeoff Inc.</merchant_name_descriptor>
20
+ <merchant_location_descriptor>Tax Free Zone</merchant_location_descriptor>
21
+ <merchant_name_descriptor nil="true"/>
22
+ <merchant_location_descriptor nil="true"/>
23
+ <gateway_transaction_id>49</gateway_transaction_id>
24
+ <message key="messages.transaction_succeeded">Succeeded!</message>
25
+ <gateway_token>LoxFMxQJD5E1ksAwFWykUamaCKE</gateway_token>
26
+ <response>
27
+ <success type="boolean">true</success>
28
+ <message>Successful verify</message>
29
+ <avs_code nil="true"/>
30
+ <avs_message nil="true"/>
31
+ <cvv_code nil="true"/>
32
+ <cvv_message nil="true"/>
33
+ <pending type="boolean">false</pending>
34
+ <error_code/>
35
+ <error_detail nil="true"/>
36
+ <cancelled type="boolean">false</cancelled>
37
+ <created_at type="datetime">2014-07-03T19:43:19Z</created_at>
38
+ <updated_at type="datetime">2014-07-03T19:43:19Z</updated_at>
39
+ </response>
40
+ <payment_method>
41
+ <token>98626DYInHb4K86dp6GrocnZOW6</token>
42
+ <created_at type="datetime">2014-07-03T19:43:18Z</created_at>
43
+ <updated_at type="datetime">2014-07-03T19:43:19Z</updated_at>
44
+ <email>perrin@wot.com</email>
45
+ <data nil="true"/>
46
+ <storage_state>retained</storage_state>
47
+ <test type="boolean">true</test>
48
+ <last_four_digits>4444</last_four_digits>
49
+ <first_six_digits>411111</first_six_digits>
50
+ <card_type>master</card_type>
51
+ <first_name>Perrin</first_name>
52
+ <last_name>Aybara</last_name>
53
+ <month type="integer">1</month>
54
+ <year type="integer">2019</year>
55
+ <address1 nil="true"/>
56
+ <address2 nil="true"/>
57
+ <city nil="true"/>
58
+ <state nil="true"/>
59
+ <zip nil="true"/>
60
+ <country nil="true"/>
61
+ <phone_number nil="true"/>
62
+ <full_name>Perrin Aybara</full_name>
63
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
64
+ <payment_method_type>credit_card</payment_method_type>
65
+ <errors>
66
+ </errors>
67
+ <verification_value/>
68
+ <number>XXXX-XXXX-XXXX-4444</number>
69
+ </payment_method>
70
+ </transaction>
71
+ XML
72
+ end
73
+
74
+ def failed_verify_response
75
+ StubResponse.failed <<-XML
76
+ <transaction>
77
+ <on_test_gateway type="boolean">true</on_test_gateway>
78
+ <created_at type="datetime">2014-07-03T19:44:28Z</created_at>
79
+ <updated_at type="datetime">2014-07-03T19:44:28Z</updated_at>
80
+ <succeeded type="boolean">false</succeeded>
81
+ <token>LoXHEUXYFDCxGLGcG94JVh9FKmE</token>
82
+ <state>gateway_processing_failed</state>
83
+ <retain_on_success type="boolean">false</retain_on_success>
84
+ <gateway_specific_fields nil="true"/>
85
+ <gateway_specific_response_fields nil="true"/>
86
+ <transaction_type>Verification</transaction_type>
87
+ <order_id nil="true"/>
88
+ <ip nil="true"/>
89
+ <description nil="true"/>
90
+ <merchant_name_descriptor nil="true"/>
91
+ <merchant_location_descriptor nil="true"/>
92
+ <gateway_transaction_id nil="true"/>
93
+ <message>Unable to process the verify transaction.</message>
94
+ <gateway_token>XpnCSoIOpESZsDMTxnXrcYmtWzq</gateway_token>
95
+ <response>
96
+ <success type="boolean">false</success>
97
+ <message>Unable to process the verify transaction.</message>
98
+ <avs_code nil="true"/>
99
+ <avs_message nil="true"/>
100
+ <cvv_code nil="true"/>
101
+ <cvv_message nil="true"/>
102
+ <pending type="boolean">false</pending>
103
+ <error_code/>
104
+ <error_detail>What up with that?</error_detail>
105
+ <cancelled type="boolean">false</cancelled>
106
+ <created_at type="datetime">2014-07-03T19:44:28Z</created_at>
107
+ <updated_at type="datetime">2014-07-03T19:44:28Z</updated_at>
108
+ </response>
109
+ <payment_method>
110
+ <token>M6oqAYOZe1OVnwhzNWr0DyWzV83</token>
111
+ <created_at type="datetime">2014-07-03T19:44:27Z</created_at>
112
+ <updated_at type="datetime">2014-07-03T19:44:27Z</updated_at>
113
+ <email>perrin@wot.com</email>
114
+ <data nil="true"/>
115
+ <storage_state>retained</storage_state>
116
+ <test type="boolean">true</test>
117
+ <last_four_digits>1881</last_four_digits>
118
+ <first_six_digits>401288</first_six_digits>
119
+ <card_type>visa</card_type>
120
+ <first_name>Perrin</first_name>
121
+ <last_name>Aybara</last_name>
122
+ <month type="integer">1</month>
123
+ <year type="integer">2019</year>
124
+ <address1 nil="true"/>
125
+ <address2 nil="true"/>
126
+ <city nil="true"/>
127
+ <state nil="true"/>
128
+ <zip nil="true"/>
129
+ <country nil="true"/>
130
+ <phone_number nil="true"/>
131
+ <full_name>Perrin Aybara</full_name>
132
+ <eligible_for_card_updater type="boolean">true</eligible_for_card_updater>
133
+ <payment_method_type>credit_card</payment_method_type>
134
+ <errors>
135
+ </errors>
136
+ <verification_value/>
137
+ <number>XXXX-XXXX-XXXX-1881</number>
138
+ </payment_method>
139
+ </transaction>
140
+ XML
141
+ end
142
+
143
+ end
@@ -0,0 +1,81 @@
1
+ require 'test_helper'
2
+ require 'unit/response_stubs/verification_stubs'
3
+
4
+ class VerifyTest < Test::Unit::TestCase
5
+
6
+ include VerificationStubs
7
+
8
+ def setup
9
+ @environment = Spreedly::Environment.new("key", "secret")
10
+ end
11
+
12
+ def test_successful_verify
13
+ t = verify_using(successful_verify_response)
14
+
15
+ assert_kind_of(Spreedly::Verification, t)
16
+ assert_equal 'CSCoubzCMgrD4FAv1CRmucVTxTQ', t.token
17
+ assert t.on_test_gateway?
18
+ assert_equal Time.parse("2014-07-03T19:43:19Z"), t.created_at
19
+ assert_equal Time.parse("2014-07-03T19:43:20Z"), t.updated_at
20
+ assert t.succeeded?
21
+ assert_equal 'succeeded', t.state
22
+ assert_equal '99a1', t.order_id
23
+ assert_equal '182.129.106.102', t.ip
24
+ assert_equal 'LotsOCoffee', t.description
25
+ assert_equal 'My Writeoff Inc.', t.merchant_name_descriptor
26
+ assert_equal 'Tax Free Zone', t.merchant_location_descriptor
27
+ assert_equal 'LoxFMxQJD5E1ksAwFWykUamaCKE', t.gateway_token
28
+ assert_equal "49", t.gateway_transaction_id
29
+
30
+ assert_equal '98626DYInHb4K86dp6GrocnZOW6', t.payment_method.token
31
+ assert_equal 'Aybara', t.payment_method.last_name
32
+
33
+ assert t.response.success
34
+ assert_equal 'Successful verify', t.response.message
35
+ end
36
+
37
+ def test_failed_authorize
38
+ t = verify_using(failed_verify_response)
39
+
40
+ assert_kind_of(Spreedly::Verification, t)
41
+ assert_equal 'LoXHEUXYFDCxGLGcG94JVh9FKmE', t.token
42
+ assert !t.succeeded?
43
+ assert_equal 'gateway_processing_failed', t.state
44
+ assert_equal 'What up with that?', t.response.error_detail
45
+ end
46
+
47
+ def test_request_body_params
48
+ body = get_request_body(successful_verify_response) do
49
+ @environment.verify_on_gateway("TheGatewayToken", "TheCardToken", all_possible_options)
50
+ end
51
+
52
+ transaction = body.xpath('./transaction')
53
+ assert_xpaths_in transaction,
54
+ [ './payment_method_token', 'TheCardToken' ],
55
+ [ './order_id', '8669' ],
56
+ [ './description', 'Gold Farmin' ],
57
+ [ './ip', '183.128.100.102' ],
58
+ [ './merchant_name_descriptor', 'TRain' ],
59
+ [ './merchant_location_descriptor', 'British Colombia' ],
60
+ [ './retain_on_success', 'true' ]
61
+ end
62
+
63
+
64
+ private
65
+ def verify_using(response)
66
+ @environment.stubs(:raw_ssl_request).returns(response)
67
+ @environment.verify_on_gateway("IgnoredGatewayTokenSinceResponseIsStubbed", "IgnoredPaymentMethodTokenSinceResponseIsStubbed")
68
+ end
69
+
70
+ def all_possible_options
71
+ {
72
+ order_id: "8669",
73
+ description: "Gold Farmin",
74
+ ip: "183.128.100.102",
75
+ merchant_name_descriptor: "TRain",
76
+ merchant_location_descriptor: "British Colombia",
77
+ retain_on_success: true
78
+ }
79
+ end
80
+
81
+ end