Skip to content

Commit

Permalink
[V6] Accept email in BTPayPalVaultRequest (#1223)
Browse files Browse the repository at this point in the history
  • Loading branch information
scannillo authored Mar 19, 2024
1 parent c05669b commit 267fc96
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Braintree iOS SDK Release Notes

## unreleased
* Add `BTPayPalVaultRequest.userAuthenticationEmail` optional property

## 6.15.0 (2024-03-18)
* [Meets Apple's new Privacy Update requirements](https://developer.apple.com/news/?id=3d8a9yyh)

Expand Down
12 changes: 10 additions & 2 deletions Sources/BraintreePayPal/BTPayPalVaultRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ import BraintreeCore

/// Optional: Offers PayPal Credit if the customer qualifies. Defaults to `false`.
public var offerCredit: Bool

/// Optional: User email to initiate a quicker authentication flow in cases where the user has a PayPal Account with the same email.
public var userAuthenticationEmail: String?

// MARK: - Initializer

/// Initializes a PayPal Native Vault request
/// - Parameter offerCredit: Optional: Offers PayPal Credit if the customer qualifies. Defaults to `false`.
public init(offerCredit: Bool = false) {
public init(offerCredit: Bool = false, userAuthenticationEmail: String? = nil) {
self.offerCredit = offerCredit
self.userAuthenticationEmail = userAuthenticationEmail

super.init(hermesPath: "v1/paypal_hermes/setup_billing_agreement", paymentType: .vault)
}
Expand All @@ -30,9 +34,13 @@ import BraintreeCore
let baseParameters = super.parameters(with: configuration)
var vaultParameters: [String: Any] = ["offer_paypal_credit": offerCredit]

if billingAgreementDescription != nil {
if let billingAgreementDescription {
vaultParameters["description"] = billingAgreementDescription
}

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

if let shippingAddressOverride {
let shippingAddressParameters: [String: String?] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ class BTPayPalVaultRequest_Tests: XCTestCase {
request.shippingAddressOverride = shippingAddress
request.isShippingAddressEditable = true
request.offerCredit = true
request.userAuthenticationEmail = "[email protected]"

let parameters = request.parameters(with: configuration)

XCTAssertEqual(parameters["description"] as? String, "desc")
XCTAssertEqual(parameters["offer_paypal_credit"] as? Bool, true)
XCTAssertEqual(parameters["payer_email"] as? String, "[email protected]")

guard let shippingParams = parameters["shipping_address"] as? [String:String] else { XCTFail(); return }

Expand Down

0 comments on commit 267fc96

Please sign in to comment.