我开始将 Stripe 集成到我正在制作的 iOS 应用程序中,我已经到了需要验证卡信息的地步。
我试过:
#pragma mark - My Actions
- (IBAction)buyButtonTapped:(id)sender {
//Populate STPCard property
self.stripeCard = [[STPCard alloc]init];
self.stripeCard.name = self.txtFieldCardHolderName.text;
self.stripeCard.number = self.txtFieldCardNumber.text;
self.stripeCard.cvc = self.txtFieldCardCvc.text;
self.stripeCard.expMonth = [self.selectedMonth integerValue];
self.stripeCard.expYear = [self.selectedYear integerValue];
//Validate Customer info
if ([self validateCustomerInfo]) {
[self performStripeOperation];
}
}
-(BOOL)validateCustomerInfo{
//Create Alert
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Please, try again!"
message:@"Please, enter all required information."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
//Add some action
}]; …Run Code Online (Sandbox Code Playgroud)