Skip to content

Commit

Permalink
Fixups - PR feedback & use payer_email over recepient_email in POST body
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo committed Apr 19, 2024
1 parent d8d2d87 commit 1f2af56
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController {

lazy var emailLabel: UILabel = {
let label = UILabel()
label.text = "User email:"
label.text = "Buyer email:"
return label
}()

Expand All @@ -22,7 +22,7 @@ class PayPalWebCheckoutViewController: PaymentButtonBaseViewController {
lazy var payLaterToggleLabel: UILabel = {
let label = UILabel()
label.text = "Offer Pay Later"
label.font = UIFont.preferredFont(forTextStyle: .footnote)
label.font = .preferredFont(forTextStyle: .footnote)
return label
}()

Expand Down
5 changes: 4 additions & 1 deletion Sources/BraintreePayPal/BTPayPalCheckoutRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ import BraintreeCore
if currencyCode != nil {
checkoutParameters["currency_iso_code"] = currencyCode
}

if let userAuthenticationEmail {
checkoutParameters["payer_email"] = userAuthenticationEmail
}

if userAction != .none, var experienceProfile = baseParameters["experience_profile"] as? [String: Any] {
experienceProfile["user_action"] = userAction.stringValue
Expand All @@ -155,7 +159,6 @@ import BraintreeCore
checkoutParameters["postal_code"] = shippingAddressOverride?.postalCode
checkoutParameters["country_code"] = shippingAddressOverride?.countryCodeAlpha2
checkoutParameters["recipient_name"] = shippingAddressOverride?.recipientName
checkoutParameters["recipient_email"] = userAuthenticationEmail
}

return baseParameters.merging(checkoutParameters) { $1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class BTPayPalCheckoutRequest_Tests: XCTestCase {
XCTAssertEqual(parameters["postal_code"] as? String, "11111")
XCTAssertEqual(parameters["country_code"] as? String, "US")
XCTAssertEqual(parameters["recipient_name"] as? String, "Recipient")
XCTAssertEqual(parameters["recipient_email"] as? String, "fake@email.com")
XCTAssertEqual(parameters["payer_email"] as? String, "fake@email.com")
XCTAssertEqual(parameters["request_billing_agreement"] as? Bool, true)

guard let billingAgreementDetails = parameters["billing_agreement_details"] as? [String : String] else {
Expand Down

0 comments on commit 1f2af56

Please sign in to comment.