Skip to content

Commit

Permalink
4.13.0
Browse files Browse the repository at this point in the history
Co-authored-by: Sara Vasquez <saravasquez@paypal.com>
Co-authored-by: Debra Do <debdo@paypal.com>
  • Loading branch information
3 people committed Aug 29, 2023
1 parent 3430ebc commit 9504bf3
Show file tree
Hide file tree
Showing 14 changed files with 510 additions and 590 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 4.13.0
* Add `retry_ids` array to `Transaction`
* Add `retried_transaction_id` string to `Transaction`
* Add `merchant_token_identifier` and `source_card_last4` to ApplePayCard and ApplePayDetails response objects
* Add `processing_overrides` to `Transaction.sale` options
* Add `arrival_date` and `ticket_issuer_address` to `industry` object in `Transaction` and add `industry` to `Transaction.submit_for_settlement`

## 4.12.0
* Add `merchant_advice_code` and `merchant_advice_code_text` to Transaction object

Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/apple_pay_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ module CardType
attr_reader :image_url
attr_reader :issuing_bank
attr_reader :last_4
attr_reader :merchant_token_identifier
attr_reader :payment_instrument_name
attr_reader :payroll
attr_reader :prepaid
attr_reader :product_id
attr_reader :source_card_last4
attr_reader :source_description
attr_reader :subscriptions
attr_reader :token
Expand Down
1 change: 1 addition & 0 deletions lib/braintree/test/nonce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Nonce
ApplePayVisa = "fake-apple-pay-visa-nonce"
ApplePayMasterCard = "fake-apple-pay-mastercard-nonce"
ApplePayAmEx = "fake-apple-pay-amex-nonce"
ApplePayMpan = "fake-apple-pay-mpan-nonce"
AbstractTransactable = "fake-abstract-transactable-nonce"
Europe = "fake-europe-bank-account-nonce"
GooglePayDiscover = "fake-android-pay-discover-nonce"
Expand Down
2 changes: 2 additions & 0 deletions lib/braintree/transaction.rb
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ module Status
attr_reader :refunded_transaction_id
attr_reader :refunded_installments
attr_reader :retried
attr_reader :retried_transaction_id # the primary/parent transaction id of any retried transaction
attr_reader :retrieval_reference_number
attr_reader :retry_ids # all retried transactions ids for a primary transaction
attr_reader :risk_data
attr_reader :samsung_pay_card_details
attr_reader :sca_exemption_requested
Expand Down
22 changes: 12 additions & 10 deletions lib/braintree/transaction/apple_pay_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ class ApplePayDetails
attr_reader :bin
attr_reader :card_type
attr_reader :cardholder_name
attr_reader :commercial
attr_reader :country_of_issuance
attr_reader :debit
attr_reader :durbin_regulated
attr_reader :expiration_month
attr_reader :expiration_year
attr_reader :global_id
attr_reader :healthcare
attr_reader :image_url
attr_reader :issuing_bank
attr_reader :last_4
attr_reader :merchant_token_identifier
attr_reader :payment_instrument_name
attr_reader :source_description
attr_reader :token
attr_reader :prepaid
attr_reader :healthcare
attr_reader :debit
attr_reader :durbin_regulated
attr_reader :commercial
attr_reader :payroll
attr_reader :issuing_bank
attr_reader :country_of_issuance
attr_reader :prepaid
attr_reader :product_id
attr_reader :global_id
attr_reader :source_card_last4
attr_reader :source_description
attr_reader :token

