Skip to content

Commit

Permalink
[PayPal] Support disabling vaulted PayPal accounts with PayPal enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dmazzoni committed Apr 17, 2024
1 parent 6a275e3 commit 445609c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/BraintreeDropIn/BTPaymentMethodNonce+DropIn.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ - (NSString *)paymentDescription {
- (BOOL)shouldDisplayVaultedNonceForRequest:(BTDropInRequest *)request config:(BTConfiguration *)configuration {
if ([self isKindOfClass:BTCardNonce.class] && (request.cardDisabled || configuration.supportedCardTypes.count == 0)) {
return NO;
} else if ([self isKindOfClass:BTPayPalAccountNonce.class] && (request.paypalDisabled || !configuration.isPayPalEnabled)) {
} else if ([self isKindOfClass:BTPayPalAccountNonce.class] && (request.paypalDisabled || request.vaultedPaypalAccountsDisabled || !configuration.isPayPalEnabled)) {
return NO;
} else if ([self isKindOfClass:BTVenmoAccountNonce.class] && (request.venmoDisabled || !configuration.isVenmoEnabled)) {
return NO;
Expand Down
1 change: 1 addition & 0 deletions Sources/BraintreeDropIn/Models/BTDropInRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ - (id)copyWithZone:(__unused NSZone *)zone {
request.vaultManager = self.vaultManager;
request.vaultCard = self.vaultCard;
request.allowVaultCardOverride = self.allowVaultCardOverride;
request.vaultedPaypalAccountsDisabled = self.vaultedPaypalAccountsDisabled;
return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ typedef NS_ENUM(NSInteger, BTFormFieldSetting) {
/// Defaults to false. Set to true to hide all card logos for your account.
@property (nonatomic, assign) BOOL cardLogosDisabled;

/// Defaults to false. Set to true to hide vaulted PayPal accounts even if enabled for your account.
@property (nonatomic, assign) BOOL vaultedPaypalAccountsDisabled;

/// Optional: Enable 3DS verification and specify options and additional information.
///
/// Note: To encourage 3DS 2.0 flows, set `billingAddress`, `amount`, `email`, `mobilePhone` for best results.
Expand Down
2 changes: 2 additions & 0 deletions UnitTests/BTDropInRequestTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ - (void)test_copyProperties {
originalRequest.vaultManager = YES;
originalRequest.vaultCard = NO;
originalRequest.allowVaultCardOverride = YES;
originalRequest.vaultedPaypalAccountsDisabled = YES;

BTDropInRequest *copiedRequest = [originalRequest copy];

Expand All @@ -67,6 +68,7 @@ - (void)test_copyProperties {
XCTAssertEqual(originalRequest.vaultManager, copiedRequest.vaultManager);
XCTAssertEqual(originalRequest.vaultCard, copiedRequest.vaultCard);
XCTAssertEqual(originalRequest.allowVaultCardOverride, copiedRequest.allowVaultCardOverride);
XCTAssertEqual(originalRequest.vaultedPaypalAccountsDisabled, copiedRequest.vaultedPaypalAccountsDisabled);

XCTAssertEqual(originalRequest.threeDSecureRequest, copiedRequest.threeDSecureRequest);
XCTAssertEqual(BTThreeDSecureVersion2, copiedRequest.threeDSecureRequest.versionRequested);
Expand Down

0 comments on commit 445609c

Please sign in to comment.