Skip to content

Commit

Permalink
CT-2516 (#162)
Browse files Browse the repository at this point in the history
* BUG fixes: CT-2516

- Package version bump
- One or more required Challenge response fields are missing ERROR | Santander (MC Credit)
- Sample app `Token payments` screen improvements
  • Loading branch information
stefan-tudor authored Sep 28, 2022
1 parent 511b8d2 commit e9a240a
Show file tree
Hide file tree
Showing 20 changed files with 491 additions and 223 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.1
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" == 1.1.2
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.1"
binary "https://raw.githubusercontent.com/Judopay/Judo3DS2-iOS/master/Judo3DS2_iOS.json" "1.1.2"
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 @@ -1091,7 +1091,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.5;
MARKETING_VERSION = 3.1.6;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.judo.JudoPayDemoObjC;
PRODUCT_NAME = "Judopay demo";
Expand All @@ -1116,7 +1116,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 3.1.5;
MARKETING_VERSION = 3.1.6;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.judo.JudoPayDemoObjC;
PRODUCT_NAME = "Judopay demo";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,22 @@

@import JudoKit_iOS;

@interface PayWithCardTokenViewController ()
@interface PayWithCardTokenViewController () <UITextFieldDelegate>

@property (strong, nonatomic) IBOutlet UIButton *createCardTokenButton;

@property (strong, nonatomic) IBOutlet JPLoadingButton *payWithCardTokenButton;
@property (strong, nonatomic) IBOutlet JPLoadingButton *preAuthWithCardTokenButton;

@property (strong, nonatomic) UIActivityIndicatorView *activityIndicatorView;
@property (strong, nonatomic) JPCardDetails *cardDetails;
@property (strong, nonatomic) JPCardTransactionService *transactionService;

@property (weak, nonatomic) IBOutlet UITextField *cardNetworkTextField;
@property (weak, nonatomic) IBOutlet UITextField *cardTokenTextField;
@property (weak, nonatomic) IBOutlet UITextField *cardSecurityCodeTextField;
@property (weak, nonatomic) IBOutlet UITextField *cardholderNameTextField;
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *scrollviewBottomConstraint;

@end

@implementation PayWithCardTokenViewController
Expand All @@ -47,9 +52,59 @@ @implementation PayWithCardTokenViewController

- (void)viewDidLoad {
[super viewDidLoad];
self.title = @"Token and no UI payments";
self.title = @"Token payments";
[self shouldEnableButtons:NO];
[self setupButtons];
[self _jp_registerKeyboardObservers];
}

- (void)dealloc {
[self _jp_removeKeyboardObservers];
}

#pragma mark - Keyboard handling logic

- (void)_jp_keyboardWillShow:(NSNotification *)notification {
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];

CGSize keyboardSize = [[notification.userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;
self.scrollviewBottomConstraint.constant = keyboardSize.height;
[self.view layoutIfNeeded];

__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:duration
delay:0.0
options:curve
animations:^{
[weakSelf.view layoutIfNeeded];
}
completion:^(BOOL finished){}];
}

- (void)_jp_keyboardWillHide:(NSNotification *)notification {
NSTimeInterval duration = [notification.userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];
UIViewAnimationCurve curve = [notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] integerValue];

self.scrollviewBottomConstraint.constant = 0;
[self.view layoutIfNeeded];

__weak typeof(self) weakSelf = self;
[UIView animateWithDuration:duration
delay:0.0
options:curve
animations:^{
[weakSelf.view layoutIfNeeded];
}
completion:^(BOOL finished){}];
}

- (IBAction)textFieldDidChange:(id)sender {
BOOL shouldEnableButtons =
self.cardNetworkTextField.text.length > 0
&& self.cardTokenTextField.text.length > 0
&& self.cardholderNameTextField.text.length > 0;

[self shouldEnableButtons: shouldEnableButtons];
}

