Skip to content

Commit

Permalink
UI customization for 3DS SDK (#165)
Browse files Browse the repository at this point in the history
* UI customization for 3DS SDK

* 3DS SDK version bump

* Addresses PR comments

* Temporary disable tests that fail (DeviceDNA related)

* CI/CD fixes
  • Loading branch information
stefan-tudor authored Nov 2, 2022
1 parent 27c2dd3 commit e987254
Show file tree
Hide file tree
Showing 21 changed files with 724 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "datatheorem/TrustKit" == 1.7.0
binary "https://raw.githubusercontent.com/Judopay/DeviceDNA-iOS/master/DeviceDNA.json" == 2.0.0
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" == 1.1.2
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" == 1.1.3
github "krzyzanowskim/OpenSSL" ~> 1.1.180
github "Judopay/pbba-merchant-button-library-ios" == 3.1.3
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
binary "https://raw.githubusercontent.com/Judopay/DeviceDNA-iOS/master/DeviceDNA.json" "2.0.0"
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" "1.1.2"
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" "1.1.3"
github "AliSoftware/OHHTTPStubs" "9.1.0"
github "Judopay/pbba-merchant-button-library-ios" "3.1.3"
github "datatheorem/TrustKit" "1.7.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,14 +1084,14 @@
CODE_SIGN_ENTITLEMENTS = ObjectiveCExampleApp/ObjectiveCExampleApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 95V535S6TQ;
INFOPLIST_FILE = ObjectiveCExampleApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.6;
MARKETING_VERSION = 3.1.7;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.judo.JudoPayDemoObjC;
PRODUCT_NAME = "Judopay demo";
Expand All @@ -1109,14 +1109,14 @@
CODE_SIGN_ENTITLEMENTS = ObjectiveCExampleApp/ObjectiveCExampleApp.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 95V535S6TQ;
INFOPLIST_FILE = ObjectiveCExampleApp/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.6;
MARKETING_VERSION = 3.1.7;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.judo.JudoPayDemoObjC;
PRODUCT_NAME = "Judopay demo";
Expand Down
11 changes: 8 additions & 3 deletions Examples/ObjectiveCExampleApp/ObjectiveCExampleApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,14 @@ - (void)registerDefaultsFromSettingsBundle {
return;
}

NSString *stringsPath = [settingsBundle stringByAppendingPathComponent:@"Root.plist"];
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:stringsPath];
NSArray *preferences = settings[@"PreferenceSpecifiers"];
NSArray *settingFiles = @[@"Root.plist", @"ThreeDSSDKUICustomisation.plist"];
NSMutableArray *preferences = [NSMutableArray new];

for (NSString *fileName in settingFiles) {
NSString *stringsPath = [settingsBundle stringByAppendingPathComponent:fileName];
NSDictionary *settings = [NSDictionary dictionaryWithContentsOfFile:stringsPath];
[preferences addObjectsFromArray:settings[@"PreferenceSpecifiers"]];
}

