stripe/PaymentKit

语言: Objective-C

git: https://github.com/stripe/PaymentKit

轻松接受iOS上的付款
Easily accept payments on iOS
README.md (中文)

PaymentKit

PaymentKit是一个实用程序库,用于在iOS应用程序中编写支付表单。

重要的提示

我们已将PaymentKit组件的开发转移到我们的主iOS SDK中。这将使我们更容易使它们保持最新,并使大多数应用程序的安装和集成更简单。尽管如此,请注意您不必是Stripe用户就可以使用这些组件 - 我们构建的UI与Stripe API没有任何依赖关系。

移民

如果您正在使用CocoaPods,要安装我们的iOS SDK,只需将pod“Stripe”添加到您的Podfile即可。有关其他集成方法,请查看我们的安装指南。

我们已将PTKView重命名为STPPaymentCardTextField。我们还提供了兼容性填充程序,因此如果您有一个使用PaymentKit的应用程序,则无需更改任何代码即可进行迁移。但是,迁移非常简单:

  • 如果您正在使用CocoaPods,请删除Podfile中对“PaymentKit”的任何引用。
  • 将应用程序中PTKView的任何实例重命名为STPPaymentCardTextField。
  • 删除任何读取#import'PTKView.h'的行,并用#import <Stripe / Stripe.h>替换它们。
  • 任何实现PTKViewDelegate协议的类现在都应该采用STPPaymentCardTextFieldDelegate协议。
  • 调整您的PTKViewDelegate方法如下:
// Before
- (void)paymentView:(nonnull PTKView *)paymentView withCard:(nonnull PTKCard *)card isValid:(BOOL)valid {
    if (valid) {
        [self doSomethingWithCard:card];
    }
}

// After
- (void)paymentCardTextFieldDidChange:(STPPaymentCardTextField *)textField {
    if (textField.isValid) {
        STPCard *card = [[STPCard alloc] init];
        card.number = textField.cardNumber;
        card.expMonth = textField.expirationMonth;
        card.expYear = textField.expirationYear;
        card.cvc = textField.cvc;
        [self doSomethingWithCard:card];
    }
}

如果您对迁移有任何疑问,请随时联系support@stripe.com。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

PaymentKit

PaymentKit is a utility library for writing payment forms in iOS apps.

Important note

We've moved development of PaymentKit's components into our main iOS SDK. This will make it easier for us to keep them up-to-date, and make installation and integration simpler for most apps. Despite this, please note that you don't have to be a Stripe user to use these components - the UI we've built has no dependencies on the Stripe API.

Migration

If you're using CocoaPods, to install our iOS SDK, just add pod 'Stripe' to your Podfile. For other means of integration, check out our installation guide.

We've renamed PTKView to STPPaymentCardTextField. We've also provided a compatibility shim so if you have an app that uses PaymentKit, you won't have to change any of your code in order to migrate over. However, migration is extremely straightforward:

  • Remove any references to 'PaymentKit' in your Podfile, if you're using CocoaPods.
  • Rename any instances of PTKView in your application to STPPaymentCardTextField.
  • Remove any lines that read #import 'PTKView.h', and replace them with #import <Stripe/Stripe.h>.
  • Any classes that implement the PTKViewDelegate protocol should now adopt the STPPaymentCardTextFieldDelegate protocol instead.
  • Adjust your PTKViewDelegate methods as follows:
// Before
- (void)paymentView:(nonnull PTKView *)paymentView withCard:(nonnull PTKCard *)card isValid:(BOOL)valid {
    if (valid) {
        [self doSomethingWithCard:card];
    }
}

// After
- (void)paymentCardTextFieldDidChange:(STPPaymentCardTextField *)textField {
    if (textField.isValid) {
        STPCard *card = [[STPCard alloc] init];
        card.number = textField.cardNumber;
        card.expMonth = textField.expirationMonth;
        card.expYear = textField.expirationYear;
        card.cvc = textField.cvc;
        [self doSomethingWithCard:card];
    }
}

If you have any issues with migration, feel free to contact support@stripe.com.