braintree 2.104.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/braintree.gemspec +6 -3
- data/lib/braintree.rb +3 -17
- data/lib/braintree/address.rb +0 -22
- data/lib/braintree/base_module.rb +6 -0
- data/lib/braintree/bin_data.rb +9 -2
- data/lib/braintree/configuration.rb +1 -1
- data/lib/braintree/credit_card.rb +0 -75
- data/lib/braintree/credit_card_gateway.rb +3 -32
- data/lib/braintree/credit_card_verification.rb +13 -0
- data/lib/braintree/customer.rb +3 -74
- data/lib/braintree/customer_gateway.rb +0 -23
- data/lib/braintree/dispute.rb +1 -7
- data/lib/braintree/dispute/{history_event.rb → status_history.rb} +3 -1
- data/lib/braintree/dispute_gateway.rb +2 -7
- data/lib/braintree/error_codes.rb +139 -170
- data/lib/braintree/exceptions.rb +5 -3
- data/lib/braintree/gateway.rb +0 -14
- data/lib/braintree/{android_pay_card.rb → google_pay_card.rb} +1 -2
- data/lib/braintree/local_payment_completed.rb +1 -1
- data/lib/braintree/merchant_account_gateway.rb +2 -0
- data/lib/braintree/payment_instrument_type.rb +1 -5
- data/lib/braintree/payment_method_gateway.rb +4 -9
- data/lib/braintree/payment_method_parser.rb +1 -8
- data/lib/braintree/subscription.rb +5 -5
- data/lib/braintree/successful_result.rb +0 -1
- data/lib/braintree/test/nonce.rb +4 -23
- data/lib/braintree/transaction.rb +4 -80
- data/lib/braintree/transaction/disbursement_details.rb +1 -0
- data/lib/braintree/transaction/{android_pay_details.rb → google_pay_details.rb} +1 -1
- data/lib/braintree/transaction/paypal_details.rb +1 -0
- data/lib/braintree/transaction/subscription_details.rb +2 -0
- data/lib/braintree/transaction_gateway.rb +12 -21
- data/lib/braintree/transaction_search.rb +0 -1
- data/lib/braintree/util.rb +17 -2
- data/lib/braintree/version.rb +2 -2
- data/lib/braintree/webhook_notification.rb +0 -10
- data/lib/braintree/webhook_testing_gateway.rb +0 -43
- data/lib/braintree/xml/libxml.rb +1 -0
- data/lib/braintree/xml/parser.rb +11 -34
- data/spec/integration/braintree/address_spec.rb +2 -89
- data/spec/integration/braintree/client_api/spec_helper.rb +0 -26
- data/spec/integration/braintree/credit_card_spec.rb +6 -471
- data/spec/integration/braintree/customer_spec.rb +22 -362
- data/spec/integration/braintree/dispute_search_spec.rb +3 -3
- data/spec/integration/braintree/dispute_spec.rb +1 -2
- data/spec/integration/braintree/payment_method_spec.rb +77 -120
- data/spec/integration/braintree/subscription_spec.rb +11 -16
- data/spec/integration/braintree/transaction_search_spec.rb +3 -3
- data/spec/integration/braintree/transaction_spec.rb +106 -511
- data/spec/integration/spec_helper.rb +1 -4
- data/spec/spec_helper.rb +1 -11
- data/spec/unit/braintree/address_spec.rb +0 -8
- data/spec/unit/braintree/credit_card_spec.rb +1 -20
- data/spec/unit/braintree/customer_spec.rb +0 -12
- data/spec/unit/braintree/dispute_spec.rb +1 -12
- data/spec/unit/braintree/http_spec.rb +3 -3
- data/spec/unit/braintree/local_payment_completed_spec.rb +14 -0
- data/spec/unit/braintree/transaction/paypal_details_spec.rb +2 -0
- data/spec/unit/braintree/transaction_spec.rb +1 -35
- data/spec/unit/braintree/util_spec.rb +37 -3
- data/spec/unit/braintree/webhook_notification_spec.rb +1 -1
- data/spec/unit/braintree/xml/parser_spec.rb +21 -16
- metadata +26 -30
- data/lib/braintree/amex_express_checkout_card.rb +0 -40
- data/lib/braintree/coinbase_account.rb +0 -34
- data/lib/braintree/europe_bank_account.rb +0 -36
- data/lib/braintree/europe_bank_account_gateway.rb +0 -17
- data/lib/braintree/ideal_payment.rb +0 -61
- data/lib/braintree/ideal_payment_gateway.rb +0 -19
- data/lib/braintree/masterpass_card.rb +0 -83
- data/lib/braintree/transaction/amex_express_checkout_details.rb +0 -21
- data/lib/braintree/transaction/coinbase_details.rb +0 -16
- data/lib/braintree/transaction/ideal_payment_details.rb +0 -19
- data/lib/braintree/transaction/masterpass_card_details.rb +0 -49
- data/lib/braintree/transparent_redirect.rb +0 -40
- data/lib/braintree/transparent_redirect_gateway.rb +0 -105
- data/lib/braintree/xml/rexml.rb +0 -71
- data/spec/hacks/tcp_socket.rb +0 -18
- data/spec/integration/braintree/coinbase_spec.rb +0 -34
- 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
- data/spec/unit/braintree/xml/rexml_spec.rb +0 -51
@@ -1,21 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class Transaction
|
3
|
-
class AmexExpressCheckoutDetails
|
4
|
-
include BaseModule
|
5
|
-
|
6
|
-
attr_reader :bin
|
7
|
-
attr_reader :card_member_expiry_date
|
8
|
-
attr_reader :card_member_number
|
9
|
-
attr_reader :card_type
|
10
|
-
attr_reader :expiration_month
|
11
|
-
attr_reader :expiration_year
|
12
|
-
attr_reader :image_url
|
13
|
-
attr_reader :source_description
|
14
|
-
attr_reader :token
|
15
|
-
|
16
|
-
def initialize(attributes)
|
17
|
-
set_instance_variables_from_hash attributes unless attributes.nil?
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class Transaction
|
3
|
-
class CoinbaseDetails
|
4
|
-
include BaseModule
|
5
|
-
|
6
|
-
attr_reader :user_id
|
7
|
-
attr_reader :user_email
|
8
|
-
attr_reader :user_name
|
9
|
-
attr_reader :token
|
10
|
-
|
11
|
-
def initialize(attributes)
|
12
|
-
set_instance_variables_from_hash attributes unless attributes.nil?
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
# NEXT_MAJOR_VERSION Remove this class as legacy Ideal has been removed/disabled in the Braintree Gateway
|
3
|
-
# DEPRECATED If you're looking to accept iDEAL as a payment method contact accounts@braintreepayments.com for a solution.
|
4
|
-
class Transaction
|
5
|
-
class IdealPaymentDetails # :nodoc:
|
6
|
-
include BaseModule
|
7
|
-
|
8
|
-
attr_reader :bic
|
9
|
-
attr_reader :ideal_payment_id
|
10
|
-
attr_reader :ideal_transaction_id
|
11
|
-
attr_reader :image_url
|
12
|
-
attr_reader :masked_iban
|
13
|
-
|
14
|
-
def initialize(attributes)
|
15
|
-
set_instance_variables_from_hash attributes unless attributes.nil?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class Transaction
|
3
|
-
# NEXT_MAJOR_VERSION Remove this class.
|
4
|
-
# DEPRECATED The Masterpass Card payment method is deprecated.
|
5
|
-
class MasterpassCardDetails # :nodoc:
|
6
|
-
include BaseModule
|
7
|
-
|
8
|
-
attr_reader :bin
|
9
|
-
attr_reader :card_type
|
10
|
-
attr_reader :cardholder_name
|
11
|
-
attr_reader :commercial
|
12
|
-
attr_reader :country_of_issuance
|
13
|
-
attr_reader :customer_location
|
14
|
-
attr_reader :debit
|
15
|
-
attr_reader :durbin_regulated
|
16
|
-
attr_reader :expiration_month
|
17
|
-
attr_reader :expiration_year
|
18
|
-
attr_reader :healthcare
|
19
|
-
attr_reader :image_url
|
20
|
-
attr_reader :issuing_bank
|
21
|
-
attr_reader :last_4
|
22
|
-
attr_reader :payroll
|
23
|
-
attr_reader :prepaid
|
24
|
-
attr_reader :product_id
|
25
|
-
attr_reader :token
|
26
|
-
|
27
|
-
def initialize(attributes)
|
28
|
-
set_instance_variables_from_hash attributes unless attributes.nil?
|
29
|
-
end
|
30
|
-
|
31
|
-
def expiration_date
|
32
|
-
"#{expiration_month}/#{expiration_year}"
|
33
|
-
end
|
34
|
-
|
35
|
-
def inspect
|
36
|
-
attr_order = [:token, :bin, :last_4, :card_type, :expiration_date, :cardholder_name, :customer_location, :prepaid,
|
37
|
-
:healthcare, :durbin_regulated, :debit, :commercial, :payroll, :product_id, :country_of_issuance, :issuing_bank, :image_url]
|
38
|
-
formatted_attrs = attr_order.map do |attr|
|
39
|
-
"#{attr}: #{send(attr).inspect}"
|
40
|
-
end
|
41
|
-
"#<#{formatted_attrs.join(", ")}>"
|
42
|
-
end
|
43
|
-
|
44
|
-
def masked_number
|
45
|
-
"#{bin}******#{last_4}"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
module TransparentRedirect
|
3
|
-
module Kind # :nodoc:
|
4
|
-
CreateCustomer = "create_customer"
|
5
|
-
UpdateCustomer = "update_customer"
|
6
|
-
CreatePaymentMethod = "create_payment_method"
|
7
|
-
UpdatePaymentMethod = "update_payment_method"
|
8
|
-
CreateTransaction = "create_transaction"
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.confirm(*args)
|
12
|
-
Configuration.gateway.transparent_redirect.confirm(*args)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.create_credit_card_data(*args)
|
16
|
-
Configuration.gateway.transparent_redirect.create_credit_card_data(*args)
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.create_customer_data(*args)
|
20
|
-
Configuration.gateway.transparent_redirect.create_customer_data(*args)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.transaction_data(*args)
|
24
|
-
Configuration.gateway.transparent_redirect.transaction_data(*args)
|
25
|
-
end
|
26
|
-
|
27
|
-
def self.update_credit_card_data(*args)
|
28
|
-
Configuration.gateway.transparent_redirect.update_credit_card_data(*args)
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.update_customer_data(*args)
|
32
|
-
Configuration.gateway.transparent_redirect.update_customer_data(*args)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns the URL to which Transparent Redirect Requests should be posted
|
36
|
-
def self.url
|
37
|
-
Configuration.gateway.transparent_redirect.url
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
module Braintree
|
2
|
-
class TransparentRedirectGateway # :nodoc
|
3
|
-
TransparentRedirectKeys = [:redirect_url] # :nodoc:
|
4
|
-
CreateCustomerSignature = TransparentRedirectKeys + [{:customer => CustomerGateway._create_signature}] # :nodoc:
|
5
|
-
UpdateCustomerSignature = TransparentRedirectKeys + [:customer_id, {:customer => CustomerGateway._update_signature}] # :nodoc:
|
6
|
-
TransactionSignature = TransparentRedirectKeys + [{:transaction => TransactionGateway._create_signature}] # :nodoc:
|
7
|
-
CreateCreditCardSignature = TransparentRedirectKeys + [{:credit_card => CreditCardGateway._create_signature}] # :nodoc:
|
8
|
-
UpdateCreditCardSignature = TransparentRedirectKeys + [:payment_method_token, {:credit_card => CreditCardGateway._update_signature}] # :nodoc:
|
9
|
-
|
10
|
-
def initialize(gateway)
|
11
|
-
@gateway = gateway
|
12
|
-
@config = gateway.config
|
13
|
-
@config.assert_has_access_token_or_keys
|
14
|
-
end
|
15
|
-
|
16
|
-
def confirm(query_string)
|
17
|
-
params = @gateway.transparent_redirect.parse_and_validate_query_string query_string
|
18
|
-
confirmation_gateway = {
|
19
|
-
TransparentRedirect::Kind::CreateCustomer => :customer,
|
20
|
-
TransparentRedirect::Kind::UpdateCustomer => :customer,
|
21
|
-
TransparentRedirect::Kind::CreatePaymentMethod => :credit_card,
|
22
|
-
TransparentRedirect::Kind::UpdatePaymentMethod => :credit_card,
|
23
|
-
TransparentRedirect::Kind::CreateTransaction => :transaction
|
24
|
-
}[params[:kind]]
|
25
|
-
|
26
|
-
@gateway.send(confirmation_gateway)._do_create("/transparent_redirect_requests/#{params[:id]}/confirm")
|
27
|
-
end
|
28
|
-
|
29
|
-
def create_credit_card_data(params)
|
30
|
-
Util.verify_keys(CreateCreditCardSignature, params)
|
31
|
-
params[:kind] = TransparentRedirect::Kind::CreatePaymentMethod
|
32
|
-
_data(params)
|
33
|
-
end
|
34
|
-
|
35
|
-
def create_customer_data(params)
|
36
|
-
Util.verify_keys(CreateCustomerSignature, params)
|
37
|
-
params[:kind] = TransparentRedirect::Kind::CreateCustomer
|
38
|
-
_data(params)
|
39
|
-
end
|
40
|
-
|
41
|
-
def parse_and_validate_query_string(query_string) # :nodoc:
|
42
|
-
params = Util.symbolize_keys(Util.parse_query_string(query_string))
|
43
|
-
query_string_without_hash = query_string.split("&").reject{|param| param =~ /\Ahash=/}.join("&")
|
44
|
-
decoded_query_string_without_hash = Util.url_decode(query_string_without_hash)
|
45
|
-
encoded_query_string_without_hash = Util.url_encode(query_string_without_hash)
|
46
|
-
|
47
|
-
if params[:http_status] == nil
|
48
|
-
raise UnexpectedError, "expected query string to have an http_status param"
|
49
|
-
elsif params[:http_status] != '200'
|
50
|
-
Util.raise_exception_for_status_code(params[:http_status], params[:bt_message])
|
51
|
-
end
|
52
|
-
|
53
|
-
query_strings_without_hash = [query_string_without_hash, encoded_query_string_without_hash, decoded_query_string_without_hash]
|
54
|
-
|
55
|
-
if query_strings_without_hash.any? { |query_string| @config.signature_service.hash(query_string) == params[:hash] }
|
56
|
-
params
|
57
|
-
else
|
58
|
-
raise ForgedQueryString
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def transaction_data(params)
|
63
|
-
Util.verify_keys(TransactionSignature, params)
|
64
|
-
params[:kind] = TransparentRedirect::Kind::CreateTransaction
|
65
|
-
transaction_type = params[:transaction] && params[:transaction][:type]
|
66
|
-
unless %w[sale credit].include?(transaction_type)
|
67
|
-
raise ArgumentError, "expected transaction[type] of sale or credit, was: #{transaction_type.inspect}"
|
68
|
-
end
|
69
|
-
_data(params)
|
70
|
-
end
|
71
|
-
|
72
|
-
def update_credit_card_data(params)
|
73
|
-
Util.verify_keys(UpdateCreditCardSignature, params)
|
74
|
-
unless params[:payment_method_token]
|
75
|
-
raise ArgumentError, "expected params to contain :payment_method_token of payment method to update"
|
76
|
-
end
|
77
|
-
params[:kind] = TransparentRedirect::Kind::UpdatePaymentMethod
|
78
|
-
_data(params)
|
79
|
-
end
|
80
|
-
|
81
|
-
def update_customer_data(params)
|
82
|
-
Util.verify_keys(UpdateCustomerSignature, params)
|
83
|
-
unless params[:customer_id]
|
84
|
-
raise ArgumentError, "expected params to contain :customer_id of customer to update"
|
85
|
-
end
|
86
|
-
params[:kind] = TransparentRedirect::Kind::UpdateCustomer
|
87
|
-
_data(params)
|
88
|
-
end
|
89
|
-
|
90
|
-
def url
|
91
|
-
"#{@config.base_merchant_url}/transparent_redirect_requests"
|
92
|
-
end
|
93
|
-
|
94
|
-
def _data(params) # :nodoc:
|
95
|
-
raise ArgumentError, "expected params to contain :redirect_url" unless params[:redirect_url]
|
96
|
-
|
97
|
-
@config.signature_service.sign(params.merge(
|
98
|
-
:api_version => @config.api_version,
|
99
|
-
:time => Time.now.utc.strftime("%Y%m%d%H%M%S"),
|
100
|
-
:public_key => @config.public_key
|
101
|
-
))
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
data/lib/braintree/xml/rexml.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Portions of this code were copied and modified from Ruby on Rails, released
|
2
|
-
# under the MIT license, copyright (c) 2005-2009 David Heinemeier Hansson
|
3
|
-
module Braintree
|
4
|
-
module Xml # :nodoc:
|
5
|
-
module Rexml # :nodoc:
|
6
|
-
|
7
|
-
CONTENT_KEY = '__content__'.freeze
|
8
|
-
|
9
|
-
def self.parse(string)
|
10
|
-
require 'rexml/document' unless defined?(REXML::Document)
|
11
|
-
doc = REXML::Document.new(string)
|
12
|
-
_merge_element!({}, doc.root)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self._merge_element!(hash, element)
|
16
|
-
_merge!(hash, element.name, _collapse(element))
|
17
|
-
end
|
18
|
-
|
19
|
-
def self._collapse(element)
|
20
|
-
hash = _get_attributes(element)
|
21
|
-
|
22
|
-
if element.has_elements?
|
23
|
-
element.each_element {|child| _merge_element!(hash, child) }
|
24
|
-
_merge_texts!(hash, element) unless _empty_content?(element)
|
25
|
-
hash
|
26
|
-
else
|
27
|
-
_merge_texts!(hash, element)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def self._merge_texts!(hash, element)
|
32
|
-
unless element.has_text?
|
33
|
-
hash
|
34
|
-
else
|
35
|
-
# must use value to prevent double-escaping
|
36
|
-
_merge!(
|
37
|
-
hash,
|
38
|
-
CONTENT_KEY,
|
39
|
-
element.texts.map { |t| t.value}.join
|
40
|
-
)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def self._merge!(hash, key, value)
|
45
|
-
if hash.has_key?(key)
|
46
|
-
if hash[key].instance_of?(Array)
|
47
|
-
hash[key] << value
|
48
|
-
else
|
49
|
-
hash[key] = [hash[key], value]
|
50
|
-
end
|
51
|
-
elsif value.instance_of?(Array)
|
52
|
-
hash[key] = [value]
|
53
|
-
else
|
54
|
-
hash[key] = value
|
55
|
-
end
|
56
|
-
hash
|
57
|
-
end
|
58
|
-
|
59
|
-
def self._get_attributes(element)
|
60
|
-
attributes = {}
|
61
|
-
element.attributes.each { |n,v| attributes[n] = v }
|
62
|
-
attributes
|
63
|
-
end
|
64
|
-
|
65
|
-
def self._empty_content?(element)
|
66
|
-
element.texts.join.strip == ""
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
data/spec/hacks/tcp_socket.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'timeout'
|
2
|
-
require 'socket'
|
3
|
-
|
4
|
-
TCPSocket.class_eval do
|
5
|
-
def self.wait_for_service(options)
|
6
|
-
Timeout::timeout(options[:timeout] || 20) do
|
7
|
-
loop do
|
8
|
-
begin
|
9
|
-
socket = TCPSocket.new(options[:host], options[:port])
|
10
|
-
socket.close
|
11
|
-
return
|
12
|
-
rescue Errno::ECONNREFUSED
|
13
|
-
sleep 0.5
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")
|
2
|
-
|
3
|
-
describe "Coinbase" do
|
4
|
-
|
5
|
-
def assert_valid_coinbase_attrs(account_or_details)
|
6
|
-
[:user_id, :user_name, :user_email].each do |attr|
|
7
|
-
[nil,""].should_not include(account_or_details.send(attr))
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it "is no longer supported with transaction#create" do
|
12
|
-
result = Braintree::Transaction.sale(:payment_method_nonce => Braintree::Test::Nonce::Coinbase, :amount => "0.02")
|
13
|
-
result.should_not be_success
|
14
|
-
|
15
|
-
result.errors.for(:transaction).first.code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNoLongerSupported
|
16
|
-
end
|
17
|
-
|
18
|
-
it "is no longer supported for vaulting" do
|
19
|
-
customer = Braintree::Customer.create!
|
20
|
-
result = Braintree::PaymentMethod.create(:customer_id => customer.id, :payment_method_nonce => Braintree::Test::Nonce::Coinbase)
|
21
|
-
result.should_not be_success
|
22
|
-
|
23
|
-
result.errors.for(:coinbase_account).first.code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNoLongerSupported
|
24
|
-
end
|
25
|
-
|
26
|
-
it "is no longer supported when creating a Customer with a Coinbase payment method nonce" do
|
27
|
-
expect do
|
28
|
-
Braintree::Customer.create!(:payment_method_nonce => Braintree::Test::Nonce::Coinbase)
|
29
|
-
end.to raise_error { |error|
|
30
|
-
error.should be_a(Braintree::ValidationsFailed)
|
31
|
-
error.error_result.errors.for(:coinbase_account).first.code.should == Braintree::ErrorCodes::PaymentMethod::PaymentMethodNoLongerSupported
|
32
|
-
}
|
33
|
-
end
|
34
|
-
end
|
@@ -1,97 +0,0 @@
|
|
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::MasterpassCard do
|
5
|
-
it "can create from a payment method nonce" do
|
6
|
-
customer = Braintree::Customer.create!
|
7
|
-
|
8
|
-
result = Braintree::PaymentMethod.create(
|
9
|
-
:payment_method_nonce => Braintree::Test::Nonce::MasterpassDiscover,
|
10
|
-
:customer_id => customer.id
|
11
|
-
)
|
12
|
-
result.should be_success
|
13
|
-
|
14
|
-
masterpass_card = result.payment_method
|
15
|
-
masterpass_card.should be_a(Braintree::MasterpassCard)
|
16
|
-
masterpass_card.billing_address.should_not be_nil
|
17
|
-
masterpass_card.bin.should_not be_nil
|
18
|
-
masterpass_card.card_type.should_not be_nil
|
19
|
-
masterpass_card.cardholder_name.should_not be_nil
|
20
|
-
masterpass_card.commercial.should_not be_nil
|
21
|
-
masterpass_card.country_of_issuance.should_not be_nil
|
22
|
-
masterpass_card.created_at.should_not be_nil
|
23
|
-
masterpass_card.customer_id.should_not be_nil
|
24
|
-
masterpass_card.customer_location.should_not be_nil
|
25
|
-
masterpass_card.debit.should_not be_nil
|
26
|
-
masterpass_card.default?.should_not be_nil
|
27
|
-
masterpass_card.durbin_regulated.should_not be_nil
|
28
|
-
masterpass_card.expiration_date.should_not be_nil
|
29
|
-
masterpass_card.expiration_month.should_not be_nil
|
30
|
-
masterpass_card.expiration_year.should_not be_nil
|
31
|
-
masterpass_card.expired?.should_not be_nil
|
32
|
-
masterpass_card.healthcare.should_not be_nil
|
33
|
-
masterpass_card.image_url.should_not be_nil
|
34
|
-
masterpass_card.issuing_bank.should_not be_nil
|
35
|
-
masterpass_card.last_4.should_not be_nil
|
36
|
-
masterpass_card.payroll.should_not be_nil
|
37
|
-
masterpass_card.prepaid.should_not be_nil
|
38
|
-
masterpass_card.product_id.should_not be_nil
|
39
|
-
masterpass_card.subscriptions.should_not be_nil
|
40
|
-
masterpass_card.token.should_not be_nil
|
41
|
-
masterpass_card.unique_number_identifier.should_not be_nil
|
42
|
-
masterpass_card.updated_at.should_not be_nil
|
43
|
-
|
44
|
-
customer = Braintree::Customer.find(customer.id)
|
45
|
-
customer.masterpass_cards.size.should == 1
|
46
|
-
customer.masterpass_cards.first.should == masterpass_card
|
47
|
-
end
|
48
|
-
|
49
|
-
it "can search for transactions" do
|
50
|
-
transaction_create_result = Braintree::Transaction.sale(
|
51
|
-
:payment_method_nonce => Braintree::Test::Nonce::MasterpassDiscover,
|
52
|
-
:amount => '47.00',
|
53
|
-
)
|
54
|
-
transaction_create_result.should be_success
|
55
|
-
transaction_id = transaction_create_result.transaction.id
|
56
|
-
|
57
|
-
search_results = Braintree::Transaction.search do |search|
|
58
|
-
search.id.is transaction_id
|
59
|
-
search.payment_instrument_type.is Braintree::PaymentInstrumentType::MasterpassCard
|
60
|
-
end
|
61
|
-
search_results.first.id.should == transaction_id
|
62
|
-
end
|
63
|
-
|
64
|
-
it "can create transaction from nonce and vault" do
|
65
|
-
customer = Braintree::Customer.create!
|
66
|
-
|
67
|
-
result = Braintree::Transaction.sale(
|
68
|
-
:payment_method_nonce => Braintree::Test::Nonce::MasterpassDiscover,
|
69
|
-
:customer_id => customer.id,
|
70
|
-
:amount => '47.00',
|
71
|
-
:options => { :store_in_vault => true },
|
72
|
-
)
|
73
|
-
result.should be_success
|
74
|
-
|
75
|
-
masterpass_card_details = result.transaction.masterpass_card_details
|
76
|
-
masterpass_card_details.bin.should_not be_nil
|
77
|
-
masterpass_card_details.card_type.should_not be_nil
|
78
|
-
masterpass_card_details.cardholder_name.should_not be_nil
|
79
|
-
masterpass_card_details.commercial.should_not be_nil
|
80
|
-
masterpass_card_details.country_of_issuance.should_not be_nil
|
81
|
-
masterpass_card_details.customer_location.should_not be_nil
|
82
|
-
masterpass_card_details.debit.should_not be_nil
|
83
|
-
masterpass_card_details.durbin_regulated.should_not be_nil
|
84
|
-
masterpass_card_details.expiration_date.should_not be_nil
|
85
|
-
masterpass_card_details.expiration_month.should_not be_nil
|
86
|
-
masterpass_card_details.expiration_year.should_not be_nil
|
87
|
-
masterpass_card_details.healthcare.should_not be_nil
|
88
|
-
masterpass_card_details.image_url.should_not be_nil
|
89
|
-
masterpass_card_details.issuing_bank.should_not be_nil
|
90
|
-
masterpass_card_details.last_4.should_not be_nil
|
91
|
-
masterpass_card_details.payroll.should_not be_nil
|
92
|
-
masterpass_card_details.prepaid.should_not be_nil
|
93
|
-
masterpass_card_details.product_id.should_not be_nil
|
94
|
-
masterpass_card_details.token.should_not be_nil
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|