Skip to content

Commit 37782b4

Browse files
authored
Merge branch 'main' into shipping-callback-feature
2 parents 2a417a0 + aa9f71a commit 37782b4

File tree

6 files changed

+47
-7
lines changed

6 files changed

+47
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
## unreleased
44
* BraintreePayPal
5+
* Fix bug to ensure that `BTPayPalVaultRequest.userAuthenticationEmail` is not sent as an empty string
56
* Add `shippingCallbackURL` to `BTPayPalCheckoutRequest`
7+
* BraintreeThreeDSecure
8+
* Return error if no `dfReferenceId` is returned in the 3D Secure flow
69

710
## 6.25.0 (2024-12-11)
811
* BraintreePayPal

Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo.xcscheme

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@
262262
ReferencedContainer = "container:../Braintree.xcodeproj">
263263
</BuildableReference>
264264
</TestableReference>
265+
<TestableReference
266+
skipped = "NO">
267+
<BuildableReference
268+
BuildableIdentifier = "primary"
269+
BlueprintIdentifier = "8046983D2B27C5530090878E"
270+
BuildableName = "BraintreeShopperInsightsTests.xctest"
271+
BlueprintName = "BraintreeShopperInsightsTests"
272+
ReferencedContainer = "container:../Braintree.xcodeproj">
273+
</BuildableReference>
274+
</TestableReference>
265275
</Testables>
266276
</TestAction>
267277
<LaunchAction

Sources/BraintreePayPal/BTPayPalVaultRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import BraintreeCore
6868
) -> [String: Any] {
6969
var baseParameters = super.parameters(with: configuration)
7070

71-
if let userAuthenticationEmail {
71+
if let userAuthenticationEmail, !userAuthenticationEmail.isEmpty {
7272
baseParameters["payer_email"] = userAuthenticationEmail
7373
}
7474

Sources/BraintreeThreeDSecure/BTThreeDSecureClient.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,16 @@ import BraintreeCore
250250
request: request,
251251
cardinalSession: cardinalSession
252252
) { lookupParameters in
253-
if let dfReferenceID = lookupParameters?["dfReferenceId"] {
254-
request.dfReferenceID = dfReferenceID
253+
guard let dfReferenceID = lookupParameters?["dfReferenceId"], !dfReferenceID.isEmpty else {
254+
completion(
255+
BTThreeDSecureError.failedLookup(
256+
[NSLocalizedDescriptionKey: "There was an error retrieving the dfReferenceId."]
257+
)
258+
)
259+
return
255260
}
261+
262+
request.dfReferenceID = dfReferenceID
256263
completion(nil)
257264
}
258265
} else {

UnitTests/BraintreeThreeDSecureTests/BTThreeDSecureClient_Tests.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ class BTThreeDSecureClient_Tests: XCTestCase {
1010
var threeDSecureRequest = BTThreeDSecureRequest()
1111
var client: BTThreeDSecureClient!
1212
var mockThreeDSecureRequestDelegate : MockThreeDSecureRequestDelegate!
13-
13+
14+
let mockCardinalSession = MockCardinalSession()
15+
1416
let mockConfiguration = BTJSON(value: [
1517
"threeDSecure": ["cardinalAuthenticationJWT": "FAKE_JWT"],
1618
"assetsUrl": "http://assets.example.com"
@@ -21,7 +23,7 @@ class BTThreeDSecureClient_Tests: XCTestCase {
2123
threeDSecureRequest.amount = 10.0
2224
threeDSecureRequest.nonce = "fake-card-nonce"
2325
client = BTThreeDSecureClient(apiClient: mockAPIClient)
24-
client.cardinalSession = MockCardinalSession()
26+
client.cardinalSession = mockCardinalSession
2527
mockThreeDSecureRequestDelegate = MockThreeDSecureRequestDelegate()
2628
}
2729

@@ -689,4 +691,20 @@ class BTThreeDSecureClient_Tests: XCTestCase {
689691

690692
waitForExpectations(timeout: 1)
691693
}
694+
695+
func testPrepareLookup_whenDfReferenceIDEmpty_throwsError() {
696+
mockAPIClient.cannedConfigurationResponseBody = mockConfiguration
697+
mockCardinalSession.dfReferenceID = ""
698+
699+
let expectation = expectation(description: "willCallCompletion")
700+
701+
threeDSecureRequest.nonce = "fake-card-nonce"
702+
703+
client.prepareLookup(threeDSecureRequest) { _, error in
704+
XCTAssertEqual(error?.localizedDescription, "There was an error retrieving the dfReferenceId.")
705+
expectation.fulfill()
706+
}
707+
708+
waitForExpectations(timeout: 1)
709+
}
692710
}

UnitTests/BraintreeThreeDSecureTests/MockCardinalSession.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import CardinalMobile
33
@testable import BraintreeThreeDSecure
44

55
class MockCardinalSession: CardinalSessionTestable {
6-
6+
7+
var dfReferenceID = "fake-df-reference-id"
8+
79
func configure(_ sessionConfig: CardinalSessionConfiguration) {
810
// do nothing
911
}
@@ -13,7 +15,7 @@ class MockCardinalSession: CardinalSessionTestable {
1315
completed didCompleteHandler: @escaping CardinalSessionSetupDidCompleteHandler,
1416
validated didValidateHandler: @escaping CardinalSessionSetupDidValidateHandler
1517
) {
16-
didCompleteHandler("fake-df-reference-id")
18+
didCompleteHandler(dfReferenceID)
1719
}
1820

1921
func continueWith(transactionId: String, payload: String, validationDelegate: CardinalValidationDelegate) {

0 commit comments

Comments
 (0)