def initialize(attributes)
set_instance_variables_from_hash attributes unless attributes.nil?
Expand Down
18 changes: 17 additions & 1 deletion lib/braintree/transaction_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ def self._create_signature # :nodoc:
:skip_avs,
:skip_cvv,
{:paypal => [:custom_field, :payee_id, :payee_email, :description, {:supplementary_data => :_any_key_}]},
{:processing_overrides => [:customer_email, :customer_first_name, :customer_last_name, :customer_tax_identifier]},
{:three_d_secure => [:required]},
{:amex_rewards => [:request_id, :points, :currency_amount, :currency_iso_code]},
{:venmo => [:profile_id]},
Expand All @@ -247,7 +248,7 @@ def self._create_signature # :nodoc:
{:data => [
:folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax,
:passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number,
:issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone,
:issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date,
{:legs => [
:conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time,
:arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions,
Expand All @@ -267,6 +268,21 @@ def self._submit_for_settlement_signature # :nodoc:
[
:order_id,
{:descriptor => [:name, :phone, :url]},
{:industry => [
:industry_type,
{:data => [
:folio_number, :check_in_date, :check_out_date, :travel_package, :lodging_check_in_date, :lodging_check_out_date, :departure_date, :lodging_name, :room_rate, :room_tax,
:passenger_first_name, :passenger_last_name, :passenger_middle_initial, :passenger_title, :issued_date, :travel_agency_name, :travel_agency_code, :ticket_number,
:issuing_carrier_code, :customer_code, :fare_amount, :fee_amount, :tax_amount, :restricted_ticket, :no_show, :advanced_deposit, :fire_safe, :property_phone, :ticket_issuer_address, :arrival_date,
{:legs => [
:conjunction_ticket, :exchange_ticket, :coupon_number, :service_class, :carrier_code, :fare_basis_code, :flight_number, :departure_date, :departure_airport_code, :departure_time,
:arrival_airport_code, :arrival_time, :stopover_permitted, :fare_amount, :fee_amount, :tax_amount, :endorsement_or_restrictions,
]},
{:additional_charges => [
:kind, :amount,
]},
]},
]},
:purchase_order_number,
:tax_amount,
:tax_exempt,
Expand Down
2 changes: 1 addition & 1 deletion lib/braintree/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Braintree
module Version
Major = 4
Minor = 12
Minor = 13
Tiny = 0

String = "#{Major}.#{Minor}.#{Tiny}"
Expand Down
61 changes: 61 additions & 0 deletions spec/integration/braintree/payment_method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,42 @@ def make_token
apple_pay_card.product_id.should_not be_nil
end

it "creates a payment method from a fake apple pay mpan nonce" do
customer = Braintree::Customer.create.customer
token = SecureRandom.hex(16)
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::ApplePayMpan,
:customer_id => customer.id,
:token => token,
)

result.should be_success
apple_pay_card = result.payment_method
apple_pay_card.should be_a(Braintree::ApplePayCard)
apple_pay_card.should_not be_nil
apple_pay_card.bin.should_not be_nil
apple_pay_card.token.should == token
apple_pay_card.card_type.should == Braintree::ApplePayCard::CardType::Visa
apple_pay_card.payment_instrument_name.should == "Visa 8886"
apple_pay_card.source_description.should == "Visa 8886"
apple_pay_card.default.should == true
apple_pay_card.image_url.should =~ /apple_pay/
apple_pay_card.expiration_month.to_i.should > 0
apple_pay_card.expiration_year.to_i.should > 0
apple_pay_card.customer_id.should == customer.id
apple_pay_card.commercial.should_not be_nil
apple_pay_card.country_of_issuance.should_not be_nil
apple_pay_card.debit.should_not be_nil
apple_pay_card.durbin_regulated.should_not be_nil
apple_pay_card.healthcare.should_not be_nil
apple_pay_card.issuing_bank.should_not be_nil
apple_pay_card.payroll.should_not be_nil
apple_pay_card.prepaid.should_not be_nil
apple_pay_card.product_id.should_not be_nil
apple_pay_card.merchant_token_identifier.should_not be_nil
apple_pay_card.source_card_last4.should_not be_nil
end

it "creates a payment method from a fake google pay proxy card nonce" do
customer = Braintree::Customer.create.customer
token = SecureRandom.hex(16)
Expand Down Expand Up @@ -1143,6 +1179,31 @@ def make_token
apple_pay_card.source_description.should == "AmEx 41002"
apple_pay_card.customer_id.should == customer.id
end

it "finds the payment method with the given mpan token" do
customer = Braintree::Customer.create!
payment_method_token = make_token
result = Braintree::PaymentMethod.create(
:payment_method_nonce => Braintree::Test::Nonce::ApplePayMpan,
:customer_id => customer.id,
:token => payment_method_token,
)
result.should be_success

apple_pay_card = Braintree::PaymentMethod.find(payment_method_token)
apple_pay_card.should be_a(Braintree::ApplePayCard)
apple_pay_card.should_not be_nil
apple_pay_card.token.should == payment_method_token
apple_pay_card.card_type.should == Braintree::ApplePayCard::CardType::Visa
apple_pay_card.default.should == true
apple_pay_card.image_url.should =~ /apple_pay/
apple_pay_card.expiration_month.to_i.should > 0
apple_pay_card.expiration_year.to_i.should > 0
apple_pay_card.source_description.should == "Visa 8886"
apple_pay_card.customer_id.should == customer.id
apple_pay_card.merchant_token_identifier == "DNITHE302308980427388297"
apple_pay_card.source_card_last4 == "2006"
end
end

context "venmo accounts" do
Expand Down
163 changes: 0 additions & 163 deletions spec/integration/braintree/payment_method_us_bank_account_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,89 +10,6 @@
Braintree::Configuration.private_key = "integration2_private_key"
end

context "plaid verified nonce" do
let(:nonce) { generate_valid_plaid_us_bank_account_nonce }

# we are temporarily skipping this test until we have a more stable CI env
xit "succeeds" do
customer = Braintree::Customer.create.customer
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
},
)

result.should be_success
us_bank_account = result.payment_method
us_bank_account.should be_a(Braintree::UsBankAccount)
us_bank_account.routing_number.should == "011000015"
us_bank_account.last_4.should == "0000"
us_bank_account.account_type.should == "checking"
us_bank_account.account_holder_name.should == "PayPal, Inc."
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
us_bank_account.default.should == true
us_bank_account.ach_mandate.text.should == "cl mandate text"
us_bank_account.ach_mandate.accepted_at.should be_a Time

us_bank_account.verifications.count.should == 1
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
us_bank_account.verifications.first.id.should_not be_empty
us_bank_account.verifications.first.verification_determined_at.should be_a Time
us_bank_account.verified.should == true

Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
end

[
Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck,
Braintree::UsBankAccountVerification::VerificationMethod::NetworkCheck,
].each do |method|
# we are temporarily skipping this test until we have a more stable CI env
xit "succeeds and verifies via #{method}" do
customer = Braintree::Customer.create.customer
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:us_bank_account_verification_method => method,
:verification_merchant_account_id => SpecHelper::AnotherUsBankMerchantAccountId,
},
)