- (IBAction)addCardAction:(UIButton *)sender {
Expand All @@ -58,12 +113,7 @@ - (IBAction)addCardAction:(UIButton *)sender {
configuration:self.configuration
completion:^(JPResponse *response, JPError *error) {
[weakSelf handleResponse:response error:error showReceipt:false];

weakSelf.cardDetails = response.cardDetails;

if (weakSelf.cardDetails) {
[weakSelf shouldEnableButtons:YES];
}
[weakSelf fillInFieldsFromResponse:response];
}];
}

Expand All @@ -78,70 +128,57 @@ - (void)handleResponse:(JPResponse *)response error:(NSError *)error showReceipt
}
}

- (void)fillInFieldsFromResponse:(JPResponse *)response {
JPCardDetails *cardDetails = response.cardDetails;

if (cardDetails) {
self.cardNetworkTextField.text = [NSString stringWithFormat:@"%@", cardDetails.rawCardNetwork];
self.cardTokenTextField.text = cardDetails.cardToken;
[self textFieldDidChange:nil];
}
}

- (IBAction)payWithCardToken:(UIButton *)sender {
[self.payWithCardTokenButton startLoading];

__weak typeof(self) weakSelf = self;

[self presentTextFieldAlertControllerWithTitle:@"Please provide the security code"
message:@""
positiveButtonTitle:@"Ok"
negativeButtonTitle:@"Cancel"
textFieldPlaceholder:@"Security code"
andCompletion:^(NSString *text) {
if (!text || text.length == 0) {
return;
}

[weakSelf.payWithCardTokenButton startLoading];

weakSelf.configuration.reference = Settings.defaultSettings.reference;
JPCardTransactionDetails *details = [JPCardTransactionDetails detailsWithConfiguration:weakSelf.configuration
andCardDetails:weakSelf.cardDetails];
details.secureCode = text;
details.cardholderName = @"CHALLENGE";

[weakSelf.transactionService invokeTokenPaymentWithDetails:details
andCompletion:^(JPResponse *response, JPError *error) {
[weakSelf handleResponse:response error:error showReceipt:true];
[weakSelf.payWithCardTokenButton stopLoading];
}];
[self.transactionService invokeTokenPaymentWithDetails:self.cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
[weakSelf handleResponse:response error:error showReceipt:true];
[weakSelf.payWithCardTokenButton stopLoading];
}];
}

- (IBAction)preAuthWithCardToken:(UIButton *)sender {
[self.preAuthWithCardTokenButton startLoading];

__weak typeof(self) weakSelf = self;

[self presentTextFieldAlertControllerWithTitle:@"Please provide the security code"
message:@""
positiveButtonTitle:@"Ok"
negativeButtonTitle:@"Cancel"
textFieldPlaceholder:@"Security code"
andCompletion:^(NSString *text) {
if (!text || text.length == 0) {
return;
}

[weakSelf.preAuthWithCardTokenButton startLoading];

weakSelf.configuration.reference = Settings.defaultSettings.reference;
JPCardTransactionDetails *details = [JPCardTransactionDetails detailsWithConfiguration:weakSelf.configuration
andCardDetails:weakSelf.cardDetails];
details.secureCode = text;
details.cardholderName = @"CHALLENGE";

[weakSelf.transactionService invokePreAuthTokenPaymentWithDetails:details
andCompletion:^(JPResponse *response, JPError *error) {
[weakSelf handleResponse:response error:error showReceipt:true];
[weakSelf.preAuthWithCardTokenButton stopLoading];
}];
[self.transactionService invokePreAuthTokenPaymentWithDetails:self.cardTransactionDetails
andCompletion:^(JPResponse *response, JPError *error) {
[weakSelf handleResponse:response error:error showReceipt:true];
[weakSelf.preAuthWithCardTokenButton stopLoading];
}];
}

- (void)setupButtons {
[self.preAuthWithCardTokenButton setBackgroundImage:UIColor.darkGrayColor._jp_asImage forState:UIControlStateDisabled];
[self.preAuthWithCardTokenButton setBackgroundImage:UIColor.blackColor._jp_asImage forState:UIControlStateNormal];
- (JPCardTransactionDetails *)cardTransactionDetails {
self.configuration.reference = Settings.defaultSettings.reference;

JPCardTransactionDetails *details = [JPCardTransactionDetails detailsWithConfiguration:self.configuration];

NSString *secureCode = nil;

if (self.cardSecurityCodeTextField.text.length > 0) {
secureCode = self.cardSecurityCodeTextField.text;
}

details.cardToken = self.cardTokenTextField.text;
details.cardType = @(self.cardNetworkTextField.text.integerValue)._jp_toCardNetworkType;
details.secureCode = secureCode;
details.cardholderName = self.cardholderNameTextField.text;

[self.payWithCardTokenButton setBackgroundImage:UIColor.darkGrayColor._jp_asImage forState:UIControlStateDisabled];
[self.payWithCardTokenButton setBackgroundImage:UIColor.blackColor._jp_asImage forState:UIControlStateNormal];
return details;
}

- (void)shouldEnableButtons:(BOOL)shouldEnable {
Expand Down
6 changes: 3 additions & 3 deletions Examples/ObjectiveCExampleApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ use_frameworks!
inhibit_all_warnings!

target 'ObjectiveCExampleApp' do
# pod 'Judo3DS2_iOS', :path => '../../../Judo3DS2-iOS-Source'
pod 'Judo3DS2_iOS', '1.1.1'
# pod 'Judo3DS2_iOS', :path => '../../../Judo3DS2-iOS-Source'
pod 'Judo3DS2_iOS', '1.1.2'

pod 'JudoKit-iOS', :path => '../../'
# pod 'JudoKit-iOS', '3.1.5'
# pod 'JudoKit-iOS', '3.1.6'

pod 'MaterialComponents/Snackbar'
pod 'InAppSettingsKit', '3.3.6'
Expand Down
14 changes: 7 additions & 7 deletions Examples/ObjectiveCExampleApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ PODS:
- DeviceDNA (2.0.0):
- OpenSSL-Universal (~> 1.1.180)
- InAppSettingsKit (3.3.6)
- Judo3DS2_iOS (1.1.1)
- JudoKit-iOS (3.1.5):
- Judo3DS2_iOS (1.1.2)
- JudoKit-iOS (3.1.6):
- DeviceDNA (~> 2.0.0)
- Judo3DS2_iOS (~> 1.1.1)
- Judo3DS2_iOS (~> 1.1.2)
- TrustKit
- ZappMerchantLib
- MaterialComponents/AnimationTiming (124.2.0)
Expand Down Expand Up @@ -87,7 +87,7 @@ DEPENDENCIES:
- CocoaDebug (= 1.7.2)
- Cucumberish (from `https://github.com/mpetrenco/Cucumberish.git`)
- InAppSettingsKit (= 3.3.6)
- Judo3DS2_iOS (= 1.1.1)
- Judo3DS2_iOS (= 1.1.2)
- JudoKit-iOS (from `../../`)
- MaterialComponents/Snackbar

Expand Down Expand Up @@ -120,15 +120,15 @@ SPEC CHECKSUMS:
Cucumberish: 6cbd0c1f50306b369acebfe7d9f514c9c287d26c
DeviceDNA: 9ff289d1fb983937754b324fa0adade2081210c4
InAppSettingsKit: 37df0b44132380d4c7db6fc7cded92997e29873a
Judo3DS2_iOS: 1699474533e69b69593c6a76b42645cb240f618a
JudoKit-iOS: 3b009233037b438e71c20ae11473033bd95185cb
Judo3DS2_iOS: 90b820a50035cb08ccc1b2e22900b856132c79a5
JudoKit-iOS: eabd569f41993ddd46273a63aa5c255cef473308
MaterialComponents: 1a9b2d9d45b1601ae544de85089adc4c464306d4
MDFInternationalization: d697c55307816222a55685c4ccb1044ffb030c12
MDFTextAccessibility: f4bb4cc2194286651b59a215fdeaa0e05dc90ba5
OpenSSL-Universal: ee0a7a25f2042782e2df405e66db3e429198e392
TrustKit: 610b8c71c07914756dd74c380040a3408a747798
ZappMerchantLib: b14bc5814840426d351190309250347ca9b0983d

PODFILE CHECKSUM: 10752d4f17761aeeed2fdbfd7024bb8b37e579c3
PODFILE CHECKSUM: 959926dd8d6e204912c4dfcf372d307df9eafa7f

COCOAPODS: 1.11.3
2 changes: 1 addition & 1 deletion Examples/SwiftExampleApp/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inhibit_all_warnings!

target 'SwiftExampleApp' do
# pod 'Judo3DS2_iOS', :path => '../../../Judo3DS2-iOS-Source'
pod 'Judo3DS2_iOS', '1.1.1'
pod 'Judo3DS2_iOS', '1.1.2'
pod 'JudoKit-iOS', :path => '../../'

pod 'InAppSettingsKit', '3.3.6'
Expand Down
14 changes: 7 additions & 7 deletions Examples/SwiftExampleApp/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ PODS:
- DeviceDNA (2.0.0):
- OpenSSL-Universal (~> 1.1.180)
- InAppSettingsKit (3.3.6)
- Judo3DS2_iOS (1.1.1)
- JudoKit-iOS (3.1.5):
- Judo3DS2_iOS (1.1.2)
- JudoKit-iOS (3.1.6):
- DeviceDNA (~> 2.0.0)
- Judo3DS2_iOS (~> 1.1.1)
- Judo3DS2_iOS (~> 1.1.2)
- TrustKit
- ZappMerchantLib
- OpenSSL-Universal (1.1.1700)
Expand All @@ -17,7 +17,7 @@ PODS:
DEPENDENCIES:
- CocoaDebug (= 1.7.2)
- InAppSettingsKit (= 3.3.6)
- Judo3DS2_iOS (= 1.1.1)
- Judo3DS2_iOS (= 1.1.2)
- JudoKit-iOS (from `../../`)
- SwiftLint

Expand All @@ -40,13 +40,13 @@ SPEC CHECKSUMS:
CocoaDebug: 61cf93ada6ce8f3407507dc01f9b874d91ac1d5c
DeviceDNA: 9ff289d1fb983937754b324fa0adade2081210c4
InAppSettingsKit: 37df0b44132380d4c7db6fc7cded92997e29873a
Judo3DS2_iOS: 1699474533e69b69593c6a76b42645cb240f618a
JudoKit-iOS: b78d93312da35d459c02c0e5788e84f04eec82b3
Judo3DS2_iOS: 90b820a50035cb08ccc1b2e22900b856132c79a5
JudoKit-iOS: eabd569f41993ddd46273a63aa5c255cef473308
OpenSSL-Universal: ee0a7a25f2042782e2df405e66db3e429198e392
SwiftLint: 32ee33ded0636d0905ef6911b2b67bbaeeedafa5
TrustKit: dad4c3a08248c21fcb9a3b5be3c2e2b9d4f9b973
ZappMerchantLib: b14bc5814840426d351190309250347ca9b0983d

PODFILE CHECKSUM: 233ac28971564811d36889d6e76357472cd383ec
PODFILE CHECKSUM: 4e5736f2d6472829c0d555f407e37bfa8eecafe5

COCOAPODS: 1.11.3
4 changes: 2 additions & 2 deletions JudoKit-iOS.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'JudoKit-iOS'
s.version = '3.1.5'
s.version = '3.1.6'
s.summary = 'Judo Pay Full iOS Client Kit'
s.homepage = 'https://www.judopay.com/'
s.license = 'MIT'
Expand All @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.dependency 'DeviceDNA', '~> 2.0.0'
s.dependency 'TrustKit'
s.dependency 'ZappMerchantLib'
s.dependency 'Judo3DS2_iOS', '~> 1.1.1'
s.dependency 'Judo3DS2_iOS', '~> 1.1.2'

s.frameworks = 'CoreLocation', 'Security', 'CoreTelephony', 'Vision'
s.resource_bundles = { "JudoKit_iOS" => ["Resources/*.lproj/*.strings"] }
Expand Down
Loading

0 comments on commit e9a240a

Please sign in to comment.