简体   繁体   English

Stripe iOS SDK-创建令牌时州和国家/地区的格式

[英]Stripe iOS SDK - Format for State and Country While Creating Token

I'm wondering what format for state and country I should be passing in the STPCardParams while creating a token in Stripe with the iOS SDK. 我想知道在使用iOS SDK在Stripe中创建令牌时,应该在STPCardParams中传递的州和国家/地区格式是什么。

In my code, I have the following: 在我的代码中,我具有以下内容:

        STPCardParams *card = [[STPCardParams alloc] init];
        card.number = self.paymentView.cardParams.number;

        card.expMonth = self.paymentView.cardParams.expMonth;
        card.expYear = self.paymentView.cardParams.expYear;
        card.cvc = self.paymentView.cardParams.cvc;
        card.addressZip = self.zipField.text;
        card.addressLine1 = self.addressField.text;
        card.addressCity = self.cityField.text;
        card.addressCountry = self.countryField.text;
        card.addressState = self.stateField.text;

        [[STPAPIClient sharedClient] createTokenWithCard:card completion:^(STPToken *token, NSError *error) { ......

My question is, should I be formatting the user's input for state and country. 我的问题是,是否应该格式化用户输入的州和国家/地区格式。

For example, should it be: 例如,应为:

"California, United States of America" or "CA, US" “美国加利福尼亚”或“美国加利福尼亚”

It should be fairly permissive about it, I'd suggest peering into the Tests within the iOS SDK. 它应该是相当宽松的,我建议您凝视iOS SDK中的测试。

Specifically, https://github.com/stripe/stripe-ios/blob/master/Tests/Tests/STPCardTest.m#L45 具体来说, https://github.com/stripe/stripe-ios/blob/master/Tests/Tests/STPCardTest.m#L45

And https://github.com/stripe/stripe-ios/blob/master/Tests/Tests/STPCardFunctionalTest.m#L19 https://github.com/stripe/stripe-ios/blob/master/Tests/Tests/STPCardFunctionalTest.m#L19

My personal choice might be to format it as "CA, US" (Two letter ISO code is how Stripe generally stores countries). 我个人的选择可能是将其格式设置为“ CA,US”(Stripe通常存储国家/地区的方式是两个字母的ISO代码)。

https://stripe.com/docs/api#card_object-country https://stripe.com/docs/api#card_object-country

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM