diff --git a/CardIO_Public_API/CardIOPaymentViewController.h b/CardIO_Public_API/CardIOPaymentViewController.h index 41579e86..e992e6f7 100644 --- a/CardIO_Public_API/CardIOPaymentViewController.h +++ b/CardIO_Public_API/CardIOPaymentViewController.h @@ -129,6 +129,11 @@ /// Set to YES if you need to collect the billing postal code. Defaults to NO. @property(nonatomic, assign, readwrite) BOOL collectPostalCode; +/// Set to YES if the postal code should only collect numeric input. Defaults to NO. Set this if you know the +/// expected country's postal code has only numeric postal +/// codes. +@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly; + /// Set to YES if you need to collect the cardholder name. Defaults to NO. @property(nonatomic, assign, readwrite) BOOL collectCardholderName; @@ -177,4 +182,4 @@ extern NSString * const CardIOCurrentScanningOrientation; /// Returned as an NSNumber wrapping an NSTimeInterval (i.e. a double). extern NSString * const CardIOScanningOrientationAnimationDuration; -@end \ No newline at end of file +@end diff --git a/Classes/CardIOContext.h b/Classes/CardIOContext.h index 75ece6d7..4d0c19f4 100644 --- a/Classes/CardIOContext.h +++ b/Classes/CardIOContext.h @@ -19,6 +19,7 @@ @property(nonatomic, assign, readwrite) BOOL collectCVV; @property(nonatomic, assign, readwrite) BOOL collectExpiry; @property(nonatomic, assign, readwrite) BOOL collectPostalCode; +@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly; @property(nonatomic, assign, readwrite) BOOL collectCardholderName; @property(nonatomic, assign, readwrite) BOOL disableManualEntryButtons; @property(nonatomic, assign, readwrite) BOOL keepStatusBarStyle; diff --git a/Classes/CardIODataEntryViewController.h b/Classes/CardIODataEntryViewController.h index cbe3bd78..c9d3154d 100644 --- a/Classes/CardIODataEntryViewController.h +++ b/Classes/CardIODataEntryViewController.h @@ -27,6 +27,7 @@ @property(nonatomic, assign, readwrite) BOOL collectExpiry; @property(nonatomic, assign, readwrite) BOOL collectCVV; @property(nonatomic, assign, readwrite) BOOL collectPostalCode; +@property(nonatomic, assign, readwrite) BOOL restrictPostalCodeToNumericOnly; @property(nonatomic, assign, readwrite) BOOL collectCardholderName; @property(nonatomic, strong, readwrite) UITextField *expiryTextField; @property(nonatomic, strong, readwrite) UITextField *numberTextField; diff --git a/Classes/CardIODataEntryViewController.m b/Classes/CardIODataEntryViewController.m index e8e5125a..d29b839d 100644 --- a/Classes/CardIODataEntryViewController.m +++ b/Classes/CardIODataEntryViewController.m @@ -151,6 +151,7 @@ - (void)viewDidLoad { self.collectExpiry = pvc.collectExpiry; self.collectCVV = pvc.collectCVV; self.collectPostalCode = pvc.collectPostalCode; + self.restrictPostalCodeToNumericOnly = pvc.restrictPostalCodeToNumericOnly; self.collectCardholderName = pvc.collectCardholderName; self.scrollView = [[UIScrollView alloc] initWithFrame:self.relevantViewFrame]; @@ -312,7 +313,12 @@ - (void)viewDidLoad { self.postalCodeTextField.placeholder = postalCodeText; self.postalCodeTextField.delegate = self.postalCodeRowTextFieldDelegate; self.postalCodeTextField.text = self.cardInfo.postalCode; - self.postalCodeTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; + if (self.restrictPostalCodeToNumericOnly) { + self.postalCodeTextField.keyboardType = UIKeyboardTypeNumberPad; + self.postalCodeRowTextFieldDelegate.numbersOnly = YES; + } else { + self.postalCodeTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; + } self.postalCodeTextField.clearButtonMode = UITextFieldViewModeNever; self.postalCodeTextField.text = @""; self.postalCodeTextField.textAlignment = [CardIOLocalizer textAlignmentForLanguageOrLocale:self.context.languageOrLocale]; diff --git a/Classes/CardIOPaymentViewController.m b/Classes/CardIOPaymentViewController.m index 8e1b09ff..8d77a72d 100644 --- a/Classes/CardIOPaymentViewController.m +++ b/Classes/CardIOPaymentViewController.m @@ -340,7 +340,7 @@ - (void)didReceiveForegroundingNotification:(NSNotification *)notification { #define DESCRIBE_BOOL(property) (self.property ? "; " #property : "") - (NSString *)description { - return [NSString stringWithFormat:@"{delegate: %@; %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}" + return [NSString stringWithFormat:@"{delegate: %@; %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s}" ,self.paymentDelegate ,DESCRIBE_BOOL(keepStatusBarStyle) ,DESCRIBE_BOOL(disableBlurWhenBackgrounding) @@ -351,6 +351,7 @@ - (NSString *)description { ,DESCRIBE_BOOL(collectCVV) ,DESCRIBE_BOOL(collectPostalCode) ,DESCRIBE_BOOL(collectCardholderName) + ,DESCRIBE_BOOL(restrictPostalCodeToNumericOnly) ,DESCRIBE_BOOL(scanExpiry) ,DESCRIBE_BOOL(useCardIOLogo) ,DESCRIBE_BOOL(disableManualEntryButtons) @@ -388,6 +389,7 @@ - (void)set##prop_uc:(t)prop_lc { \ CONTEXT_PASSTHROUGH_READWRITE(BOOL, disableBlurWhenBackgrounding, DisableBlurWhenBackgrounding) CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectCVV, CollectCVV) CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectPostalCode, CollectPostalCode) +CONTEXT_PASSTHROUGH_READWRITE(BOOL, restrictPostalCodeToNumericOnly, RestrictPostalCodeToNumericOnly) CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectCardholderName, CollectCardholderName) CONTEXT_PASSTHROUGH_READWRITE(BOOL, collectExpiry, CollectExpiry) CONTEXT_PASSTHROUGH_READWRITE(BOOL, scanExpiry, ScanExpiry) diff --git a/Classes/RootViewController.m b/Classes/RootViewController.m index 67dea994..3397c980 100644 --- a/Classes/RootViewController.m +++ b/Classes/RootViewController.m @@ -26,6 +26,7 @@ @interface RootViewController () @property(nonatomic, strong, readwrite) IBOutlet UISwitch *expirySwitch; @property(nonatomic, strong, readwrite) IBOutlet UISwitch *cvvSwitch; @property(nonatomic, strong, readwrite) IBOutlet UISwitch *zipSwitch; +@property(nonatomic, strong, readwrite) IBOutlet UISwitch *zipOnlyNumericSwitch; @property(nonatomic, strong, readwrite) IBOutlet UISwitch *nameSwitch; @property(nonatomic, strong, readwrite) IBOutlet UILabel *outcomeLabel; @property(nonatomic, strong, readwrite) IBOutlet UIImageView *cardImageView; @@ -80,6 +81,7 @@ - (IBAction)scan { paymentVC.collectExpiry = self.expirySwitch.on; paymentVC.collectCVV = self.cvvSwitch.on; paymentVC.collectPostalCode = self.zipSwitch.on; + paymentVC.restrictPostalCodeToNumericOnly = self.zipOnlyNumericSwitch.on; paymentVC.collectCardholderName = self.nameSwitch.on; paymentVC.disableManualEntryButtons = self.disableManualEntrySwitch.on; paymentVC.useCardIOLogo = self.useCardIOLogoSwitch.on; @@ -423,6 +425,9 @@ - (void)userDidProvideCreditCardInfo:(CardIOCreditCardInfo *)info inPaymentViewC if(self.zipSwitch.on) { [resultStr appendFormat:@"Postal Code: %@\n", info.postalCode]; } + if(self.zipOnlyNumericSwitch.on) { + [resultStr appendFormat:@"Postal Code Only Numeric: %@\n", info.postalCode]; + } if(self.nameSwitch.on) { [resultStr appendFormat:@"Cardholder Name: %@\n", info.cardholderName]; } diff --git a/Classes/RootViewController.xib b/Classes/RootViewController.xib index a5b54a04..b63aaf54 100644 --- a/Classes/RootViewController.xib +++ b/Classes/RootViewController.xib @@ -1,7 +1,7 @@ - + - + @@ -25,6 +25,7 @@ + @@ -34,7 +35,7 @@