NSMutableDictionary *defaultsToRegister = [[NSMutableDictionary alloc] initWithCapacity:preferences.count];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,13 @@ - (JPConfiguration *)configuration {
configuration.uiConfiguration.shouldPaymentButtonDisplayAmount = Settings.defaultSettings.shouldPaymentButtonDisplayAmount;
configuration.uiConfiguration.shouldPaymentMethodsVerifySecurityCode = Settings.defaultSettings.shouldPaymentMethodsVerifySecurityCode;
configuration.uiConfiguration.shouldAskForBillingInformation = Settings.defaultSettings.shouldAskForBillingInformation;

@try {
configuration.uiConfiguration.threeDSUICustomization = Settings.defaultSettings.threeDSUICustomization;
} @catch(NSException *exception) {
[self displaySnackBarWith:[NSString stringWithFormat:@"Setting 3DS SDK UI configuration failed with reason: %@", exception.reason]];
}

configuration.supportedCardNetworks = Settings.defaultSettings.supportedCardNetworks;
configuration.applePayConfiguration = self.applePayConfiguration;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,59 @@ static NSString *const kReadTimeoutKey = @"read_timeout";
static NSString *const kWriteTimeoutKey = @"write_timeout";
static NSString *const kThreeDSTwoMessageVersionKey = @"three_ds_two_message_version";

static NSString *const kIsThreeDSUICustomisationEnabledKey = @"three_ds_is_ui_customisation_enabled";

static NSString *const kThreeDSToolbarTextFontNameKey = @"three_ds_toolbar_text_font_name";
static NSString *const kThreeDSToolbarTextColorKey = @"three_ds_toolbar_text_color";
static NSString *const kThreeDSToolbarTextFontSizeKey = @"three_ds_toolbar_text_font_size";
static NSString *const kThreeDSToolbarBackgroundColorKey = @"three_ds_toolbar_background_color";
static NSString *const kThreeDSToolbarHeaderTextKey = @"three_ds_toolbar_header_text";
static NSString *const kThreeDSToolbarButtonTextKey = @"three_ds_toolbar_button_text";

static NSString *const kThreeDSLabelTextFontNameKey = @"three_ds_label_text_font_name";
static NSString *const kThreeDSLabelTextColorKey = @"three_ds_label_text_color";
static NSString *const kThreeDSLabelTextFontSizeKey = @"three_ds_label_text_font_size";
static NSString *const kThreeDSLabelHeadingTextFontNameKey = @"three_ds_label_heading_text_font_name";
static NSString *const kThreeDSLabelHeadingTextColorKey = @"three_ds_label_heading_text_color";
static NSString *const kThreeDSLabelHeadingTextFontSizeKey = @"three_ds_label_heading_text_font_size";

static NSString *const kThreeDSTextBoxTextFontNameKey = @"three_ds_text_box_text_font_name";
static NSString *const kThreeDSTextBoxTextColorKey = @"three_ds_text_box_text_color";
static NSString *const kThreeDSTextBoxTextFontSizeKey = @"three_ds_text_box_text_font_size";
static NSString *const kThreeDSTextBoxBorderWidthKey = @"three_ds_text_box_border_width";
static NSString *const kThreeDSTextBoxBorderColorKey = @"three_ds_text_box_border_color";
static NSString *const kThreeDSTextBoxCornerRadiusKey = @"three_ds_text_box_corner_radius";

static NSString *const kThreeDSSubmitButtonTextFontNameKey = @"three_ds_submit_button_text_font_name";
static NSString *const kThreeDSSubmitButtonTextColorKey = @"three_ds_submit_button_text_color";
static NSString *const kThreeDSSubmitButtonTextFontSizeKey = @"three_ds_submit_button_text_font_size";
static NSString *const kThreeDSSubmitButtonBackgroundColorKey = @"three_ds_submit_button_background_color";
static NSString *const kThreeDSSubmitButtonCornerRadiusKey = @"three_ds_submit_button_corner_radius";

static NSString *const kThreeDSNextButtonTextFontNameKey = @"three_ds_next_button_text_font_name";
static NSString *const kThreeDSNextButtonTextColorKey = @"three_ds_next_button_text_color";
static NSString *const kThreeDSNextButtonTextFontSizeKey = @"three_ds_next_button_text_font_size";
static NSString *const kThreeDSNextButtonBackgroundColorKey = @"three_ds_next_button_background_color";
static NSString *const kThreeDSNextButtonCornerRadiusKey = @"three_ds_next_button_corner_radius";

static NSString *const kThreeDSContinueButtonTextFontNameKey = @"three_ds_continue_button_text_font_name";
static NSString *const kThreeDSContinueButtonTextColorKey = @"three_ds_continue_button_text_color";
static NSString *const kThreeDSContinueButtonTextFontSizeKey = @"three_ds_continue_button_text_font_size";
static NSString *const kThreeDSContinueButtonBackgroundColorKey = @"three_ds_continue_button_background_color";
static NSString *const kThreeDSContinueButtonCornerRadiusKey = @"three_ds_continue_button_corner_radius";

static NSString *const kThreeDSCancelButtonTextFontNameKey = @"three_ds_cancel_button_text_font_name";
static NSString *const kThreeDSCancelButtonTextColorKey = @"three_ds_cancel_button_text_color";
static NSString *const kThreeDSCancelButtonTextFontSizeKey = @"three_ds_cancel_button_text_font_size";
static NSString *const kThreeDSCancelButtonBackgroundColorKey = @"three_ds_cancel_button_background_color";
static NSString *const kThreeDSCancelButtonCornerRadiusKey = @"three_ds_cancel_button_corner_radius";

static NSString *const kThreeDSResendButtonTextFontNameKey = @"three_ds_resend_button_text_font_name";
static NSString *const kThreeDSResendButtonTextColorKey = @"three_ds_resend_button_text_color";
static NSString *const kThreeDSResendButtonTextFontSizeKey = @"three_ds_resend_button_text_font_size";
static NSString *const kThreeDSResendButtonBackgroundColorKey = @"three_ds_resend_button_background_color";
static NSString *const kThreeDSResendButtonCornerRadiusKey = @"three_ds_resend_button_corner_radius";

#pragma mark - Reference section keys

static NSString *const kPaymentReferenceKey = @"payment_reference";
Expand Down Expand Up @@ -102,6 +155,8 @@ static NSString *const kShouldPaymentButtonDisplayAmount = @"should_payment_butt
static NSString *const kShouldPaymentMethodsVerifySecurityCode = @"should_ask_security_code";
static NSString *const kIsInitialRecurringPaymentKey = @"is_initial_recurring_payment";

@class JP3DSUICustomization;

@interface Settings : NSObject

+ (instancetype)defaultSettings;
Expand Down Expand Up @@ -175,7 +230,7 @@ static NSString *const kIsInitialRecurringPaymentKey = @"is_initial_recurring_pa
- (nonnull NSNumber *)connectTimeout;
- (nonnull NSNumber *)readTimeout;
- (nonnull NSNumber *)writeTimeout;

- (nullable JP3DSUICustomization *)threeDSUICustomization;
@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "Settings.h"
#import <Judo3DS2_iOS/Judo3DS2_iOS.h>

static NSString *const kDefaultConsumerReference = @"my-unique-consumer-ref";
static NSString *const kDontSet = @"dontSet";
Expand Down Expand Up @@ -268,14 +269,15 @@ - (BOOL)isInitialRecurringPaymentEnabled {
- (JPAddress *)address {
if (Settings.defaultSettings.isAddressOn) {
NSNumber *addressCountryCode = @([self.defaults stringForKey:kAddressCountryCodeKey].intValue);

NSString *state = [self.defaults stringForKey:kAddressStateKey];

return [[JPAddress alloc] initWithAddress1:[self.defaults stringForKey:kAddressLine1Key]
address2:[self.defaults stringForKey:kAddressLine2Key]
address3:[self.defaults stringForKey:kAddressLine3Key]
town:[self.defaults stringForKey:kAddressTownKey]
postCode:[self.defaults stringForKey:kAddressPostCodeKey]
countryCode:addressCountryCode
state:[self.defaults stringForKey:kAddressStateKey]];
state:state.length > 0 ? state : nil];
}
return nil;
}
Expand Down Expand Up @@ -356,4 +358,82 @@ - (NSNumber *)writeTimeout {
return [self timeoutForKey:kWriteTimeoutKey];
}

- (JP3DSUICustomization *)threeDSUICustomization {
if ([self.defaults boolForKey:kIsThreeDSUICustomisationEnabledKey]) {
JP3DSUICustomization *customization = [JP3DSUICustomization new];

JP3DSLabelCustomization *labelCustomization = [JP3DSLabelCustomization new];
NSString *font = [self.defaults stringForKey:kThreeDSLabelTextFontNameKey];
[labelCustomization setTextFontName:font];
[labelCustomization setTextColor:[self.defaults stringForKey:kThreeDSLabelTextColorKey]];
[labelCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSLabelTextFontSizeKey].integerValue];
[labelCustomization setHeadingTextFontName:[self.defaults stringForKey:kThreeDSLabelHeadingTextFontNameKey]];
[labelCustomization setHeadingTextColor:[self.defaults stringForKey:kThreeDSLabelHeadingTextColorKey]];
[labelCustomization setHeadingTextFontSize:[self.defaults stringForKey:kThreeDSLabelHeadingTextFontSizeKey].integerValue];
[customization setLabelCustomization:labelCustomization];

JP3DSToolbarCustomization *toolbarCustomization = [JP3DSToolbarCustomization new];
[toolbarCustomization setTextFontName:[self.defaults stringForKey:kThreeDSToolbarTextFontNameKey]];
[toolbarCustomization setTextColor:[self.defaults stringForKey:kThreeDSToolbarTextColorKey]];
[toolbarCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSToolbarTextFontSizeKey].integerValue];
[toolbarCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSToolbarBackgroundColorKey]];
[toolbarCustomization setHeaderText:[self.defaults stringForKey:kThreeDSToolbarHeaderTextKey]];
[toolbarCustomization setButtonText:[self.defaults stringForKey:kThreeDSToolbarButtonTextKey]];
[customization setToolbarCustomization:toolbarCustomization];

