braintree 4.26.0 → 4.28.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.
- checksums.yaml +4 -4
- data/lib/braintree/apple_pay_card.rb +4 -0
- data/lib/braintree/bin_data.rb +7 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +11 -5
- data/lib/braintree/credit_card_gateway.rb +1 -0
- data/lib/braintree/credit_card_verification_gateway.rb +1 -0
- data/lib/braintree/customer_session_gateway.rb +11 -10
- data/lib/braintree/error_codes.rb +5 -104
- data/lib/braintree/google_pay_card.rb +4 -0
- data/lib/braintree/graphql/enums/recommendations.rb +2 -0
- data/lib/braintree/graphql/enums/recommended_payment_option.rb +2 -0
- data/lib/braintree/graphql/inputs/create_customer_session_input.rb +10 -1
- data/lib/braintree/graphql/inputs/customer_recommendations_input.rb +7 -8
- data/lib/braintree/graphql/inputs/customer_session_input.rb +6 -0
- data/lib/braintree/graphql/inputs/monetary_amount_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_payee_input.rb +28 -0
- data/lib/braintree/graphql/inputs/paypal_purchase_unit_input.rb +31 -0
- data/lib/braintree/graphql/inputs/phone_input.rb +2 -0
- data/lib/braintree/graphql/inputs/update_customer_session_input.rb +5 -0
- data/lib/braintree/graphql/types/customer_recommendations_payload.rb +112 -18
- data/lib/braintree/graphql/types/payment_options.rb +2 -0
- data/lib/braintree/graphql/types/payment_recommendations.rb +35 -0
- data/lib/braintree/graphql/unions/customer_recommendations.rb +38 -25
- data/lib/braintree/merchant_account.rb +1 -25
- data/lib/braintree/merchant_account_gateway.rb +0 -81
- data/lib/braintree/meta_checkout_card.rb +8 -4
- data/lib/braintree/meta_checkout_token.rb +10 -6
- data/lib/braintree/payment_method_gateway.rb +3 -0
- data/lib/braintree/test/credit_card.rb +4 -0
- data/lib/braintree/transaction/apple_pay_details.rb +4 -0
- data/lib/braintree/transaction/credit_card_details.rb +8 -0
- data/lib/braintree/transaction/google_pay_details.rb +4 -0
- data/lib/braintree/transaction/meta_checkout_card_details.rb +9 -3
- data/lib/braintree/transaction/meta_checkout_token_details.rb +11 -5
- data/lib/braintree/transaction/visa_checkout_card_details.rb +8 -3
- data/lib/braintree/transaction.rb +0 -26
- data/lib/braintree/transaction_gateway.rb +9 -20
- data/lib/braintree/version.rb +1 -1
- data/lib/braintree/visa_checkout_card.rb +9 -4
- data/lib/braintree/webhook_notification.rb +0 -4
- data/lib/braintree/webhook_testing_gateway.rb +0 -33
- data/lib/braintree.rb +4 -3
- data/spec/integration/braintree/credit_card_spec.rb +101 -0
- data/spec/integration/braintree/credit_card_verification_spec.rb +118 -0
- data/spec/integration/braintree/customer_session_spec.rb +59 -49
- data/spec/integration/braintree/customer_spec.rb +71 -4
- data/spec/integration/braintree/disbursement_spec.rb +1 -1
- data/spec/integration/braintree/merchant_account_spec.rb +0 -342
- data/spec/integration/braintree/payment_method_nonce_spec.rb +44 -0
- data/spec/integration/braintree/payment_method_spec.rb +50 -3
- data/spec/integration/braintree/transaction_payment_facilitator_spec.rb +119 -0
- data/spec/integration/braintree/transaction_spec.rb +60 -328
- data/spec/spec_helper.rb +1 -1
- data/spec/unit/braintree/apple_pay_card_spec.rb +4 -0
- data/spec/unit/braintree/configuration_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_spec.rb +22 -2
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +1 -0
- data/spec/unit/braintree/customer_session_gateway_spec.rb +10 -9
- data/spec/unit/braintree/customer_spec.rb +2 -1
- data/spec/unit/braintree/google_pay_card_spec.rb +20 -0
- data/spec/unit/braintree/graphql/create_customer_session_input_spec.rb +25 -4
- data/spec/unit/braintree/graphql/customer_recommendations_input_spec.rb +21 -51
- data/spec/unit/braintree/graphql/customer_recommendations_spec.rb +40 -0
- data/spec/unit/braintree/graphql/update_customer_session_input_spec.rb +21 -7
- data/spec/unit/braintree/meta_checkout_card_spec.rb +8 -0
- data/spec/unit/braintree/meta_checkout_token_spec.rb +4 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +9 -2
- data/spec/unit/braintree/payment_method_spec.rb +12 -0
- data/spec/unit/braintree/transaction/apple_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +5 -1
- data/spec/unit/braintree/transaction/google_pay_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/meta_checkout_token_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction/visa_checkout_card_details_spec.rb +20 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +19 -0
- data/spec/unit/braintree/transaction_spec.rb +8 -0
- data/spec/unit/braintree/visa_checkout_card_spec.rb +20 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +0 -53
- data/spec/unit/credit_card_details_spec.rb +20 -0
- metadata +8 -7
- data/lib/braintree/merchant_account/business_details.rb +0 -17
- data/lib/braintree/merchant_account/funding_details.rb +0 -18
- data/lib/braintree/merchant_account/individual_details.rb +0 -20
- data/spec/unit/braintree/disbursement_spec.rb +0 -131
- data/spec/unit/braintree/merchant_account_spec.rb +0 -33
@@ -4,10 +4,13 @@ module Braintree
|
|
4
4
|
include BaseModule
|
5
5
|
|
6
6
|
attr_reader :bin
|
7
|
-
attr_reader :
|
7
|
+
attr_reader :business
|
8
8
|
attr_reader :card_type
|
9
9
|
attr_reader :cardholder_name
|
10
10
|
attr_reader :commercial
|
11
|
+
attr_reader :consumer
|
12
|
+
attr_reader :container_id
|
13
|
+
attr_reader :corporate
|
11
14
|
attr_reader :country_of_issuance
|
12
15
|
attr_reader :created_at
|
13
16
|
attr_reader :cryptogram
|
@@ -26,6 +29,7 @@ module Braintree
|
|
26
29
|
attr_reader :prepaid
|
27
30
|
attr_reader :prepaid_reloadable
|
28
31
|
attr_reader :product_id
|
32
|
+
attr_reader :purchase
|
29
33
|
attr_reader :token
|
30
34
|
attr_reader :unique_number_identifier
|
31
35
|
attr_reader :updated_at
|
@@ -40,10 +44,12 @@ module Braintree
|
|
40
44
|
|
41
45
|
def inspect
|
42
46
|
attr_order = [
|
43
|
-
:bin, :card_type, :cardholder_name, :commercial, :
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
+
:bin, :business, :card_type, :cardholder_name, :commercial, :consumer, :container_id,
|
48
|
+
:corporate, :country_of_issuance, :cryptogram, :customer_location, :debit,
|
49
|
+
:durbin_regulated, :ecommerce_indicator, :expiration_date, :healthcare, :image_url,
|
50
|
+
:is_network_tokenized, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
|
51
|
+
:product_id, :purchase, :token
|
52
|
+
]
|
47
53
|
formatted_attrs = attr_order.map do |attr|
|
48
54
|
"#{attr}: #{send(attr).inspect}"
|
49
55
|
end
|
@@ -4,10 +4,13 @@ module Braintree
|
|
4
4
|
include BaseModule
|
5
5
|
|
6
6
|
attr_reader :bin
|
7
|
+
attr_reader :business
|
7
8
|
attr_reader :call_id
|
8
9
|
attr_reader :card_type
|
9
10
|
attr_reader :cardholder_name
|
10
11
|
attr_reader :commercial
|
12
|
+
attr_reader :consumer
|
13
|
+
attr_reader :corporate
|
11
14
|
attr_reader :country_of_issuance
|
12
15
|
attr_reader :customer_location
|
13
16
|
attr_reader :debit
|
@@ -22,6 +25,7 @@ module Braintree
|
|
22
25
|
attr_reader :prepaid
|
23
26
|
attr_reader :prepaid_reloadable
|
24
27
|
attr_reader :product_id
|
28
|
+
attr_reader :purchase
|
25
29
|
attr_reader :token
|
26
30
|
|
27
31
|
def initialize(attributes)
|
@@ -34,9 +38,10 @@ module Braintree
|
|
34
38
|
|
35
39
|
def inspect
|
36
40
|
attr_order = [
|
37
|
-
:bin, :call_id, :card_type, :cardholder_name, :commercial, :
|
38
|
-
:
|
39
|
-
:
|
41
|
+
:bin, :business, :call_id, :card_type, :cardholder_name, :commercial, :consumer, :corporate,
|
42
|
+
:country_of_issuance, :customer_location, :debit, :durbin_regulated, :expiration_date,
|
43
|
+
:healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
|
44
|
+
:product_id, :purchase, :token]
|
40
45
|
formatted_attrs = attr_order.map do |attr|
|
41
46
|
"#{attr}: #{send(attr).inspect}"
|
42
47
|
end
|
@@ -9,15 +9,6 @@ module Braintree
|
|
9
9
|
Unrecognized = "unrecognized"
|
10
10
|
end
|
11
11
|
|
12
|
-
module EscrowStatus
|
13
|
-
HoldPending = "hold_pending"
|
14
|
-
Held = "held"
|
15
|
-
ReleasePending = "release_pending"
|
16
|
-
Released = "released"
|
17
|
-
Refunded = "refunded"
|
18
|
-
Unrecognized = "unrecognized"
|
19
|
-
end
|
20
|
-
|
21
12
|
module GatewayRejectionReason
|
22
13
|
ApplicationIncomplete = "application_incomplete"
|
23
14
|
AVS = "avs"
|
@@ -118,7 +109,6 @@ module Braintree
|
|
118
109
|
attr_reader :discount_amount
|
119
110
|
attr_reader :discounts
|
120
111
|
attr_reader :disputes
|
121
|
-
attr_reader :escrow_status
|
122
112
|
attr_reader :facilitated_details
|
123
113
|
attr_reader :facilitator_details
|
124
114
|
attr_reader :foreign_retailer
|
@@ -235,14 +225,6 @@ module Braintree
|
|
235
225
|
Configuration.gateway.transaction_line_item.find_all(*args)
|
236
226
|
end
|
237
227
|
|
238
|
-
def self.hold_in_escrow(*args)
|
239
|
-
Configuration.gateway.transaction.hold_in_escrow(*args)
|
240
|
-
end
|
241
|
-
|
242
|
-
def self.hold_in_escrow!(*args)
|
243
|
-
Configuration.gateway.transaction.hold_in_escrow!(*args)
|
244
|
-
end
|
245
|
-
|
246
228
|
def self.refund(*args)
|
247
229
|
Configuration.gateway.transaction.refund(*args)
|
248
230
|
end
|
@@ -263,14 +245,6 @@ module Braintree
|
|
263
245
|
Configuration.gateway.transaction.search(&block)
|
264
246
|
end
|
265
247
|
|
266
|
-
def self.release_from_escrow(*args)
|
267
|
-
Configuration.gateway.transaction.release_from_escrow(*args)
|
268
|
-
end
|
269
|
-
|
270
|
-
def self.release_from_escrow!(*args)
|
271
|
-
Configuration.gateway.transaction.release_from_escrow!(*args)
|
272
|
-
end
|
273
|
-
|
274
248
|
def self.submit_for_settlement(*args)
|
275
249
|
Configuration.gateway.transaction.submit_for_settlement(*args)
|
276
250
|
end
|
@@ -31,16 +31,6 @@ module Braintree
|
|
31
31
|
return_object_or_raise(:transaction) { cancel_release(*args) }
|
32
32
|
end
|
33
33
|
|
34
|
-
def hold_in_escrow(transaction_id)
|
35
|
-
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
36
|
-
response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/hold_in_escrow")
|
37
|
-
_handle_transaction_response(response)
|
38
|
-
end
|
39
|
-
|
40
|
-
def hold_in_escrow!(*args)
|
41
|
-
return_object_or_raise(:transaction) { hold_in_escrow(*args) }
|
42
|
-
end
|
43
|
-
|
44
34
|
def _handle_transaction_response(response)
|
45
35
|
if response[:transaction]
|
46
36
|
SuccessfulResult.new(:transaction => Transaction._new(@gateway, response[:transaction]))
|
@@ -135,16 +125,6 @@ module Braintree
|
|
135
125
|
end
|
136
126
|
end
|
137
127
|
|
138
|
-
def release_from_escrow(transaction_id)
|
139
|
-
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
140
|
-
response = @config.http.put("#{@config.base_merchant_path}/transactions/#{transaction_id}/release_from_escrow")
|
141
|
-
_handle_transaction_response(response)
|
142
|
-
end
|
143
|
-
|
144
|
-
def release_from_escrow!(*args)
|
145
|
-
return_object_or_raise(:transaction) { release_from_escrow(*args) }
|
146
|
-
end
|
147
|
-
|
148
128
|
def submit_for_settlement(transaction_id, amount = nil, options = {})
|
149
129
|
raise ArgumentError, "transaction_id is invalid" unless transaction_id =~ /\A[0-9a-z]+\z/
|
150
130
|
Util.verify_keys(TransactionGateway._submit_for_settlement_signature, options)
|
@@ -275,6 +255,15 @@ module Braintree
|
|
275
255
|
]
|
276
256
|
},
|
277
257
|
{:paypal_account => [:email, :token, :paypal_data, :payee_id, :payee_email, :payer_id, :payment_id]},
|
258
|
+
{:payment_facilitator => [
|
259
|
+
:payment_facilitator_id,
|
260
|
+
{:sub_merchant => [:reference_number, :tax_id, :legal_name,
|
261
|
+
{:address => [ :street_address, :locality, :region, :country_code_alpha2, :postal_code,
|
262
|
+
{:international_phone => [:country_code, :national_number
|
263
|
+
]}
|
264
|
+
]}
|
265
|
+
]}
|
266
|
+
]},
|
278
267
|
{:risk_data => [:customer_browser, :customer_device_id, :customer_ip, :customer_location_zip, :customer_tenure]},
|
279
268
|
{
|
280
269
|
:shipping => AddressGateway._shared_signature + [:shipping_method],
|
data/lib/braintree/version.rb
CHANGED
@@ -5,10 +5,13 @@ module Braintree
|
|
5
5
|
|
6
6
|
attr_reader :billing_address
|
7
7
|
attr_reader :bin
|
8
|
+
attr_reader :business
|
8
9
|
attr_reader :call_id
|
9
10
|
attr_reader :card_type
|
10
11
|
attr_reader :cardholder_name
|
11
12
|
attr_reader :commercial
|
13
|
+
attr_reader :consumer
|
14
|
+
attr_reader :corporate
|
12
15
|
attr_reader :country_of_issuance
|
13
16
|
attr_reader :created_at
|
14
17
|
attr_reader :customer_id
|
@@ -25,6 +28,7 @@ module Braintree
|
|
25
28
|
attr_reader :prepaid
|
26
29
|
attr_reader :prepaid_reloadable
|
27
30
|
attr_reader :product_id
|
31
|
+
attr_reader :purchase
|
28
32
|
attr_reader :subscriptions
|
29
33
|
attr_reader :token
|
30
34
|
attr_reader :unique_number_identifier
|
@@ -76,10 +80,11 @@ module Braintree
|
|
76
80
|
|
77
81
|
def self._attributes
|
78
82
|
[
|
79
|
-
:bin, :billing_address, :card_type, :cardholder_name, :commercial,
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
+
:bin, :billing_address, :business, :card_type, :cardholder_name, :commercial,
|
84
|
+
:consumer, :container_id, :corporate, :country_of_issuance, :created_at, :customer_id,
|
85
|
+
:customer_location, :debit, :durbin_regulated, :expiration_month, :expiration_year,
|
86
|
+
:healthcare, :image_url, :issuing_bank, :last_4, :payroll, :prepaid, :prepaid_reloadable,
|
87
|
+
:product_id, :purchase, :token, :updated_at
|
83
88
|
]
|
84
89
|
end
|
85
90
|
|
@@ -13,7 +13,6 @@ module Braintree
|
|
13
13
|
ConnectedMerchantPayPalStatusChanged = "connected_merchant_paypal_status_changed"
|
14
14
|
ConnectedMerchantStatusTransitioned = "connected_merchant_status_transitioned"
|
15
15
|
Disbursement = "disbursement"
|
16
|
-
DisbursementException = "disbursement_exception"
|
17
16
|
|
18
17
|
DisputeAccepted = "dispute_accepted"
|
19
18
|
DisputeAutoAccepted = "dispute_auto_accepted"
|
@@ -57,9 +56,6 @@ module Braintree
|
|
57
56
|
SubscriptionWentActive = "subscription_went_active"
|
58
57
|
SubscriptionWentPastDue = "subscription_went_past_due"
|
59
58
|
|
60
|
-
SubMerchantAccountApproved = "sub_merchant_account_approved"
|
61
|
-
SubMerchantAccountDeclined = "sub_merchant_account_declined"
|
62
|
-
|
63
59
|
TransactionDisbursed = "transaction_disbursed"
|
64
60
|
TransactionReviewed = "transaction_reviewed"
|
65
61
|
TransactionSettlementDeclined = "transaction_settlement_declined"
|
@@ -58,10 +58,6 @@ module Braintree
|
|
58
58
|
_partner_merchant_declined_sample_xml(id)
|
59
59
|
when Braintree::WebhookNotification::Kind::OAuthAccessRevoked
|
60
60
|
_oauth_access_revoked_sample_xml(id)
|
61
|
-
when Braintree::WebhookNotification::Kind::SubMerchantAccountApproved
|
62
|
-
_merchant_account_approved_sample_xml(id)
|
63
|
-
when Braintree::WebhookNotification::Kind::SubMerchantAccountDeclined
|
64
|
-
_merchant_account_declined_sample_xml(id)
|
65
61
|
when Braintree::WebhookNotification::Kind::TransactionDisbursed
|
66
62
|
_transaction_disbursed_sample_xml(id)
|
67
63
|
when Braintree::WebhookNotification::Kind::TransactionReviewed
|
@@ -70,8 +66,6 @@ module Braintree
|
|
70
66
|
_transaction_settled_sample_xml(id)
|
71
67
|
when Braintree::WebhookNotification::Kind::TransactionSettlementDeclined
|
72
68
|
_transaction_settlement_declined_sample_xml(id)
|
73
|
-
when Braintree::WebhookNotification::Kind::DisbursementException
|
74
|
-
_disbursement_exception_sample_xml(id)
|
75
69
|
when Braintree::WebhookNotification::Kind::Disbursement
|
76
70
|
_disbursement_sample_xml(id)
|
77
71
|
when Braintree::WebhookNotification::Kind::SubscriptionBillingSkipped
|
@@ -959,33 +953,7 @@ module Braintree
|
|
959
953
|
XML
|
960
954
|
end
|
961
955
|
|
962
|
-
def _disbursement_exception_sample_xml(id)
|
963
|
-
|
964
|
-
<<-XML
|
965
|
-
<disbursement>
|
966
|
-
<id>#{id}</id>
|
967
|
-
<transaction-ids type="array">
|
968
|
-
<item>afv56j</item>
|
969
|
-
<item>kj8hjk</item>
|
970
|
-
</transaction-ids>
|
971
|
-
<success type="boolean">false</success>
|
972
|
-
<retry type="boolean">false</retry>
|
973
|
-
<merchant-account>
|
974
|
-
<id>merchant_account_token</id>
|
975
|
-
<currency-iso-code>USD</currency-iso-code>
|
976
|
-
<sub-merchant-account type="boolean">false</sub-merchant-account>
|
977
|
-
<status>active</status>
|
978
|
-
</merchant-account>
|
979
|
-
<amount>100.00</amount>
|
980
|
-
<disbursement-date type="date">2014-02-10</disbursement-date>
|
981
|
-
<exception-message>bank_rejected</exception-message>
|
982
|
-
<follow-up-action>update_funding_information</follow-up-action>
|
983
|
-
</disbursement>
|
984
|
-
XML
|
985
|
-
end
|
986
|
-
|
987
956
|
def _disbursement_sample_xml(id)
|
988
|
-
|
989
957
|
<<-XML
|
990
958
|
<disbursement>
|
991
959
|
<id>#{id}</id>
|
@@ -1010,7 +978,6 @@ module Braintree
|
|
1010
978
|
end
|
1011
979
|
|
1012
980
|
def _account_updater_daily_report_sample_xml(id)
|
1013
|
-
|
1014
981
|
<<-XML
|
1015
982
|
<account-updater-daily-report>
|
1016
983
|
<report-date type="date">2016-01-14</report-date>
|
data/lib/braintree.rb
CHANGED
@@ -83,8 +83,12 @@ require "braintree/graphql/inputs/customer_recommendations_input"
|
|
83
83
|
require "braintree/graphql/inputs/customer_session_input"
|
84
84
|
require "braintree/graphql/inputs/phone_input"
|
85
85
|
require "braintree/graphql/inputs/update_customer_session_input"
|
86
|
+
require "braintree/graphql/inputs/paypal_purchase_unit_input"
|
87
|
+
require "braintree/graphql/inputs/paypal_payee_input"
|
88
|
+
require "braintree/graphql/inputs/monetary_amount_input"
|
86
89
|
require "braintree/graphql/types/customer_recommendations_payload"
|
87
90
|
require "braintree/graphql/types/payment_options"
|
91
|
+
require "braintree/graphql/types/payment_recommendations"
|
88
92
|
require "braintree/graphql/unions/customer_recommendations"
|
89
93
|
require "braintree/graphql_client"
|
90
94
|
require "braintree/google_pay_card"
|
@@ -98,9 +102,6 @@ require "braintree/merchant"
|
|
98
102
|
require "braintree/merchant_gateway"
|
99
103
|
require "braintree/merchant_account"
|
100
104
|
require "braintree/merchant_account_gateway"
|
101
|
-
require "braintree/merchant_account/individual_details"
|
102
|
-
require "braintree/merchant_account/business_details"
|
103
|
-
require "braintree/merchant_account/funding_details"
|
104
105
|
require "braintree/merchant_account/address_details"
|
105
106
|
require "braintree/meta_checkout_card"
|
106
107
|
require "braintree/meta_checkout_token"
|
@@ -461,6 +461,54 @@ describe Braintree::CreditCard do
|
|
461
461
|
expect(credit_card.prepaid_reloadable).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
462
462
|
end
|
463
463
|
|
464
|
+
it "sets the business field if the card is business" do
|
465
|
+
customer = Braintree::Customer.create!
|
466
|
+
result = Braintree::CreditCard.create(
|
467
|
+
:customer_id => customer.id,
|
468
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
469
|
+
:expiration_date => "05/2014",
|
470
|
+
:options => {:verify_card => true},
|
471
|
+
)
|
472
|
+
credit_card = result.credit_card
|
473
|
+
expect(credit_card.business).to eq(Braintree::CreditCard::Business::Yes)
|
474
|
+
end
|
475
|
+
|
476
|
+
it "sets the consumer field if the card is consumer" do
|
477
|
+
customer = Braintree::Customer.create!
|
478
|
+
result = Braintree::CreditCard.create(
|
479
|
+
:customer_id => customer.id,
|
480
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
481
|
+
:expiration_date => "05/2014",
|
482
|
+
:options => {:verify_card => true},
|
483
|
+
)
|
484
|
+
credit_card = result.credit_card
|
485
|
+
expect(credit_card.consumer).to eq(Braintree::CreditCard::Consumer::Yes)
|
486
|
+
end
|
487
|
+
|
488
|
+
it "sets the corporate field if the card is corporate" do
|
489
|
+
customer = Braintree::Customer.create!
|
490
|
+
result = Braintree::CreditCard.create(
|
491
|
+
:customer_id => customer.id,
|
492
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
493
|
+
:expiration_date => "05/2014",
|
494
|
+
:options => {:verify_card => true},
|
495
|
+
)
|
496
|
+
credit_card = result.credit_card
|
497
|
+
expect(credit_card.corporate).to eq(Braintree::CreditCard::Corporate::Yes)
|
498
|
+
end
|
499
|
+
|
500
|
+
it "sets the purchase field if the card is purchase" do
|
501
|
+
customer = Braintree::Customer.create!
|
502
|
+
result = Braintree::CreditCard.create(
|
503
|
+
:customer_id => customer.id,
|
504
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
505
|
+
:expiration_date => "05/2014",
|
506
|
+
:options => {:verify_card => true},
|
507
|
+
)
|
508
|
+
credit_card = result.credit_card
|
509
|
+
expect(credit_card.purchase).to eq(Braintree::CreditCard::Purchase::Yes)
|
510
|
+
end
|
511
|
+
|
464
512
|
it "sets the healthcare field if the card is healthcare" do
|
465
513
|
customer = Braintree::Customer.create!
|
466
514
|
result = Braintree::CreditCard.create(
|
@@ -1450,4 +1498,57 @@ describe Braintree::CreditCard do
|
|
1450
1498
|
expect(credit_card_vaulted.is_network_tokenized?).to eq(false)
|
1451
1499
|
end
|
1452
1500
|
end
|
1501
|
+
|
1502
|
+
describe "account information inquiry" do
|
1503
|
+
it "includes ani response when account information inquiry is sent in options" do
|
1504
|
+
customer = Braintree::Customer.create!
|
1505
|
+
result = Braintree::CreditCard.create(
|
1506
|
+
:cardholder_name => "John Doe",
|
1507
|
+
:customer_id => customer.id,
|
1508
|
+
:cvv => "123",
|
1509
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1510
|
+
:expiration_date => "05/2027",
|
1511
|
+
:billing_address => {
|
1512
|
+
:first_name => "John",
|
1513
|
+
:last_name => "Doe",
|
1514
|
+
},
|
1515
|
+
:options => {
|
1516
|
+
:account_information_inquiry => "send_data",
|
1517
|
+
:verify_card => true,
|
1518
|
+
},
|
1519
|
+
)
|
1520
|
+
|
1521
|
+
expect(result).to be_success
|
1522
|
+
verification = result.credit_card.verification
|
1523
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
1524
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
1525
|
+
end
|
1526
|
+
|
1527
|
+
it "includes ani response after updating the options with account information inquiry" do
|
1528
|
+
customer = Braintree::Customer.create!
|
1529
|
+
credit_card = Braintree::CreditCard.create!(
|
1530
|
+
:cardholder_name => "Original Holder",
|
1531
|
+
:customer_id => customer.id,
|
1532
|
+
:cvv => "123",
|
1533
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
1534
|
+
:expiration_date => "05/2027",
|
1535
|
+
)
|
1536
|
+
updated_result = Braintree::CreditCard.update(credit_card.token,
|
1537
|
+
:options => {
|
1538
|
+
:verify_card => true,
|
1539
|
+
:account_information_inquiry => "send_data",
|
1540
|
+
},
|
1541
|
+
)
|
1542
|
+
|
1543
|
+
expect(updated_result).to be_success
|
1544
|
+
verification = updated_result.credit_card.verification
|
1545
|
+
expect(verification.ani_first_name_response_code).not_to be_nil
|
1546
|
+
expect(verification.ani_last_name_response_code).not_to be_nil
|
1547
|
+
end
|
1548
|
+
end
|
1453
1549
|
end
|
1550
|
+
|
1551
|
+
|
1552
|
+
|
1553
|
+
|
1554
|
+
|
@@ -67,6 +67,28 @@ describe Braintree::CreditCardVerification, "search" do
|
|
67
67
|
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
68
68
|
end
|
69
69
|
|
70
|
+
it "creates a new verification for Visa ANI when account information inquiry is passed" do
|
71
|
+
verification_params = {
|
72
|
+
:credit_card => {
|
73
|
+
:expiration_date => "05/2032",
|
74
|
+
:number => Braintree::Test::CreditCardNumbers::Visa,
|
75
|
+
},
|
76
|
+
:options => {
|
77
|
+
:account_information_inquiry => "send_data",
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
result = Braintree::CreditCardVerification.create(verification_params)
|
82
|
+
|
83
|
+
expect(result).to be_success
|
84
|
+
expect(result.credit_card_verification.status).to eq(Braintree::CreditCardVerification::Status::Verified)
|
85
|
+
expect(result.credit_card_verification.processor_response_code).to eq("1000")
|
86
|
+
expect(result.credit_card_verification.processor_response_text).to eq("Approved")
|
87
|
+
expect(result.credit_card_verification.ani_first_name_response_code).to eq("I")
|
88
|
+
expect(result.credit_card_verification.ani_last_name_response_code).to eq("I")
|
89
|
+
expect(result.credit_card_verification.processor_response_type).to eq(Braintree::ProcessorResponseTypes::Approved)
|
90
|
+
end
|
91
|
+
|
70
92
|
it "creates a new verification from external vault param" do
|
71
93
|
verification_params = {
|
72
94
|
:credit_card => {
|
@@ -346,6 +368,102 @@ describe Braintree::CreditCardVerification, "search" do
|
|
346
368
|
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
347
369
|
expect(found_verification.credit_card[:prepaid_reloadable]).to eq(Braintree::CreditCard::PrepaidReloadable::Yes)
|
348
370
|
end
|
371
|
+
|
372
|
+
it "returns business on a business card" do
|
373
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
374
|
+
|
375
|
+
Braintree::Customer.create(
|
376
|
+
:credit_card => {
|
377
|
+
:cardholder_name => cardholder_name,
|
378
|
+
:expiration_date => "05/2012",
|
379
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Business,
|
380
|
+
:cvv => "200",
|
381
|
+
:options => {
|
382
|
+
:verify_card => true
|
383
|
+
}
|
384
|
+
})
|
385
|
+
|
386
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
387
|
+
search.credit_card_cardholder_name.is cardholder_name
|
388
|
+
end
|
389
|
+
|
390
|
+
verification_id = search_results.first.id
|
391
|
+
|
392
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
393
|
+
expect(found_verification.credit_card[:business]).to eq(Braintree::CreditCard::Business::Yes)
|
394
|
+
end
|
395
|
+
|
396
|
+
it "returns consumer on a consumer card" do
|
397
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
398
|
+
|
399
|
+
Braintree::Customer.create(
|
400
|
+
:credit_card => {
|
401
|
+
:cardholder_name => cardholder_name,
|
402
|
+
:expiration_date => "05/2012",
|
403
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Consumer,
|
404
|
+
:cvv => "200",
|
405
|
+
:options => {
|
406
|
+
:verify_card => true
|
407
|
+
}
|
408
|
+
})
|
409
|
+
|
410
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
411
|
+
search.credit_card_cardholder_name.is cardholder_name
|
412
|
+
end
|
413
|
+
|
414
|
+
verification_id = search_results.first.id
|
415
|
+
|
416
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
417
|
+
expect(found_verification.credit_card[:consumer]).to eq(Braintree::CreditCard::Consumer::Yes)
|
418
|
+
end
|
419
|
+
|
420
|
+
it "returns corporate on a corporate card" do
|
421
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
422
|
+
|
423
|
+
Braintree::Customer.create(
|
424
|
+
:credit_card => {
|
425
|
+
:cardholder_name => cardholder_name,
|
426
|
+
:expiration_date => "05/2012",
|
427
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Corporate,
|
428
|
+
:cvv => "200",
|
429
|
+
:options => {
|
430
|
+
:verify_card => true
|
431
|
+
}
|
432
|
+
})
|
433
|
+
|
434
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
435
|
+
search.credit_card_cardholder_name.is cardholder_name
|
436
|
+
end
|
437
|
+
|
438
|
+
verification_id = search_results.first.id
|
439
|
+
|
440
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
441
|
+
expect(found_verification.credit_card[:corporate]).to eq(Braintree::CreditCard::Corporate::Yes)
|
442
|
+
end
|
443
|
+
|
444
|
+
it "returns purchase on a purchase card" do
|
445
|
+
cardholder_name = "Tom #{rand(1_000_000)} Smith"
|
446
|
+
|
447
|
+
Braintree::Customer.create(
|
448
|
+
:credit_card => {
|
449
|
+
:cardholder_name => cardholder_name,
|
450
|
+
:expiration_date => "05/2012",
|
451
|
+
:number => Braintree::Test::CreditCardNumbers::CardTypeIndicators::Purchase,
|
452
|
+
:cvv => "200",
|
453
|
+
:options => {
|
454
|
+
:verify_card => true
|
455
|
+
}
|
456
|
+
})
|
457
|
+
|
458
|
+
search_results = Braintree::CreditCardVerification.search do |search|
|
459
|
+
search.credit_card_cardholder_name.is cardholder_name
|
460
|
+
end
|
461
|
+
|
462
|
+
verification_id = search_results.first.id
|
463
|
+
|
464
|
+
found_verification = Braintree::CreditCardVerification.find(verification_id)
|
465
|
+
expect(found_verification.credit_card[:purchase]).to eq(Braintree::CreditCard::Purchase::Yes)
|
466
|
+
end
|
349
467
|
end
|
350
468
|
end
|
351
469
|
|