Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merchant Passed Email addition to Native Checkout #1118

Merged
merged 12 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Braintree.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Pod::Spec.new do |s|
s.source_files = "Sources/BraintreePayPalNativeCheckout/*.swift"
s.dependency "Braintree/Core"
s.dependency "Braintree/PayPal"
s.dependency "PayPalCheckout", '1.1.0'
s.dependency "PayPalCheckout", '1.2.0'
end

s.subspec "ThreeDSecure" do |s|
Expand Down
2 changes: 1 addition & 1 deletion Braintree.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -6134,7 +6134,7 @@
repositoryURL = "https://github.com/paypal/paypalcheckout-ios/";
requirement = {
kind = exactVersion;
version = 1.1.0;
version = 1.2.0;
};
};
/* End XCRemoteSwiftPackageReference section */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/paypal/paypalcheckout-ios/",
"state" : {
"revision" : "7c6750e1316c6a3d656e90497271de68c63219f1",
"version" : "1.1.0"
"revision" : "f477176da4c6780c8586b493c604f0ab74d9be49",
"version" : "1.2.0"
}
}
],
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
* Fix bug where defaults for `BTThreeDSecureRequest.accountType`, `BTThreeDSecureRequest.requestedExemptionType`, and `BTThreeDSecureRequest.dfReferenceID` were improperly returning an error if not passed into the request
* BraintreeCard
* Deprecate unused `BTCardRequest` class
* BraintreePayPalNativeCheckout
* Update PayPalCheckout from 1.1.0 to 1.2.0.
* Add `userAuthenticationEmail` to `BTPayPalNativeCheckoutRequest`

## 5.24.0 (2023-10-30)
* BraintreePayPalDataCollector
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
binary "https://assets.braintreegateway.com/mobile/ios/carthage-frameworks/cardinal-mobile/CardinalMobile.json" == 2.2.5-6
binary "https://assets.braintreegateway.com/mobile/ios/carthage-frameworks/pp-risk-magnes/PPRiskMagnes.json" == 5.4.1
binary "https://github.com/paypal/paypalcheckout-ios/raw/main/Carthage/PayPalCheckout.json" == 1.1.0
binary "https://github.com/paypal/paypalcheckout-ios/raw/main/Carthage/PayPalCheckout.json" == 1.2.0
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ let package = Package(
),
.binaryTarget(
name: "PayPalCheckout",
url: "https://github.com/paypal/paypalcheckout-ios/releases/download/1.1.0/PayPalCheckout.xcframework.zip",
checksum: "e9e8d7ed4c48de1323bed5be81ddbc4fc82107506a6d23edc55689214f75f7ea"
url: "https://github.com/paypal/paypalcheckout-ios/releases/download/1.2.0/PayPalCheckout.xcframework.zip",
checksum: "de177ea050cfd342aa1bbfe0d9ed7faf8262270a0291a5862b6ee3c7f85cc1ff"
),
.target(
name: "BraintreeSEPADirectDebit",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import PayPalCheckout
_ request: BTPayPalNativeCheckoutRequest,
completion: @escaping (BTPayPalNativeCheckoutAccountNonce?, Error?) -> Void
) {
tokenize(request: request, completion: completion)
tokenize(request: request, userAuthenticationEmail: request.userAuthenticationEmail, completion: completion)
}

/// Tokenize a PayPal request to be used with the PayPal Native Checkout flow.
Expand Down Expand Up @@ -107,6 +107,7 @@ import PayPalCheckout

private func tokenize(
request: BTPayPalRequest,
userAuthenticationEmail: String? = nil,
completion: @escaping (BTPayPalNativeCheckoutAccountNonce?, Error?) -> Void
) {
clientMetadataID = request.riskCorrelationID ?? State.correlationIDs.riskCorrelationID
Expand Down Expand Up @@ -156,7 +157,7 @@ import PayPalCheckout
},
environment: order.environment
)

payPalNativeConfig.authConfig.userEmail = userAuthenticationEmail
mariolopez-pypl marked this conversation as resolved.
Show resolved Hide resolved
PayPalCheckout.Checkout.showsExitAlert = false
PayPalCheckout.Checkout.set(config: payPalNativeConfig)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ import BraintreePayPal

/// Options for the PayPal Checkout flow.
@objcMembers public class BTPayPalNativeCheckoutRequest: BTPayPalCheckoutRequest {

// MARK: - Public Properties

/// 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

Expand All @@ -24,13 +29,15 @@ import BraintreePayPal
/// - requestBillingAgreement: Optional: If set to `true`, this enables the Checkout with Vault flow, where the customer will be prompted to consent to a billing agreement during checkout.
/// - billingAgreementDescription: Optional: Display a custom description to the user for a billing agreement. For Checkout with Vault flows, you must also
/// set `requestBillingAgreement` to `true` on your `BTPayPalNativeVaultRequest`.
/// - userAuthenticationEmail: Optional: User email to initiate a quicker authentication flow in cases where the user has a PayPal Account with the same email.
public init(
amount: String,
intent: BTPayPalRequestIntent = .authorize,
offerPayLater: Bool = false,
currencyCode: String? = nil,
requestBillingAgreement: Bool = false,
billingAgreementDescription: String? = nil
billingAgreementDescription: String? = nil,
userAuthenticationEmail: String? = nil
) {
super.init(
amount: amount,
Expand All @@ -46,5 +53,6 @@ import BraintreePayPal
self.currencyCode = currencyCode
self.requestBillingAgreement = requestBillingAgreement
self.billingAgreementDescription = billingAgreementDescription
self.userAuthenticationEmail = userAuthenticationEmail
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ class BTPayPalNativeCheckoutRequest_Tests: XCTestCase {
XCTAssertEqual(checkoutRequest.hermesPath, "v1/paypal_hermes/create_payment_resource")
}

func testUserAuthenticationEmailReturnsNil() {
let request = BTPayPalNativeCheckoutRequest(amount: "10.00")
XCTAssertNil(request.userAuthenticationEmail)
}

func testUserAuthenticationEmailReturnsEmail() {
let request = BTPayPalNativeCheckoutRequest(amount: "10.00", userAuthenticationEmail: "[email protected]")
XCTAssertEqual(request.userAuthenticationEmail, "[email protected]")
}

func testIntentStringReturnsCorrectValue() {
let checkoutRequest = BTPayPalNativeCheckoutRequest(amount: "10.00")
checkoutRequest.intent = .authorize
Expand Down