JP3DSTextBoxCustomization *textBoxCustomization = [JP3DSTextBoxCustomization new];
[textBoxCustomization setTextFontName:[self.defaults stringForKey:kThreeDSTextBoxTextFontNameKey]];
[textBoxCustomization setTextColor:[self.defaults stringForKey:kThreeDSTextBoxTextColorKey]];
[textBoxCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSTextBoxTextFontSizeKey].integerValue];
[textBoxCustomization setBorderWidth:[self.defaults stringForKey:kThreeDSTextBoxBorderWidthKey].integerValue];
[textBoxCustomization setBorderColor:[self.defaults stringForKey:kThreeDSTextBoxBorderColorKey]];
[textBoxCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSTextBoxCornerRadiusKey].integerValue];
[customization setTextBoxCustomization:textBoxCustomization];

JP3DSButtonCustomization *submitCustomization = [JP3DSButtonCustomization new];
[submitCustomization setTextFontName:[self.defaults stringForKey:kThreeDSSubmitButtonTextFontNameKey]];
[submitCustomization setTextColor:[self.defaults stringForKey:kThreeDSSubmitButtonTextColorKey]];
[submitCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSSubmitButtonTextFontSizeKey].integerValue];
[submitCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSSubmitButtonBackgroundColorKey]];
[submitCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSSubmitButtonCornerRadiusKey].integerValue];
[customization setButtonCustomization:submitCustomization ofType:JP3DSButtonTypeSubmit];

