braintree 2.74.0 → 4.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/braintree.gemspec +13 -7
- data/lib/braintree/account_updater_daily_report.rb +2 -2
- data/lib/braintree/ach_mandate.rb +2 -1
- data/lib/braintree/address/country_names.rb +4 -1
- data/lib/braintree/address.rb +30 -38
- data/lib/braintree/address_gateway.rb +12 -2
- data/lib/braintree/advanced_search.rb +8 -0
- data/lib/braintree/apple_pay.rb +29 -0
- data/lib/braintree/apple_pay_card.rb +28 -4
- data/lib/braintree/apple_pay_gateway.rb +37 -0
- data/lib/braintree/apple_pay_options.rb +19 -0
- data/lib/braintree/authorization_adjustment.rb +23 -0
- data/lib/braintree/base_module.rb +10 -0
- data/lib/braintree/bin_data.rb +33 -0
- data/lib/braintree/client_token.rb +3 -3
- data/lib/braintree/client_token_gateway.rb +3 -1
- data/lib/braintree/configuration.rb +57 -10
- data/lib/braintree/connected_merchant_paypal_status_changed.rb +6 -2
- data/lib/braintree/connected_merchant_status_transitioned.rb +6 -2
- data/lib/braintree/credentials_parser.rb +5 -1
- data/lib/braintree/credit_card.rb +53 -107
- data/lib/braintree/credit_card_gateway.rb +43 -30
- data/lib/braintree/credit_card_verification.rb +61 -21
- data/lib/braintree/credit_card_verification_gateway.rb +19 -6
- data/lib/braintree/credit_card_verification_search.rb +1 -1
- data/lib/braintree/customer.rb +51 -98
- data/lib/braintree/customer_gateway.rb +30 -23
- data/lib/braintree/customer_search.rb +1 -1
- data/lib/braintree/descriptor.rb +3 -1
- data/lib/braintree/disbursement.rb +24 -2
- data/lib/braintree/dispute/evidence.rb +24 -0
- data/lib/braintree/{transaction/coinbase_details.rb → dispute/paypal_message.rb} +5 -3
- data/lib/braintree/dispute/status_history.rb +18 -0
- data/lib/braintree/dispute/transaction.rb +20 -0
- data/lib/braintree/dispute/transaction_details.rb +2 -1
- data/lib/braintree/dispute.rb +114 -10
- data/lib/braintree/dispute_gateway.rb +142 -0
- data/lib/braintree/dispute_search.rb +31 -0
- data/lib/braintree/document_upload.rb +37 -0
- data/lib/braintree/document_upload_gateway.rb +38 -0
- data/lib/braintree/enriched_customer_data.rb +21 -0
- data/lib/braintree/error_codes.rb +328 -109
- data/lib/braintree/error_result.rb +8 -1
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/exchange_rate.rb +13 -0
- data/lib/braintree/exchange_rate_quote.rb +24 -0
- data/lib/braintree/exchange_rate_quote_gateway.rb +35 -0
- data/lib/braintree/exchange_rate_quote_input.rb +21 -0
- data/lib/braintree/exchange_rate_quote_request.rb +18 -0
- data/lib/braintree/exchange_rate_quote_response.rb +18 -0
- data/lib/braintree/facilitated_details.rb +21 -0
- data/lib/braintree/facilitator_details.rb +2 -1
- data/lib/braintree/gateway.rb +29 -11
- data/lib/braintree/google_pay_card.rb +61 -0
- data/lib/braintree/granted_payment_instrument_update.rb +23 -0
- data/lib/braintree/graphql_client.rb +34 -0
- data/lib/braintree/http.rb +81 -20
- data/lib/braintree/local_payment_completed.rb +23 -0
- data/lib/braintree/local_payment_expired.rb +21 -0
- data/lib/braintree/local_payment_funded.rb +22 -0
- data/lib/braintree/local_payment_reversed.rb +19 -0
- data/lib/braintree/merchant.rb +11 -4
- data/lib/braintree/merchant_account/address_details.rb +4 -1
- data/lib/braintree/merchant_account/business_details.rb +4 -1
- data/lib/braintree/merchant_account/funding_details.rb +6 -1
- data/lib/braintree/merchant_account/individual_details.rb +7 -2
- data/lib/braintree/merchant_account.rb +23 -10
- data/lib/braintree/merchant_account_gateway.rb +13 -1
- data/lib/braintree/merchant_gateway.rb +2 -2
- data/lib/braintree/modification.rb +1 -1
- data/lib/braintree/oauth_credentials.rb +5 -2
- data/lib/braintree/oauth_gateway.rb +8 -14
- data/lib/braintree/paginated_result.rb +3 -1
- data/lib/braintree/payment_instrument_type.rb +11 -11
- data/lib/braintree/payment_method.rb +20 -12
- data/lib/braintree/payment_method_customer_data_updated_metadata.rb +24 -0
- data/lib/braintree/payment_method_gateway.rb +82 -54
- data/lib/braintree/payment_method_nonce.rb +22 -8
- data/lib/braintree/payment_method_nonce_details.rb +40 -0
- data/lib/braintree/payment_method_nonce_details_payer_info.rb +32 -0
- data/lib/braintree/payment_method_nonce_gateway.rb +19 -2
- data/lib/braintree/payment_method_parser.rb +28 -0
- data/lib/braintree/paypal_account.rb +10 -1
- data/lib/braintree/plan.rb +25 -5
- data/lib/braintree/plan_gateway.rb +100 -0
- data/lib/braintree/processor_response_types.rb +7 -0
- data/lib/braintree/resource_collection.rb +8 -3
- data/lib/braintree/revoked_payment_method_metadata.rb +22 -0
- data/lib/braintree/risk_data/liability_shift.rb +22 -0
- data/lib/braintree/risk_data.rb +12 -2
- data/lib/braintree/samsung_pay_card.rb +83 -0
- data/lib/braintree/sepa_direct_debit_account.rb +60 -0
- data/lib/braintree/sepa_direct_debit_account_gateway.rb +25 -0
- data/lib/braintree/sepa_direct_debit_account_nonce_details.rb +28 -0
- data/lib/braintree/settlement_batch_summary.rb +2 -1
- data/lib/braintree/settlement_batch_summary_gateway.rb +2 -0
- data/lib/braintree/subscription/status_details.rb +8 -1
- data/lib/braintree/subscription.rb +56 -41
- data/lib/braintree/subscription_gateway.rb +25 -2
- data/lib/braintree/successful_result.rb +23 -1
- data/lib/braintree/test/authentication_id.rb +21 -0
- data/lib/braintree/test/credit_card.rb +13 -0
- data/lib/braintree/test/nonce.rb +28 -20
- data/lib/braintree/test/transaction_amounts.rb +1 -0
- data/lib/braintree/three_d_secure_info.rb +34 -2
- data/lib/braintree/transaction/address_details.rb +24 -4
- data/lib/braintree/transaction/apple_pay_details.rb +20 -2
- data/lib/braintree/transaction/credit_card_details.rb +45 -6
- data/lib/braintree/transaction/customer_details.rb +8 -1
- data/lib/braintree/transaction/disbursement_details.rb +6 -1
- data/lib/braintree/transaction/google_pay_details.rb +41 -0
- data/lib/braintree/transaction/installment/adjustment.rb +33 -0
- data/lib/braintree/transaction/installment.rb +28 -0
- data/lib/braintree/transaction/local_payment_details.rb +24 -0
- data/lib/braintree/transaction/paypal_details.rb +26 -4
- data/lib/braintree/transaction/paypal_here_details.rb +23 -0
- data/lib/braintree/transaction/{masterpass_card_details.rb → samsung_pay_card_details.rb} +21 -6
- data/lib/braintree/transaction/sepa_direct_debit_account_details.rb +27 -0
- data/lib/braintree/transaction/status_details.rb +5 -1
- data/lib/braintree/transaction/subscription_details.rb +4 -1
- data/lib/braintree/transaction/us_bank_account_details.rb +8 -1
- data/lib/braintree/transaction/venmo_account_details.rb +5 -1
- data/lib/braintree/transaction/visa_checkout_card_details.rb +19 -4
- data/lib/braintree/transaction.rb +201 -188
- data/lib/braintree/transaction_gateway.rb +124 -30
- data/lib/braintree/transaction_line_item.rb +40 -0
- data/lib/braintree/transaction_line_item_gateway.rb +19 -0
- data/lib/braintree/transaction_review.rb +18 -0
- data/lib/braintree/transaction_search.rb +6 -3
- data/lib/braintree/unknown_payment_method.rb +3 -2
- data/lib/braintree/us_bank_account.rb +24 -8
- data/lib/braintree/us_bank_account_gateway.rb +0 -1
- data/lib/braintree/us_bank_account_verification.rb +81 -0
- data/lib/braintree/us_bank_account_verification_gateway.rb +51 -0
- data/lib/braintree/us_bank_account_verification_search.rb +19 -0
- data/lib/braintree/util.rb +79 -9
- data/lib/braintree/validation_error.rb +13 -3
- data/lib/braintree/validation_error_collection.rb +2 -1
- data/lib/braintree/venmo_account.rb +11 -4
- data/lib/braintree/venmo_profile_data.rb +23 -0
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/visa_checkout_card.rb +29 -13
- data/lib/braintree/webhook_notification.rb +66 -26
- data/lib/braintree/webhook_notification_gateway.rb +5 -3
- data/lib/braintree/webhook_testing.rb +2 -2
- data/lib/braintree/webhook_testing_gateway.rb +721 -55
- data/lib/braintree/xml/generator.rb +6 -4
- data/lib/braintree/xml/parser.rb +22 -35
- data/lib/braintree/xml/rexml.rb +4 -5
- data/lib/braintree.rb +60 -22
- data/lib/ssl/api_braintreegateway_com.ca.crt +50 -0
- data/spec/fixtures/files/bt_logo.png +0 -0
- data/spec/fixtures/files/gif_extension_bt_logo.gif +0 -0
- data/spec/fixtures/files/malformed_pdf.pdf +1 -0
- data/spec/fixtures/files/too_long.pdf +0 -0
- data/spec/integration/braintree/add_on_spec.rb +3 -3
- data/spec/integration/braintree/address_spec.rb +30 -113
- data/spec/integration/braintree/advanced_search_spec.rb +45 -45
- data/spec/integration/braintree/apple_pay_spec.rb +63 -0
- data/spec/integration/braintree/braintree_gateway_spec.rb +72 -0
- data/spec/integration/braintree/client_api/client_token_spec.rb +14 -32
- data/spec/integration/braintree/client_api/spec_helper.rb +104 -65
- data/spec/integration/braintree/credit_card_spec.rb +460 -615
- data/spec/integration/braintree/credit_card_verification_search_spec.rb +2 -2
- data/spec/integration/braintree/credit_card_verification_spec.rb +222 -6
- data/spec/integration/braintree/customer_search_spec.rb +8 -8
- data/spec/integration/braintree/customer_spec.rb +810 -498
- data/spec/integration/braintree/discount_spec.rb +1 -1
- data/spec/integration/braintree/dispute_search_spec.rb +167 -0
- data/spec/integration/braintree/dispute_spec.rb +333 -0
- data/spec/integration/braintree/document_upload_spec.rb +87 -0
- data/spec/integration/braintree/error_codes_spec.rb +1 -1
- data/spec/integration/braintree/exchange_rate_quote_spec.rb +97 -0
- data/spec/integration/braintree/graphql_client_spec.rb +72 -0
- data/spec/integration/braintree/http_spec.rb +12 -4
- data/spec/integration/braintree/merchant_account_spec.rb +74 -26
- data/spec/integration/braintree/merchant_spec.rb +39 -13
- data/spec/integration/braintree/oauth_spec.rb +18 -25
- data/spec/integration/braintree/payment_method_nonce_spec.rb +239 -5
- data/spec/integration/braintree/payment_method_spec.rb +882 -300
- data/spec/integration/braintree/payment_method_us_bank_account_spec.rb +416 -0
- data/spec/integration/braintree/paypal_account_spec.rb +32 -31
- data/spec/integration/braintree/plan_spec.rb +82 -0
- data/spec/integration/braintree/samsung_pay_card_spec.rb +144 -0
- data/spec/integration/braintree/sepa_direct_debit_account_spec.rb +196 -0
- data/spec/integration/braintree/settlement_batch_summary_spec.rb +8 -8
- data/spec/integration/braintree/subscription_spec.rb +274 -180
- data/spec/integration/braintree/test/transaction_amounts_spec.rb +2 -2
- data/spec/integration/braintree/test_transaction_spec.rb +18 -18
- data/spec/integration/braintree/transaction_line_item_spec.rb +38 -0
- data/spec/integration/braintree/transaction_search_spec.rb +280 -152
- data/spec/integration/braintree/transaction_spec.rb +3709 -1175
- data/spec/integration/braintree/transaction_us_bank_account_spec.rb +438 -0
- data/spec/integration/braintree/us_bank_account_spec.rb +38 -17
- data/spec/integration/braintree/us_bank_account_verification_search_spec.rb +178 -0
- data/spec/integration/braintree/us_bank_account_verification_spec.rb +240 -0
- data/spec/integration/braintree/visa_checkout_card_spec.rb +5 -5
- data/spec/integration/spec_helper.rb +27 -6
- data/spec/oauth_test_helper.rb +1 -1
- data/spec/script/httpsd.rb +6 -6
- data/spec/spec_helper.rb +26 -23
- data/spec/unit/braintree/address_spec.rb +1 -9
- data/spec/unit/braintree/apple_pay_card_spec.rb +104 -4
- data/spec/unit/braintree/client_token_spec.rb +2 -2
- data/spec/unit/braintree/configuration_spec.rb +108 -33
- data/spec/unit/braintree/credit_card_spec.rb +62 -33
- data/spec/unit/braintree/credit_card_verification_gateway_spec.rb +51 -0
- data/spec/unit/braintree/credit_card_verification_search_spec.rb +1 -1
- data/spec/unit/braintree/credit_card_verification_spec.rb +39 -6
- data/spec/unit/braintree/customer_spec.rb +107 -27
- data/spec/unit/braintree/disbursement_spec.rb +59 -7
- data/spec/unit/braintree/dispute_search_spec.rb +66 -0
- data/spec/unit/braintree/dispute_spec.rb +472 -8
- data/spec/unit/braintree/document_upload_spec.rb +35 -0
- data/spec/unit/braintree/enriched_customer_data_spec.rb +32 -0
- data/spec/unit/braintree/error_result_spec.rb +5 -5
- data/spec/unit/braintree/errors_spec.rb +8 -8
- data/spec/unit/braintree/exchange_rate_quote_input_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_quote_request_spec.rb +82 -0
- data/spec/unit/braintree/exchange_rate_quote_response_spec.rb +52 -0
- data/spec/unit/braintree/exchange_rate_quote_spec.rb +42 -0
- data/spec/unit/braintree/exchange_rate_spec.rb +23 -0
- data/spec/unit/braintree/http_spec.rb +93 -5
- data/spec/unit/braintree/local_payment_completed_spec.rb +50 -0
- data/spec/unit/braintree/local_payment_expired_spec.rb +24 -0
- data/spec/unit/braintree/local_payment_funded_spec.rb +34 -0
- data/spec/unit/braintree/merchant_account_spec.rb +1 -1
- data/spec/unit/braintree/modification_spec.rb +1 -1
- data/spec/unit/braintree/payment_method_customer_data_updated_metadata_spec.rb +45 -0
- data/spec/unit/braintree/payment_method_nonce_details_payer_info_spec.rb +31 -0
- data/spec/unit/braintree/payment_method_nonce_details_spec.rb +51 -0
- data/spec/unit/braintree/payment_method_nonce_spec.rb +40 -0
- data/spec/unit/braintree/payment_method_spec.rb +1 -1
- data/spec/unit/braintree/paypal_account_spec.rb +2 -2
- data/spec/unit/braintree/resource_collection_spec.rb +30 -1
- data/spec/unit/braintree/risk_data/liability_shift.rb +26 -0
- data/spec/unit/braintree/risk_data_spec.rb +40 -6
- data/spec/unit/braintree/sepa_debit_account_nonce_details_spec.rb +29 -0
- data/spec/unit/braintree/sepa_debit_account_spec.rb +86 -0
- data/spec/unit/braintree/subscription_search_spec.rb +1 -1
- data/spec/unit/braintree/subscription_spec.rb +2 -2
- data/spec/unit/braintree/successful_result_spec.rb +1 -1
- data/spec/unit/braintree/three_d_secure_info_spec.rb +34 -6
- data/spec/unit/braintree/transaction/credit_card_details_spec.rb +19 -3
- data/spec/unit/braintree/transaction/customer_details_spec.rb +1 -1
- data/spec/unit/braintree/transaction/deposit_details_spec.rb +2 -2
- data/spec/unit/braintree/transaction/installment_spec.rb +25 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +63 -0
- data/spec/unit/braintree/transaction/sepa_direct_debit_account_details_spec.rb +33 -0
- data/spec/unit/braintree/transaction_gateway_spec.rb +111 -0
- data/spec/unit/braintree/transaction_search_spec.rb +12 -12
- data/spec/unit/braintree/transaction_spec.rb +171 -55
- data/spec/unit/braintree/us_bank_account_verification_search_spec.rb +60 -0
- data/spec/unit/braintree/us_bank_account_verification_spec.rb +93 -0
- data/spec/unit/braintree/util_spec.rb +162 -19
- data/spec/unit/braintree/validation_error_collection_spec.rb +336 -133
- data/spec/unit/braintree/venmo_profile_data_spec.rb +32 -0
- data/spec/unit/braintree/webhook_notification_spec.rb +546 -114
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- data/spec/unit/braintree/xml_spec.rb +31 -24
- data/spec/unit/braintree_spec.rb +1 -0
- metadata +290 -198
- data/README.rdoc +0 -93
- data/lib/braintree/amex_express_checkout_card.rb +0 -26
- data/lib/braintree/android_pay_card.rb +0 -35
- data/lib/braintree/coinbase_account.rb +0 -25
- data/lib/braintree/europe_bank_account.rb +0 -34
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -46
- data/lib/braintree/ideal_payment_gateway.rb +0 -18
- data/lib/braintree/masterpass_card.rb +0 -66
- data/lib/braintree/settlement_batch.rb +0 -0
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -14
- data/lib/braintree/transaction/android_pay_details.rb +0 -17
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -13
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/httpsd.pid +0 -1
- data/spec/integration/braintree/coinbase_spec.rb +0 -31
- data/spec/integration/braintree/ideal_payment_spec.rb +0 -87
- data/spec/integration/braintree/masterpass_card_spec.rb +0 -97
- data/spec/integration/braintree/transparent_redirect_spec.rb +0 -268
- data/spec/unit/braintree/transparent_redirect_spec.rb +0 -223
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
2
3
|
|
3
4
|
describe Braintree::Plan do
|
4
5
|
|
@@ -48,6 +49,87 @@ describe Braintree::Plan do
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
52
|
+
describe "self.create" do
|
53
|
+
let(:attributes) do
|
54
|
+
{
|
55
|
+
:billing_day_of_month => 12,
|
56
|
+
:billing_frequency => 1,
|
57
|
+
:currency_iso_code => "USD",
|
58
|
+
:description => "description on create",
|
59
|
+
:name => "my new plan name",
|
60
|
+
:number_of_billing_cycles => 1,
|
61
|
+
:price => "9.99",
|
62
|
+
:trial_period => false
|
63
|
+
}
|
64
|
+
|
65
|
+
it "is successful with given params" do
|
66
|
+
result = Braintree::Plan.create(attributes)
|
67
|
+
expect(result.success?).to be_truthy
|
68
|
+
expect(result.plan.billing_day_of_month).to eq 12
|
69
|
+
expect(result.plan.description).to eq "description on create"
|
70
|
+
expect(result.plan.name).to eq "my new plan name"
|
71
|
+
expect(result.plan.price).to eq "9.99"
|
72
|
+
expect(result.plan.billing_frequency).to eq 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "self.find" do
|
78
|
+
it "finds a plan" do
|
79
|
+
plan = Braintree::Plan.create(
|
80
|
+
:billing_day_of_month => 12,
|
81
|
+
:billing_frequency => 1,
|
82
|
+
:currency_iso_code => "USD",
|
83
|
+
:description => "description on create",
|
84
|
+
:name => "my new plan name",
|
85
|
+
:number_of_billing_cycles => 1,
|
86
|
+
:price => "9.99",
|
87
|
+
:trial_period => false,
|
88
|
+
).plan
|
89
|
+
|
90
|
+
found_plan = Braintree::Plan.find(plan.id)
|
91
|
+
expect(found_plan.name).to eq plan.name
|
92
|
+
end
|
93
|
+
|
94
|
+
it "raises Braintree::NotFoundError if it cannot find" do
|
95
|
+
expect {
|
96
|
+
Braintree::Plan.find("noSuchPlan")
|
97
|
+
}.to raise_error(Braintree::NotFoundError, 'plan with id "noSuchPlan" not found')
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "self.update!" do
|
102
|
+
before(:each) do
|
103
|
+
@plan = Braintree::Plan.create(
|
104
|
+
:billing_day_of_month => 12,
|
105
|
+
:billing_frequency => 1,
|
106
|
+
:currency_iso_code => "USD",
|
107
|
+
:description => "description on create",
|
108
|
+
:name => "my new plan name",
|
109
|
+
:number_of_billing_cycles => 1,
|
110
|
+
:price => "9.99",
|
111
|
+
:trial_period => false,
|
112
|
+
).plan
|
113
|
+
end
|
114
|
+
|
115
|
+
it "returns the updated plan if valid" do
|
116
|
+
new_id = rand(36**9).to_s(36)
|
117
|
+
plan = Braintree::Plan.update!(@plan.id,
|
118
|
+
:name => "updated name",
|
119
|
+
:price => 99.88,
|
120
|
+
)
|
121
|
+
|
122
|
+
expect(plan.name).to eq "updated name"
|
123
|
+
expect(plan.price).to eq BigDecimal("99.88")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "raises a ValidationsFailed if invalid" do
|
127
|
+
expect do
|
128
|
+
Braintree::Plan.update!(@plan.id, :number_of_billing_cycles => "number of billing cycles")
|
129
|
+
end.to raise_error(Braintree::ValidationsFailed)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
51
133
|
def create_plan_for_tests(attributes)
|
52
134
|
config = Braintree::Configuration.gateway.config
|
53
135
|
config.http.post("#{config.base_merchant_path}/plans/create_plan_for_tests", :plan => attributes)
|
@@ -0,0 +1,144 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/client_api/spec_helper")
|
3
|
+
|
4
|
+
describe Braintree::SamsungPayCard do
|
5
|
+
it "can create from payment method nonce" do
|
6
|
+
customer = Braintree::Customer.create!
|
7
|
+
|
8
|
+
result = Braintree::PaymentMethod.create(
|
9
|
+
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
10
|
+
:customer_id => customer.id,
|
11
|
+
:cardholder_name => "Jenny Block",
|
12
|
+
:billing_address => {
|
13
|
+
:first_name => "New First Name",
|
14
|
+
:last_name => "New Last Name",
|
15
|
+
:company => "New Company",
|
16
|
+
:street_address => "123 New St",
|
17
|
+
:extended_address => "Apt New",
|
18
|
+
:locality => "New City",
|
19
|
+
:region => "New State",
|
20
|
+
:postal_code => "56789",
|
21
|
+
:country_name => "United States of America"
|
22
|
+
},
|
23
|
+
)
|
24
|
+
result.should be_success
|
25
|
+
|
26
|
+
samsung_pay_card = result.payment_method
|
27
|
+
samsung_pay_card.should be_a(Braintree::SamsungPayCard)
|
28
|
+
samsung_pay_card.billing_address.should_not be_nil
|
29
|
+
samsung_pay_card.bin.should_not be_nil
|
30
|
+
samsung_pay_card.cardholder_name.should_not be_nil
|
31
|
+
samsung_pay_card.card_type.should_not be_nil
|
32
|
+
samsung_pay_card.commercial.should_not be_nil
|
33
|
+
samsung_pay_card.country_of_issuance.should_not be_nil
|
34
|
+
samsung_pay_card.created_at.should_not be_nil
|
35
|
+
samsung_pay_card.customer_id.should_not be_nil
|
36
|
+
samsung_pay_card.customer_location.should_not be_nil
|
37
|
+
samsung_pay_card.debit.should_not be_nil
|
38
|
+
samsung_pay_card.default?.should_not be_nil
|
39
|
+
samsung_pay_card.durbin_regulated.should_not be_nil
|
40
|
+
samsung_pay_card.expiration_date.should_not be_nil
|
41
|
+
samsung_pay_card.expiration_month.should_not be_nil
|
42
|
+
samsung_pay_card.expiration_year.should_not be_nil
|
43
|
+
samsung_pay_card.expired?.should_not be_nil
|
44
|
+
samsung_pay_card.healthcare.should_not be_nil
|
45
|
+
samsung_pay_card.image_url.should_not be_nil
|
46
|
+
samsung_pay_card.issuing_bank.should_not be_nil
|
47
|
+
samsung_pay_card.last_4.should_not be_nil
|
48
|
+
samsung_pay_card.payroll.should_not be_nil
|
49
|
+
samsung_pay_card.prepaid.should_not be_nil
|
50
|
+
samsung_pay_card.product_id.should_not be_nil
|
51
|
+
samsung_pay_card.source_card_last_4.should_not be_nil
|
52
|
+
samsung_pay_card.subscriptions.should_not be_nil
|
53
|
+
samsung_pay_card.token.should_not be_nil
|
54
|
+
samsung_pay_card.unique_number_identifier.should_not be_nil
|
55
|
+
samsung_pay_card.updated_at.should_not be_nil
|
56
|
+
|
57
|
+
customer = Braintree::Customer.find(customer.id)
|
58
|
+
customer.samsung_pay_cards.size.should == 1
|
59
|
+
customer.samsung_pay_cards.first.should == samsung_pay_card
|
60
|
+
end
|
61
|
+
|
62
|
+
it "returns cardholder_name and billing_address" do
|
63
|
+
customer = Braintree::Customer.create!
|
64
|
+
|
65
|
+
result = Braintree::PaymentMethod.create(
|
66
|
+
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
67
|
+
:customer_id => customer.id,
|
68
|
+
:cardholder_name => "Jenny Block",
|
69
|
+
:billing_address => {
|
70
|
+
:first_name => "New First Name",
|
71
|
+
:last_name => "New Last Name",
|
72
|
+
:company => "New Company",
|
73
|
+
:street_address => "123 New St",
|
74
|
+
:extended_address => "Apt New",
|
75
|
+
:locality => "New City",
|
76
|
+
:region => "New State",
|
77
|
+
:postal_code => "56789",
|
78
|
+
:country_name => "United States of America"
|
79
|
+
},
|
80
|
+
)
|
81
|
+
|
82
|
+
result.should be_success
|
83
|
+
result.payment_method.cardholder_name.should == "Jenny Block"
|
84
|
+
|
85
|
+
address = result.payment_method.billing_address
|
86
|
+
address.first_name.should == "New First Name"
|
87
|
+
address.last_name.should == "New Last Name"
|
88
|
+
address.company.should == "New Company"
|
89
|
+
address.street_address.should == "123 New St"
|
90
|
+
address.extended_address.should == "Apt New"
|
91
|
+
address.locality.should == "New City"
|
92
|
+
address.region.should == "New State"
|
93
|
+
address.postal_code.should == "56789"
|
94
|
+
end
|
95
|
+
|
96
|
+
it "can search for transactions" do
|
97
|
+
transaction_create_result = Braintree::Transaction.sale(
|
98
|
+
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
99
|
+
:amount => "47.00",
|
100
|
+
)
|
101
|
+
transaction_create_result.should be_success
|
102
|
+
transaction_id = transaction_create_result.transaction.id
|
103
|
+
|
104
|
+
search_results = Braintree::Transaction.search do |search|
|
105
|
+
search.id.is transaction_id
|
106
|
+
search.payment_instrument_type.is Braintree::PaymentInstrumentType::SamsungPayCard
|
107
|
+
end
|
108
|
+
search_results.first.id.should == transaction_id
|
109
|
+
end
|
110
|
+
|
111
|
+
it "can create transaction from nonce and vault" do
|
112
|
+
customer = Braintree::Customer.create!
|
113
|
+
|
114
|
+
result = Braintree::Transaction.sale(
|
115
|
+
:payment_method_nonce => Braintree::Test::Nonce::SamsungPayDiscover,
|
116
|
+
:customer_id => customer.id,
|
117
|
+
:amount => "47.00",
|
118
|
+
:options => {:store_in_vault => true},
|
119
|
+
)
|
120
|
+
result.should be_success
|
121
|
+
|
122
|
+
samsung_pay_card_details = result.transaction.samsung_pay_card_details
|
123
|
+
samsung_pay_card_details.bin.should_not be_nil
|
124
|
+
samsung_pay_card_details.card_type.should_not be_nil
|
125
|
+
samsung_pay_card_details.commercial.should_not be_nil
|
126
|
+
samsung_pay_card_details.country_of_issuance.should_not be_nil
|
127
|
+
samsung_pay_card_details.customer_location.should_not be_nil
|
128
|
+
samsung_pay_card_details.debit.should_not be_nil
|
129
|
+
samsung_pay_card_details.durbin_regulated.should_not be_nil
|
130
|
+
samsung_pay_card_details.expiration_date.should_not be_nil
|
131
|
+
samsung_pay_card_details.expiration_month.should_not be_nil
|
132
|
+
samsung_pay_card_details.expiration_year.should_not be_nil
|
133
|
+
samsung_pay_card_details.healthcare.should_not be_nil
|
134
|
+
samsung_pay_card_details.image_url.should_not be_nil
|
135
|
+
samsung_pay_card_details.issuing_bank.should_not be_nil
|
136
|
+
samsung_pay_card_details.last_4.should_not be_nil
|
137
|
+
samsung_pay_card_details.payroll.should_not be_nil
|
138
|
+
samsung_pay_card_details.prepaid.should_not be_nil
|
139
|
+
samsung_pay_card_details.product_id.should_not be_nil
|
140
|
+
samsung_pay_card_details.source_card_last_4.should_not be_nil
|
141
|
+
samsung_pay_card_details.source_card_last_4.should == "3333"
|
142
|
+
samsung_pay_card_details.token.should_not be_nil
|
143
|
+
end
|
144
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
+
|
3
|
+
describe Braintree::SepaDirectDebitAccount do
|
4
|
+
before do
|
5
|
+
Braintree::Configuration.merchant_id = "integration_merchant_id"
|
6
|
+
Braintree::Configuration.public_key = "integration_public_key"
|
7
|
+
Braintree::Configuration.private_key = "integration_private_key"
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:customer) { Braintree::Customer.create.customer }
|
11
|
+
let(:nonce) { Braintree::Test::Nonce::SepaDirectDebit }
|
12
|
+
|
13
|
+
let(:token) do
|
14
|
+
Braintree::PaymentMethod.create(
|
15
|
+
payment_method_nonce: nonce,
|
16
|
+
customer_id: customer.id,
|
17
|
+
).payment_method.token
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "self.find" do
|
21
|
+
subject do
|
22
|
+
described_class.find(token)
|
23
|
+
end
|
24
|
+
|
25
|
+
context "when payment method exists" do
|
26
|
+
it "returns a payment method" do
|
27
|
+
sepa_direct_debit_account = subject
|
28
|
+
sepa_direct_debit_account.should be_a(Braintree::SepaDirectDebitAccount)
|
29
|
+
sepa_direct_debit_account.last_4.should == "1234"
|
30
|
+
sepa_direct_debit_account.default.should == true
|
31
|
+
sepa_direct_debit_account.customer_id.should == customer.id
|
32
|
+
sepa_direct_debit_account.global_id.should_not be_empty
|
33
|
+
sepa_direct_debit_account.customer_global_id.should_not be_empty
|
34
|
+
sepa_direct_debit_account.bank_reference_token.should == "a-fake-bank-reference-token"
|
35
|
+
sepa_direct_debit_account.mandate_type.should == "RECURRENT"
|
36
|
+
sepa_direct_debit_account.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
|
37
|
+
sepa_direct_debit_account.token.should_not be_empty
|
38
|
+
sepa_direct_debit_account.image_url.should_not be_empty
|
39
|
+
sepa_direct_debit_account.created_at.should be_a Time
|
40
|
+
sepa_direct_debit_account.updated_at.should be_a Time
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when payment method does not exist" do
|
45
|
+
let(:token) { "ABC123" }
|
46
|
+
|
47
|
+
it "raises an error" do
|
48
|
+
expect {
|
49
|
+
subject
|
50
|
+
}.to raise_error(Braintree::NotFoundError)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "subscriptions" do
|
55
|
+
it "returns subscriptions associated with a SEPA direct debit account" do
|
56
|
+
customer = Braintree::Customer.create!
|
57
|
+
|
58
|
+
subscription1 = Braintree::Subscription.create(
|
59
|
+
:payment_method_token => token,
|
60
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
61
|
+
).subscription
|
62
|
+
|
63
|
+
subscription2 = Braintree::Subscription.create(
|
64
|
+
:payment_method_token => token,
|
65
|
+
:plan_id => SpecHelper::TriallessPlan[:id],
|
66
|
+
).subscription
|
67
|
+
|
68
|
+
sepa_debit_account = Braintree::SepaDirectDebitAccount.find(token)
|
69
|
+
subscription_ids = sepa_debit_account.subscriptions.map { |h| h[:id] }.sort
|
70
|
+
expect(subscription_ids).to eq([subscription1.id, subscription2.id].sort)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "self.delete" do
|
76
|
+
subject do
|
77
|
+
described_class.delete(token)
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when payment method exists" do
|
81
|
+
it "deletes a payment method" do
|
82
|
+
should be_success
|
83
|
+
|
84
|
+
expect {
|
85
|
+
described_class.find(token)
|
86
|
+
}.to raise_error(Braintree::NotFoundError)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "when payment method does not exist" do
|
91
|
+
let(:token) { "ABC123" }
|
92
|
+
|
93
|
+
it "raises an error" do
|
94
|
+
expect {
|
95
|
+
subject
|
96
|
+
}.to raise_error(Braintree::NotFoundError)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe "self.sale" do
|
102
|
+
let(:params) do
|
103
|
+
{
|
104
|
+
amount: 1.23,
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
subject do
|
109
|
+
described_class.sale(token, params)
|
110
|
+
end
|
111
|
+
|
112
|
+
context "when payment method exists" do
|
113
|
+
it "creates a transaction" do
|
114
|
+
should be_success
|
115
|
+
|
116
|
+
transaction = subject.transaction
|
117
|
+
transaction.amount.should eq(1.23)
|
118
|
+
transaction.status.should == "settling"
|
119
|
+
sepa_direct_debit_account_details = transaction.sepa_direct_debit_account_details
|
120
|
+
sepa_direct_debit_account_details.should be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
|
121
|
+
sepa_direct_debit_account_details.bank_reference_token.should == "a-fake-bank-reference-token"
|
122
|
+
sepa_direct_debit_account_details.capture_id.should_not be_empty
|
123
|
+
sepa_direct_debit_account_details.debug_id.should be_nil
|
124
|
+
sepa_direct_debit_account_details.global_id.should_not be_empty
|
125
|
+
sepa_direct_debit_account_details.last_4.should == "1234"
|
126
|
+
sepa_direct_debit_account_details.mandate_type.should == "RECURRENT"
|
127
|
+
sepa_direct_debit_account_details.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
|
128
|
+
sepa_direct_debit_account_details.paypal_v2_order_id.should be_nil
|
129
|
+
sepa_direct_debit_account_details.refund_from_transaction_fee_amount.should be_nil
|
130
|
+
sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.should be_nil
|
131
|
+
sepa_direct_debit_account_details.refund_id.should be_nil
|
132
|
+
sepa_direct_debit_account_details.settlement_type.should be_nil
|
133
|
+
sepa_direct_debit_account_details.token.should == token
|
134
|
+
sepa_direct_debit_account_details.transaction_fee_amount.should == "0.01"
|
135
|
+
sepa_direct_debit_account_details.transaction_fee_currency_iso_code.should == "USD"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "when payment method does not exist" do
|
140
|
+
let(:token) { "ABC123" }
|
141
|
+
|
142
|
+
it "not raises an error" do
|
143
|
+
expect {
|
144
|
+
subject
|
145
|
+
}.to_not raise_error
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
describe "self.sale!" do
|
151
|
+
let(:params) do
|
152
|
+
{
|
153
|
+
amount: 1.23,
|
154
|
+
}
|
155
|
+
end
|
156
|
+
|
157
|
+
subject do
|
158
|
+
described_class.sale!(token, params)
|
159
|
+
end
|
160
|
+
|
161
|
+
context "when payment method exists" do
|
162
|
+
it "creates a transaction" do
|
163
|
+
transaction = subject
|
164
|
+
transaction.amount.should eq(1.23)
|
165
|
+
transaction.status.should == "settling"
|
166
|
+
sepa_direct_debit_account_details = transaction.sepa_direct_debit_account_details
|
167
|
+
sepa_direct_debit_account_details.should be_a(Braintree::Transaction::SepaDirectDebitAccountDetails)
|
168
|
+
sepa_direct_debit_account_details.bank_reference_token.should == "a-fake-bank-reference-token"
|
169
|
+
sepa_direct_debit_account_details.capture_id.should_not be_empty
|
170
|
+
sepa_direct_debit_account_details.debug_id.should be_nil
|
171
|
+
sepa_direct_debit_account_details.global_id.should_not be_empty
|
172
|
+
sepa_direct_debit_account_details.last_4.should == "1234"
|
173
|
+
sepa_direct_debit_account_details.mandate_type.should == "RECURRENT"
|
174
|
+
sepa_direct_debit_account_details.merchant_or_partner_customer_id.should == "a-fake-mp-customer-id"
|
175
|
+
sepa_direct_debit_account_details.paypal_v2_order_id.should be_nil
|
176
|
+
sepa_direct_debit_account_details.refund_from_transaction_fee_amount.should be_nil
|
177
|
+
sepa_direct_debit_account_details.refund_from_transaction_fee_currency_iso_code.should be_nil
|
178
|
+
sepa_direct_debit_account_details.refund_id.should be_nil
|
179
|
+
sepa_direct_debit_account_details.settlement_type.should be_nil
|
180
|
+
sepa_direct_debit_account_details.token.should == token
|
181
|
+
sepa_direct_debit_account_details.transaction_fee_amount.should == "0.01"
|
182
|
+
sepa_direct_debit_account_details.transaction_fee_currency_iso_code.should == "USD"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
context "when payment method does not exist" do
|
187
|
+
let(:token) { "ABC123" }
|
188
|
+
|
189
|
+
it "not raises an error" do
|
190
|
+
expect {
|
191
|
+
subject
|
192
|
+
}.to raise_error(Braintree::ValidationsFailed)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -12,7 +12,7 @@ describe Braintree::SettlementBatchSummary do
|
|
12
12
|
it "returns an error response if the date cannot be parsed" do
|
13
13
|
result = Braintree::SettlementBatchSummary.generate("NOT A DATE :(")
|
14
14
|
result.should_not be_success
|
15
|
-
result.errors.for(:settlement_batch_summary).on(:settlement_date).map {|e| e.code}.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
15
|
+
result.errors.for(:settlement_batch_summary).on(:settlement_date).map { |e| e.code }.should include(Braintree::ErrorCodes::SettlementBatchSummary::SettlementDateIsInvalid)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "returns transactions settled on a given day" do
|
@@ -23,14 +23,14 @@ describe Braintree::SettlementBatchSummary do
|
|
23
23
|
:expiration_date => "05/2012",
|
24
24
|
:cardholder_name => "Sergio Ramos"
|
25
25
|
},
|
26
|
-
:options => {
|
26
|
+
:options => {:submit_for_settlement => true},
|
27
27
|
)
|
28
28
|
result = SpecHelper.settle_transaction transaction.id
|
29
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
29
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
30
30
|
result = Braintree::SettlementBatchSummary.generate(settlement_date)
|
31
31
|
|
32
32
|
result.should be_success
|
33
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
33
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:card_type] == Braintree::CreditCard::CardType::AmEx }
|
34
34
|
amex_records.first[:count].to_i.should >= 1
|
35
35
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|
36
36
|
end
|
@@ -46,14 +46,14 @@ describe Braintree::SettlementBatchSummary do
|
|
46
46
|
:custom_fields => {
|
47
47
|
:store_me => "1"
|
48
48
|
},
|
49
|
-
:options => {
|
49
|
+
:options => {:submit_for_settlement => true},
|
50
50
|
)
|
51
51
|
result = SpecHelper.settle_transaction transaction.id
|
52
|
-
settlement_date = result[:transaction][:settlement_batch_id].split(
|
53
|
-
result = Braintree::SettlementBatchSummary.generate(settlement_date,
|
52
|
+
settlement_date = result[:transaction][:settlement_batch_id].split("_").first
|
53
|
+
result = Braintree::SettlementBatchSummary.generate(settlement_date, "store_me")
|
54
54
|
|
55
55
|
result.should be_success
|
56
|
-
amex_records = result.settlement_batch_summary.records.select {|row| row[:store_me] == "1" }
|
56
|
+
amex_records = result.settlement_batch_summary.records.select { |row| row[:store_me] == "1" }
|
57
57
|
amex_records.should_not be_empty
|
58
58
|
amex_records.first[:count].to_i.should >= 1
|
59
59
|
amex_records.first[:amount_settled].to_i.should >= Braintree::Test::TransactionAmounts::Authorize.to_i
|