ios - Stripe - STPPaymentCardTextField - 如何删除或隐藏 CVC 代码字段?

标签 ios swift stripe-payments

Stripe 的 iOS SDK 的“STPPaymentCardTextField”有 4 个字段用于为卡生成 token :1. 信用卡号 2. 到期月份 3. 到期年份 4. CVC 字段

我们只保存信用卡号和到期月份/年份。我们不需要从用户那里获取 CVC 号码。那么如何从 STPPaymentCardTextField 中隐藏或删除 CVC 字段。

请给我一些想法来处理这个过程。

最佳答案

这是可能的,但我们需要小心地做这件事,确定打开STPPaymentCardTextField.m文件,你会得到CVC字段名称的属性为STPFormTextField

@property(nonatomic, readwrite, weak)STPFormTextField *cvcField; 

最终隐藏与 cvcField 相关的内容,无论它出现在那个页面上它周围占据了该页面中的 21 个位置,例如

STPFormTextField *cvcField = [self buildTextField];
cvcField.tag = STPCardFieldTypeCVC;
cvcField.alpha = 0;
self.cvcField = cvcField;
self.cvcPlaceholder = @"CVC";
[self.fieldsView addSubview:cvcField];

- (void)setCvcPlaceholder:(NSString * __nullable)cvcPlaceholder {
_cvcPlaceholder = [cvcPlaceholder copy];
self.cvcField.placeholder = _cvcPlaceholder;
}

否则做个小把戏隐藏

[self.fieldsView addSubview:cvcField];

关于ios - Stripe - STPPaymentCardTextField - 如何删除或隐藏 CVC 代码字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39098038/

相关文章:

ios - 上下文类型 'String' 不能与数组文字一起使用

ios - 在 Objective-C 中方法 Swizzling 的危险是什么?

ios - iOS 应用程序 swift 3 中的谷歌翻译 rest api 错误 403

arrays - 根据对象属性的字符串数组过滤对象数组

ios - Swift 包管理器 - 在包的 Storyboard中设置自定义类失败

php - 多个产品(购物车) strip API

ios - CTFramesetterSuggestFrameSizeWithConstraints : what attributes can be set?

xcode - 对数组中的字典进行排序

xcode - 将 Stripe 和 PaymentKit 集成到 Swift 时出现 Apple Mach-O 链接器错误

javascript - Stripe Checkout https ://checkout. stripe.com/checkout.js 和 Elements https ://js. stripe.com/v3/之间的区别