result.should be_success
us_bank_account = result.payment_method
us_bank_account.should be_a(Braintree::UsBankAccount)
us_bank_account.routing_number.should == "011000015"
us_bank_account.last_4.should == "0000"
us_bank_account.account_type.should == "checking"
us_bank_account.account_holder_name.should == "PayPal, Inc."
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
us_bank_account.default.should == true
us_bank_account.ach_mandate.text.should == "cl mandate text"
us_bank_account.ach_mandate.accepted_at.should be_a Time
us_bank_account.verified.should == true

us_bank_account.verifications.count.should == 2

us_bank_account.verifications.map(&:verification_method).should contain_exactly(
Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck,
method,
)

us_bank_account.verifications.each do |verification|
verification.status.should == Braintree::UsBankAccountVerification::Status::Verified
verification.id.should_not be_empty
verification.verification_determined_at.should be_a Time
end

Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
end
end
end

context "non plaid verified nonce" do
let(:nonce) { generate_non_plaid_us_bank_account_nonce }

Expand Down Expand Up @@ -176,86 +93,6 @@
end

context "exempt merchant" do
context "plaid verified nonce" do
before do
Braintree::Configuration.merchant_id = "integration_merchant_id"
Braintree::Configuration.public_key = "integration_public_key"
Braintree::Configuration.private_key = "integration_private_key"
end

let(:nonce) { generate_valid_plaid_us_bank_account_nonce }

# we are temporarily skipping this test until we have a more stable CI env
xit "succeeds and verifies via independent check" do
customer = Braintree::Customer.create.customer
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
},
)

result.should be_success
us_bank_account = result.payment_method
us_bank_account.should be_a(Braintree::UsBankAccount)
us_bank_account.routing_number.should == "011000015"
us_bank_account.last_4.should == "0000"
us_bank_account.account_type.should == "checking"
us_bank_account.account_holder_name.should == "PayPal, Inc."
us_bank_account.bank_name.should == "FEDERAL RESERVE BANK"
us_bank_account.default.should == true
us_bank_account.ach_mandate.text.should == "cl mandate text"
us_bank_account.ach_mandate.accepted_at.should be_a Time

us_bank_account.verifications.count.should == 1
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::TokenizedCheck
us_bank_account.verifications.first.id.should_not be_empty
us_bank_account.verifications.first.verification_determined_at.should be_a Time
us_bank_account.verified.should == true

Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
end
end

context "non plaid verified nonce" do
let(:nonce) { generate_non_plaid_us_bank_account_nonce }

# we are temporarily skipping this test until we have a more stable CI env
xit "succeeds and verifies via independent check" do
customer = Braintree::Customer.create.customer
result = Braintree::PaymentMethod.create(
:payment_method_nonce => nonce,
:customer_id => customer.id,
:options => {
:verification_merchant_account_id => SpecHelper::UsBankMerchantAccountId,
},
)

result.should be_success
us_bank_account = result.payment_method
us_bank_account.should be_a(Braintree::UsBankAccount)
us_bank_account.routing_number.should == "021000021"
us_bank_account.last_4.should == "0000"
us_bank_account.account_type.should == "checking"
us_bank_account.account_holder_name.should == "John Doe"
us_bank_account.bank_name.should =~ /CHASE/
us_bank_account.default.should == true
us_bank_account.ach_mandate.text.should == "cl mandate text"
us_bank_account.ach_mandate.accepted_at.should be_a Time

us_bank_account.verifications.count.should == 1
us_bank_account.verifications.first.status.should == Braintree::UsBankAccountVerification::Status::Verified
us_bank_account.verifications.first.verification_method.should == Braintree::UsBankAccountVerification::VerificationMethod::IndependentCheck
us_bank_account.verifications.first.id.should_not be_empty
us_bank_account.verifications.first.verification_determined_at.should be_a Time
us_bank_account.verified.should == true

Braintree::PaymentMethod.find(us_bank_account.token).should be_a(Braintree::UsBankAccount)
end
end

it "fails with invalid nonce" do
customer = Braintree::Customer.create.customer
result = Braintree::PaymentMethod.create(
Expand Down
Loading

0 comments on commit 9504bf3

Please sign in to comment.