JP3DSButtonCustomization *nextCustomization = [JP3DSButtonCustomization new];
[nextCustomization setTextFontName:[self.defaults stringForKey:kThreeDSNextButtonTextFontNameKey]];
[nextCustomization setTextColor:[self.defaults stringForKey:kThreeDSNextButtonTextColorKey]];
[nextCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSNextButtonTextFontSizeKey].integerValue];
[nextCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSNextButtonBackgroundColorKey]];
[nextCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSNextButtonCornerRadiusKey].integerValue];
[customization setButtonCustomization:nextCustomization ofType:JP3DSButtonTypeNext];

JP3DSButtonCustomization *cancelCustomization = [JP3DSButtonCustomization new];
[cancelCustomization setTextFontName:[self.defaults stringForKey:kThreeDSCancelButtonTextFontNameKey]];
[cancelCustomization setTextColor:[self.defaults stringForKey:kThreeDSCancelButtonTextColorKey]];
[cancelCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSCancelButtonTextFontSizeKey].integerValue];
[cancelCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSCancelButtonBackgroundColorKey]];
[cancelCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSCancelButtonCornerRadiusKey].integerValue];
[customization setButtonCustomization:cancelCustomization ofType:JP3DSButtonTypeCancel];

JP3DSButtonCustomization *continueCustomization = [JP3DSButtonCustomization new];
[continueCustomization setTextFontName:[self.defaults stringForKey:kThreeDSContinueButtonTextFontNameKey]];
[continueCustomization setTextColor:[self.defaults stringForKey:kThreeDSContinueButtonTextColorKey]];
[continueCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSContinueButtonTextFontSizeKey].integerValue];
[continueCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSContinueButtonBackgroundColorKey]];
[continueCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSContinueButtonCornerRadiusKey].integerValue];
[customization setButtonCustomization:continueCustomization ofType:JP3DSButtonTypeContinue];

JP3DSButtonCustomization *resendCustomization = [JP3DSButtonCustomization new];
[resendCustomization setTextFontName:[self.defaults stringForKey:kThreeDSResendButtonTextFontNameKey]];
[resendCustomization setTextColor:[self.defaults stringForKey:kThreeDSResendButtonTextColorKey]];
[resendCustomization setTextFontSize:[self.defaults stringForKey:kThreeDSResendButtonTextFontSizeKey].integerValue];
[resendCustomization setBackgroundColor:[self.defaults stringForKey:kThreeDSResendButtonBackgroundColorKey]];
[resendCustomization setCornerRadius:[self.defaults stringForKey:kThreeDSResendButtonCornerRadiusKey].integerValue];
[customization setButtonCustomization:resendCustomization ofType:JP3DSButtonTypeResend];

return customization;
}

return nil;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@
<key>Key</key>
<string>three_ds_two_message_version</string>
</dict>
<dict>
<key>File</key>
<string>ThreeDSSDKUICustomisation</string>
<key>Title</key>
<string>UI customization</string>
<key>Type</key>
<string>PSChildPaneSpecifier</string>
</dict>
<dict>
<key>Type</key>
<string>PSGroupSpecifier</string>
Expand Down
Loading

0 comments on commit e987254

Please sign in to comment.