This shows you the differences between two versions of the page.
— |
developer:ios-checkexpdate [2014/04/30 09:36] (current) jlei created |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | =====verifyExpDate : Verify the expiration date of a credit card===== | ||
+ | ====Description==== | ||
+ | |||
+ | This method takes in the credit card expiration date as a string. The date has a format of two digits for month and year. The month and year are not required to have a separator. | ||
+ | |||
+ | ie. 09/15 | ||
+ | ie. 0915 | ||
+ | ie. 09.15 | ||
+ | ie. 09-15 | ||
+ | |||
+ | It takes all the above form as a valid expiration date input. | ||
+ | |||
+ | The method will calculate the input date against the current date. It returns true if the expiration date is valid. Returns false if the expiration date is invalid. | ||
+ | |||
+ | ===Code Snippet=== | ||
+ | <code c> | ||
+ | -(void)checkExpDate | ||
+ | { | ||
+ | CreditCardPayment *ccPayment = [[CreditCardPayment alloc]init]; | ||
+ | | ||
+ | NSString *expDate = @"09-15"; | ||
+ | | ||
+ | if([ccPayment verifyExpDate:expDate]) | ||
+ | { | ||
+ | NSLog(@"Expiration date is valid"); | ||
+ | } | ||
+ | | ||
+ | else | ||
+ | { | ||
+ | NSLog(@"Expiration date is invalid"); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </code> |