Approach 1: Using custom views
You could use custom views rather than STPView which would give you full control over when the keyboard is triggered. You can then just populate an instance of STPCart. The stripe gighub page describes this approach under the section: 'using your own views'.
https://github.com/stripe/stripe-ios
STPCard *card = [[STPCard alloc] init];
card.number = @"4242424242424242";
card.expMonth = 12;
card.expYear = 2020;
Approach 2: Using Stripes STPView implementation
To do it with Stripe's STPView you can use an approach using addTarget on the offending UITextField subclass for the UIControlEventEditingDidBegin event. You can remove it after the view loads as it's no longer required:
// YourViewController.h
#import <UIKit/UIKit.h>
#import "YourViewController.h"
@class STPView;
@interface YourViewController : UIViewController
@property (strong,nonatomic) STPView *stripeView;
@end
// YourViewController.m
#import "YourViewController.h"
#import "STPView.h"
#import "PKView.h"
#import "PKTextField.h"
@interface YourViewController ()
@end
@implementation YourViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Create your STPView instance
_stripeView = [[STPView alloc] initWithFrame:CGRectMake(15,20,290,55) andKey:@"perishable_key"];
[self.view addSubview:_stripeView];
// Add target for editingDidBegin UIControl event
[_stripeView.paymentView.cardNumberField addTarget:self action:@selector(editingBegan:) forControlEvents:UIControlEventEditingDidBegin];
}
- (void)editingBegan:(id)sender
{
// Hide the keyboard
[_stripeView.paymentView.cardNumberField resignFirstResponder];
// Remove the addTarget
[_stripeView.paymentView.cardNumberField removeTarget:self action:@selector(editingChanged:) forControlEvents:UIControlEventEditingDidBegin];
}
@end
cardNumberField is an instance of PKTextField (a subclass of UITextField) and the view that gets the focus when the STPView is created.