diff --git a/Example/Basic Integration/README.md b/Example/Basic Integration/README.md index 7dac7182df8..31d3aa73c9c 100644 --- a/Example/Basic Integration/README.md +++ b/Example/Basic Integration/README.md @@ -1,8 +1,12 @@ # Basic Integration +

+Basic Integraion Example App +

+ This example app demonstrates how to build a payment flow using our pre-built UI component integration (`STPPaymentContext`). -For a detailed guide, see https://stripe.com/docs/mobile/ios/standard +For a detailed guide, see https://stripe.com/docs/mobile/ios/basic ## To run the example app: diff --git a/Example/Custom Integration/CardAutomaticConfirmationViewController.h b/Example/Custom Integration/CardAutomaticConfirmationViewController.h deleted file mode 100644 index 2662c9e632e..00000000000 --- a/Example/Custom Integration/CardAutomaticConfirmationViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// CardAutomaticConfirmationViewController.h -// Custom Integration -// -// Created by Daniel Jackson on 7/5/18. -// Copyright © 2018 Stripe. All rights reserved. -// - -#import - -@protocol ExampleViewControllerDelegate; - -@interface CardAutomaticConfirmationViewController : UIViewController - -@property (nonatomic, weak) id delegate; - -@end diff --git a/Example/Custom Integration/CardAutomaticConfirmationViewController.m b/Example/Custom Integration/CardAutomaticConfirmationViewController.m deleted file mode 100644 index 52fb16f1be0..00000000000 --- a/Example/Custom Integration/CardAutomaticConfirmationViewController.m +++ /dev/null @@ -1,167 +0,0 @@ -// -// CardAutomaticConfirmationViewController.m -// Custom Integration -// -// Created by Daniel Jackson on 7/5/18. -// Copyright © 2018 Stripe. All rights reserved. -// - -@import Stripe; - -#import "CardAutomaticConfirmationViewController.h" -#import "BrowseExamplesViewController.h" - -#import "MyAPIClient.h" - -/** - This example demonstrates using PaymentIntents to accept card payments verified using 3D Secure. - - 1. Collect user's card information via `STPPaymentCardTextField` - 2. Create a `PaymentIntent` on our backend (this can happen concurrently with #1) - 3. Confirm PaymentIntent using the `STPPaymentMethodParams` for the user's card information. - 4. If the user needs to go through the 3D Secure authentication flow, use `STPPaymentHandler` to do so. - 5. When user finishes native authentication, returns to the app, or finishes the SafariVC redirect flow, `STPPaymentHandler` notifies via callback - - See the documentation at https://stripe.com/docs/payments/payment-intents/ios for more information - on using PaymentIntents for dynamic authentication. - */ -@interface CardAutomaticConfirmationViewController () - -@property (weak, nonatomic) STPPaymentCardTextField *paymentTextField; -@property (weak, nonatomic) UILabel *waitingLabel; -@property (weak, nonatomic) UIActivityIndicatorView *activityIndicator; - -@end - -@implementation CardAutomaticConfirmationViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - self.view.backgroundColor = [UIColor whiteColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - self.view.backgroundColor = [UIColor systemBackgroundColor]; - } - #endif - self.title = @"Card"; - self.edgesForExtendedLayout = UIRectEdgeNone; - - STPPaymentCardTextField *paymentTextField = [[STPPaymentCardTextField alloc] init]; - STPPaymentMethodCardParams *cardParams = [STPPaymentMethodCardParams new]; - // Only successful 3D Secure transactions on this test card will succeed. - cardParams.number = @"4000000000003063"; - paymentTextField.cardParams = cardParams; - paymentTextField.delegate = self; - paymentTextField.cursorColor = [UIColor purpleColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - paymentTextField.cursorColor = [UIColor systemPurpleColor]; - } - #endif - self.paymentTextField = paymentTextField; - [self.view addSubview:paymentTextField]; - - UILabel *label = [UILabel new]; - label.text = @"Waiting for payment authorization"; - [label sizeToFit]; - label.textColor = [UIColor grayColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - label.textColor = [UIColor secondaryLabelColor]; - } - #endif - - label.alpha = 0; - [self.view addSubview:label]; - self.waitingLabel = label; - - NSString *title = @"Pay"; - UIBarButtonItem *payButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleDone target:self action:@selector(pay)]; - payButton.enabled = paymentTextField.isValid; - self.navigationItem.rightBarButtonItem = payButton; - - UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - activityIndicator.hidesWhenStopped = YES; - self.activityIndicator = activityIndicator; - [self.view addSubview:activityIndicator]; -} - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [self.paymentTextField becomeFirstResponder]; -} - -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; - CGFloat padding = 15; - CGFloat width = CGRectGetWidth(self.view.frame) - (padding*2); - CGRect bounds = self.view.bounds; - self.paymentTextField.frame = CGRectMake(padding, padding, width, 44); - self.activityIndicator.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.paymentTextField.frame) + padding*2); - self.waitingLabel.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.activityIndicator.frame) + padding*2); -} - -- (void)updateUIForPaymentInProgress:(BOOL)paymentInProgress { - self.navigationController.navigationBar.userInteractionEnabled = !paymentInProgress; - self.navigationItem.rightBarButtonItem.enabled = !paymentInProgress; - self.paymentTextField.userInteractionEnabled = !paymentInProgress; - [UIView animateWithDuration:0.2 animations:^{ - self.waitingLabel.alpha = paymentInProgress ? 1 : 0; - }]; - if (paymentInProgress) { - [self.activityIndicator startAnimating]; - } else { - [self.activityIndicator stopAnimating]; - } -} - -- (void)paymentCardTextFieldDidChange:(nonnull STPPaymentCardTextField *)textField { - self.navigationItem.rightBarButtonItem.enabled = textField.isValid; -} - -- (void)pay { - if (![self.paymentTextField isValid]) { - return; - } - if (![Stripe defaultPublishableKey]) { - [self.delegate exampleViewController:self didFinishWithMessage:@"Please set a Stripe Publishable Key in Constants.m"]; - return; - } - [self updateUIForPaymentInProgress:YES]; - - // In a more interesting app, you'll probably create your PaymentIntent as soon as you know the - // payment amount you wish to collect from your customer. For simplicity, this example does it once they've - // pushed the Pay button. - // https://stripe.com/docs/payments/dynamic-authentication#create-payment-intent - [[MyAPIClient sharedClient] createPaymentIntentWithCompletion:^(MyAPIClientResult status, NSString *clientSecret, NSError *error) { - if (status == MyAPIClientResultFailure || clientSecret == nil) { - [self.delegate exampleViewController:self didFinishWithError:error]; - return; - } - - STPPaymentIntentParams *paymentIntentParams = [[STPPaymentIntentParams alloc] initWithClientSecret:clientSecret]; - paymentIntentParams.paymentMethodParams = [STPPaymentMethodParams paramsWithCard:self.paymentTextField.cardParams - billingDetails:nil - metadata:nil]; - paymentIntentParams.returnURL = @"payments-example://stripe-redirect"; - [[STPPaymentHandler sharedHandler] confirmPayment:paymentIntentParams - withAuthenticationContext:self.delegate - completion:^(STPPaymentHandlerActionStatus handlerStatus, STPPaymentIntent * handledIntent, NSError * _Nullable handlerError) { - switch (handlerStatus) { - case STPPaymentHandlerActionStatusFailed: - [self.delegate exampleViewController:self didFinishWithError:handlerError]; - break; - case STPPaymentHandlerActionStatusCanceled: - [self.delegate exampleViewController:self didFinishWithMessage:@"Canceled"]; - break; - case STPPaymentHandlerActionStatusSucceeded: - [self.delegate exampleViewController:self didFinishWithMessage:@"Payment successfully created"]; - break; - } - }]; - } additionalParameters:nil]; -} - -@end diff --git a/Example/Custom Integration/CardManualConfirmationExampleViewController.h b/Example/Custom Integration/CardManualConfirmationExampleViewController.h deleted file mode 100644 index f07f423bdd1..00000000000 --- a/Example/Custom Integration/CardManualConfirmationExampleViewController.h +++ /dev/null @@ -1,17 +0,0 @@ -// -// CardManualConfirmationExampleViewController.h -// Custom Integration -// -// Created by Ben Guo on 2/22/17. -// Copyright © 2017 Stripe. All rights reserved. -// - -#import - -@protocol ExampleViewControllerDelegate; - -@interface CardManualConfirmationExampleViewController : UIViewController - -@property (nonatomic, weak) id delegate; - -@end diff --git a/Example/Custom Integration/CardManualConfirmationExampleViewController.m b/Example/Custom Integration/CardManualConfirmationExampleViewController.m deleted file mode 100644 index ea0260ffd79..00000000000 --- a/Example/Custom Integration/CardManualConfirmationExampleViewController.m +++ /dev/null @@ -1,166 +0,0 @@ -// -// CardManualConfirmationExampleViewController.m -// Custom Integration -// -// Created by Ben Guo on 2/22/17. -// Copyright © 2017 Stripe. All rights reserved. -// - -#import - -#import "CardManualConfirmationExampleViewController.h" - -#import "BrowseExamplesViewController.h" -#import "MyAPIClient.h" - -/** - This example demonstrates creating a payment with a credit/debit card using Manual Integration. - It creates a Payment Method using card information collected with STPPaymentCardTextField, and - then sends the Payment Method ID to our example backend to create and confirm the Payment Intent. - */ -@interface CardManualConfirmationExampleViewController () -@property (weak, nonatomic) STPPaymentCardTextField *paymentTextField; -@property (weak, nonatomic) UIActivityIndicatorView *activityIndicator; -@property (weak, nonatomic) UIScrollView *scrollView; -@end - -@implementation CardManualConfirmationExampleViewController - -- (void)loadView { - UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectZero]; - scrollView.delegate = self; - scrollView.alwaysBounceVertical = YES; - scrollView.backgroundColor = [UIColor whiteColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - scrollView.backgroundColor = [UIColor systemBackgroundColor]; - } - #endif - - self.view = scrollView; - self.scrollView = scrollView; -} - -- (void)viewDidLoad { - [super viewDidLoad]; - - self.title = @"Card - Manual Integration"; - self.edgesForExtendedLayout = UIRectEdgeNone; - - UIBarButtonItem *buyButton = [[UIBarButtonItem alloc] initWithTitle:@"Pay" style:UIBarButtonItemStyleDone target:self action:@selector(pay)]; - buyButton.enabled = NO; - self.navigationItem.rightBarButtonItem = buyButton; - - STPPaymentCardTextField *paymentTextField = [[STPPaymentCardTextField alloc] init]; - STPPaymentMethodCardParams *cardParams = [STPPaymentMethodCardParams new]; - // Only successful 3D Secure transactions on this test card will succeed. - cardParams.number = @"4000000000003063"; - paymentTextField.cardParams = cardParams; - paymentTextField.delegate = self; - paymentTextField.cursorColor = [UIColor purpleColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - paymentTextField.cursorColor = [UIColor systemPurpleColor]; - } - #endif - self.paymentTextField = paymentTextField; - [self.view addSubview:paymentTextField]; - - UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - activityIndicator.hidesWhenStopped = YES; - self.activityIndicator = activityIndicator; - [self.view addSubview:activityIndicator]; -} - -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; - CGFloat padding = 15; - CGFloat width = CGRectGetWidth(self.view.frame) - (padding*2); - CGRect bounds = self.view.bounds; - self.paymentTextField.frame = CGRectMake(padding, padding, width, 44); - self.activityIndicator.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.paymentTextField.frame) + padding*2); -} - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [self.paymentTextField becomeFirstResponder]; -} - -- (void)paymentCardTextFieldDidChange:(nonnull STPPaymentCardTextField *)textField { - self.navigationItem.rightBarButtonItem.enabled = textField.isValid; -} - -- (void)pay { - if (![self.paymentTextField isValid]) { - return; - } - if (![Stripe defaultPublishableKey]) { - [self.delegate exampleViewController:self didFinishWithMessage:@"Please set a Stripe Publishable Key in Constants.m"]; - return; - } - [self.activityIndicator startAnimating]; - - STPPaymentMethodParams *paymentMethodParams = [STPPaymentMethodParams paramsWithCard:self.paymentTextField.cardParams - billingDetails:nil - metadata:nil]; - [[STPAPIClient sharedClient] createPaymentMethodWithParams:paymentMethodParams - completion:^(STPPaymentMethod * _Nullable paymentMethod, NSError * _Nullable error) { - if (error) { - [self.delegate exampleViewController:self didFinishWithError:error]; - } else { - [self _createAndConfirmPaymentIntentWithPaymentMethod:paymentMethod]; - } - }]; -} - - -- (void)_createAndConfirmPaymentIntentWithPaymentMethod:(STPPaymentMethod *)paymentMethod { - STPPaymentHandlerActionPaymentIntentCompletionBlock paymentHandlerCompletion = ^(STPPaymentHandlerActionStatus handlerStatus, STPPaymentIntent * _Nullable paymentIntent, NSError * _Nullable handlerError) { - switch (handlerStatus) { - case STPPaymentHandlerActionStatusFailed: - [self.delegate exampleViewController:self didFinishWithError:handlerError]; - break; - case STPPaymentHandlerActionStatusCanceled: - [self.delegate exampleViewController:self didFinishWithMessage:@"Canceled authentication"]; - break; - case STPPaymentHandlerActionStatusSucceeded: - if (paymentIntent.status == STPPaymentIntentStatusRequiresConfirmation) { - // Manually confirm the PaymentIntent on the backend again to complete the payment. - [[MyAPIClient sharedClient] confirmPaymentIntent:paymentIntent.stripeId completion:^(MyAPIClientResult status, NSError *error) { - if (status == MyAPIClientResultFailure || error) { - [self.delegate exampleViewController:self didFinishWithError:error]; - return; - } - [self.delegate exampleViewController:self didFinishWithMessage:@"Payment successfully created"]; - }]; - break; - } else { - [self.delegate exampleViewController:self didFinishWithMessage:@"Payment successfully created"]; - } - } - }; - STPPaymentIntentCreateAndConfirmHandler createAndConfirmCompletion = ^(MyAPIClientResult status, BOOL requiresAction, NSString *clientSecret, NSError *error) { - if (status == MyAPIClientResultFailure || error) { - [self.delegate exampleViewController:self didFinishWithError:error]; - return; - } - if (requiresAction) { - [[STPPaymentHandler sharedHandler] handleNextActionForPayment:clientSecret - withAuthenticationContext:self.delegate - returnURL:@"payments-example://stripe-redirect" - completion:paymentHandlerCompletion]; - } else { - [self.delegate exampleViewController:self didFinishWithMessage:@"Payment successfully created"]; - } - }; - [[MyAPIClient sharedClient] createAndConfirmPaymentIntentWithPaymentMethod:paymentMethod.stripeId - returnURL:@"payments-example://stripe-redirect" - completion:createAndConfirmCompletion]; -} - -- (void)scrollViewDidScroll:(UIScrollView *)scrollView { - [self.view endEditing:NO]; -} - -@end diff --git a/Example/Custom Integration/CardSetupIntentBackendExampleViewController.h b/Example/Custom Integration/CardSetupIntentBackendExampleViewController.h deleted file mode 100644 index ecabd61e49a..00000000000 --- a/Example/Custom Integration/CardSetupIntentBackendExampleViewController.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// CardSetupIntentBackendExampleViewController.h -// Custom Integration -// -// Created by Cameron Sabol on 7/17/19. -// Copyright © 2019 Stripe. All rights reserved. -// - -#import - -@protocol ExampleViewControllerDelegate; - -NS_ASSUME_NONNULL_BEGIN - -@interface CardSetupIntentBackendExampleViewController : UIViewController - -@property (nonatomic, weak) id delegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Example/Custom Integration/CardSetupIntentBackendExampleViewController.m b/Example/Custom Integration/CardSetupIntentBackendExampleViewController.m deleted file mode 100644 index 89dd0b0c401..00000000000 --- a/Example/Custom Integration/CardSetupIntentBackendExampleViewController.m +++ /dev/null @@ -1,175 +0,0 @@ -// -// CardSetupIntentBackendExampleViewController.m -// Custom Integration -// -// Created by Cameron Sabol on 7/17/19. -// Copyright © 2019 Stripe. All rights reserved. -// - -#import "CardSetupIntentBackendExampleViewController.h" -#import "BrowseExamplesViewController.h" - -#import "MyAPIClient.h" - -/** - This example demonstrates using SetupIntents to accept card payments verified using 3D Secure confirming with your backend. - - 1. Collect user's card information via `STPPaymentCardTextField` - 2. Create a PaymentMethod with the collected card information - 3. Create a `SetupIntent` on our backend and set confirm=true - 4. Handle any required `nextAction` using `STPPaymentHandler` - */ -@interface CardSetupIntentBackendExampleViewController () - -@property (weak, nonatomic) STPPaymentCardTextField *paymentTextField; -@property (weak, nonatomic) UILabel *waitingLabel; -@property (weak, nonatomic) UIActivityIndicatorView *activityIndicator; - -@end - -@implementation CardSetupIntentBackendExampleViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - self.view.backgroundColor = [UIColor whiteColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - self.view.backgroundColor = [UIColor systemBackgroundColor]; - } - #endif - - self.title = @"Card SetupIntent (Backend)"; - self.edgesForExtendedLayout = UIRectEdgeNone; - - STPPaymentCardTextField *paymentTextField = [[STPPaymentCardTextField alloc] init]; - STPPaymentMethodCardParams *cardParams = [STPPaymentMethodCardParams new]; - // Only successful 3D Secure transactions on this test card will succeed. - cardParams.number = @"4000002500003155"; - paymentTextField.cardParams = cardParams; - paymentTextField.delegate = self; - paymentTextField.cursorColor = [UIColor purpleColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - paymentTextField.cursorColor = [UIColor systemPurpleColor]; - } - #endif - self.paymentTextField = paymentTextField; - [self.view addSubview:paymentTextField]; - - UILabel *label = [UILabel new]; - label.text = @"Waiting for payment authorization"; - [label sizeToFit]; - label.textColor = [UIColor grayColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - label.textColor = [UIColor secondaryLabelColor]; - } - #endif - label.alpha = 0; - [self.view addSubview:label]; - self.waitingLabel = label; - - NSString *title = @"Pay"; - UIBarButtonItem *payButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleDone target:self action:@selector(pay)]; - payButton.enabled = paymentTextField.isValid; - self.navigationItem.rightBarButtonItem = payButton; - - UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - activityIndicator.hidesWhenStopped = YES; - self.activityIndicator = activityIndicator; - [self.view addSubview:activityIndicator]; -} - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [self.paymentTextField becomeFirstResponder]; -} - -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; - CGFloat padding = 15; - CGFloat width = CGRectGetWidth(self.view.frame) - (padding*2); - CGRect bounds = self.view.bounds; - self.paymentTextField.frame = CGRectMake(padding, padding, width, 44); - self.activityIndicator.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.paymentTextField.frame) + padding*2); - self.waitingLabel.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.activityIndicator.frame) + padding*2); -} - -- (void)updateUIForPaymentInProgress:(BOOL)paymentInProgress { - self.navigationController.navigationBar.userInteractionEnabled = !paymentInProgress; - self.navigationItem.rightBarButtonItem.enabled = !paymentInProgress; - self.paymentTextField.userInteractionEnabled = !paymentInProgress; - [UIView animateWithDuration:0.2 animations:^{ - self.waitingLabel.alpha = paymentInProgress ? 1 : 0; - }]; - if (paymentInProgress) { - [self.activityIndicator startAnimating]; - } else { - [self.activityIndicator stopAnimating]; - } -} - -- (void)paymentCardTextFieldDidChange:(nonnull STPPaymentCardTextField *)textField { - self.navigationItem.rightBarButtonItem.enabled = textField.isValid; -} - -- (void)pay { - - if (![self.paymentTextField isValid]) { - return; - } - if (![Stripe defaultPublishableKey]) { - [self.delegate exampleViewController:self didFinishWithMessage:@"Please set a Stripe Publishable Key in Constants.m"]; - return; - } - [self updateUIForPaymentInProgress:YES]; - - STPPaymentMethodParams *paymentMethodParams = [STPPaymentMethodParams paramsWithCard:self.paymentTextField.cardParams - billingDetails:nil - metadata:nil]; - [[STPAPIClient sharedClient] createPaymentMethodWithParams:paymentMethodParams - completion:^(STPPaymentMethod * _Nullable paymentMethod, NSError * _Nullable error) { - if (error) { - [self.delegate exampleViewController:self didFinishWithError:error]; - } else { - [self _createAndConfirmSetupIntentWithPaymentMethod:paymentMethod]; - } - }]; - -} - -- (void)_createAndConfirmSetupIntentWithPaymentMethod:(STPPaymentMethod *)paymentMethod { - STPPaymentHandlerActionSetupIntentCompletionBlock paymentHandlerCompletion = ^(STPPaymentHandlerActionStatus handlerStatus, STPSetupIntent * _Nullable setupIntent, NSError * _Nullable handlerError) { - switch (handlerStatus) { - case STPPaymentHandlerActionStatusFailed: - [self.delegate exampleViewController:self didFinishWithError:handlerError]; - break; - case STPPaymentHandlerActionStatusCanceled: - [self.delegate exampleViewController:self didFinishWithMessage:@"Canceled authentication"]; - break; - case STPPaymentHandlerActionStatusSucceeded: - [self.delegate exampleViewController:self didFinishWithMessage:@"SetupIntent successfully created"]; - break; - } - }; - - STPCreateSetupIntentCompletionHandler createCompletion = ^(MyAPIClientResult status, NSString *clientSecret, NSError *error) { - if (status == MyAPIClientResultFailure || error) { - [self.delegate exampleViewController:self didFinishWithError:error]; - return; - } - [[STPPaymentHandler sharedHandler] handleNextActionForSetupIntent:clientSecret - withAuthenticationContext:self.delegate - returnURL:@"payments-example://stripe-redirect" - completion:paymentHandlerCompletion]; - }; - - [[MyAPIClient sharedClient] createAndConfirmSetupIntentWithPaymentMethod:paymentMethod.stripeId - returnURL:@"payments-example://stripe-redirect" - completion:createCompletion]; -} - - -@end diff --git a/Example/Custom Integration/CardSetupIntentExampleViewController.h b/Example/Custom Integration/CardSetupIntentExampleViewController.h deleted file mode 100644 index 1e9eaf44e05..00000000000 --- a/Example/Custom Integration/CardSetupIntentExampleViewController.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// CardSetupIntentExampleViewController.h -// Custom Integration -// -// Created by Yuki Tokuhiro on 7/1/19. -// Copyright © 2019 Stripe. All rights reserved. -// - -#import - -@protocol ExampleViewControllerDelegate; - -NS_ASSUME_NONNULL_BEGIN - -@interface CardSetupIntentExampleViewController : UIViewController - -@property (nonatomic, weak) id delegate; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Example/Custom Integration/CardSetupIntentExampleViewController.m b/Example/Custom Integration/CardSetupIntentExampleViewController.m deleted file mode 100644 index 6ddd96394c7..00000000000 --- a/Example/Custom Integration/CardSetupIntentExampleViewController.m +++ /dev/null @@ -1,156 +0,0 @@ -// -// CardSetupIntentExampleViewController.m -// Custom Integration -// -// Created by Yuki Tokuhiro on 7/1/19. -// Copyright © 2019 Stripe. All rights reserved. -// - -@import Stripe; - -#import "CardSetupIntentExampleViewController.h" - -#import "BrowseExamplesViewController.h" -#import "MyAPIClient.h" - -/** - This example demonstrates using SetupIntents to accept card payments verified using 3D Secure. - - 1. Collect user's card information via `STPPaymentCardTextField` - 2. Create a `SetupIntent` on our backend (this can happen concurrently with #1) - 3. Confirm SetupIntent with `STPPaymentHandler`, using the `STPPaymentMethodParams` for the user's card information. - */ -@interface CardSetupIntentExampleViewController () - -@property (weak, nonatomic) STPPaymentCardTextField *paymentTextField; -@property (weak, nonatomic) UILabel *waitingLabel; -@property (weak, nonatomic) UIActivityIndicatorView *activityIndicator; - -@end - -@implementation CardSetupIntentExampleViewController - -- (void)viewDidLoad { - [super viewDidLoad]; - self.view.backgroundColor = [UIColor whiteColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - self.view.backgroundColor = [UIColor systemBackgroundColor]; - } - #endif - self.title = @"Card"; - self.edgesForExtendedLayout = UIRectEdgeNone; - - STPPaymentCardTextField *paymentTextField = [[STPPaymentCardTextField alloc] init]; - STPPaymentMethodCardParams *cardParams = [STPPaymentMethodCardParams new]; - // Only successful 3D Secure transactions on this test card will succeed. - cardParams.number = @"4000002500003155"; - paymentTextField.cardParams = cardParams; - paymentTextField.delegate = self; - paymentTextField.cursorColor = [UIColor purpleColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - paymentTextField.cursorColor = [UIColor systemPurpleColor]; - } - #endif - self.paymentTextField = paymentTextField; - [self.view addSubview:paymentTextField]; - - UILabel *label = [UILabel new]; - label.text = @"Waiting for payment authorization"; - [label sizeToFit]; - label.textColor = [UIColor grayColor]; - #ifdef __IPHONE_13_0 - if (@available(iOS 13.0, *)) { - label.textColor = [UIColor secondaryLabelColor]; - } - #endif - label.alpha = 0; - [self.view addSubview:label]; - self.waitingLabel = label; - - NSString *title = @"Pay"; - UIBarButtonItem *payButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleDone target:self action:@selector(pay)]; - payButton.enabled = paymentTextField.isValid; - self.navigationItem.rightBarButtonItem = payButton; - - UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; - activityIndicator.hidesWhenStopped = YES; - self.activityIndicator = activityIndicator; - [self.view addSubview:activityIndicator]; -} - -- (void)viewDidAppear:(BOOL)animated { - [super viewDidAppear:animated]; - [self.paymentTextField becomeFirstResponder]; -} - -- (void)viewDidLayoutSubviews { - [super viewDidLayoutSubviews]; - CGFloat padding = 15; - CGFloat width = CGRectGetWidth(self.view.frame) - (padding*2); - CGRect bounds = self.view.bounds; - self.paymentTextField.frame = CGRectMake(padding, padding, width, 44); - self.activityIndicator.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.paymentTextField.frame) + padding*2); - self.waitingLabel.center = CGPointMake(CGRectGetMidX(bounds), - CGRectGetMaxY(self.activityIndicator.frame) + padding*2); -} - -- (void)updateUIForPaymentInProgress:(BOOL)paymentInProgress { - self.navigationController.navigationBar.userInteractionEnabled = !paymentInProgress; - self.navigationItem.rightBarButtonItem.enabled = !paymentInProgress; - self.paymentTextField.userInteractionEnabled = !paymentInProgress; - [UIView animateWithDuration:0.2 animations:^{ - self.waitingLabel.alpha = paymentInProgress ? 1 : 0; - }]; - if (paymentInProgress) { - [self.activityIndicator startAnimating]; - } else { - [self.activityIndicator stopAnimating]; - } -} - -- (void)paymentCardTextFieldDidChange:(nonnull STPPaymentCardTextField *)textField { - self.navigationItem.rightBarButtonItem.enabled = textField.isValid; -} - -- (void)pay { - if (![self.paymentTextField isValid]) { - return; - } - if (![Stripe defaultPublishableKey]) { - [self.delegate exampleViewController:self didFinishWithMessage:@"Please set a Stripe Publishable Key in Constants.m"]; - return; - } - [self updateUIForPaymentInProgress:YES]; - [[MyAPIClient sharedClient] createSetupIntentWithCompletion:^(MyAPIClientResult status, NSString *clientSecret, NSError *error) { - if (status == MyAPIClientResultFailure || clientSecret == nil) { - [self.delegate exampleViewController:self didFinishWithError:error]; - return; - } - STPSetupIntentConfirmParams *setupIntentConfirmParams = [[STPSetupIntentConfirmParams alloc] initWithClientSecret:clientSecret]; - setupIntentConfirmParams.paymentMethodParams = [STPPaymentMethodParams paramsWithCard:self.paymentTextField.cardParams - billingDetails:nil - metadata:nil]; - setupIntentConfirmParams.returnURL = @"payments-example://stripe-redirect"; - [[STPPaymentHandler sharedHandler] confirmSetupIntent:setupIntentConfirmParams - withAuthenticationContext:self.delegate - completion:^(STPPaymentHandlerActionStatus handlerStatus, STPSetupIntent * _Nullable handledIntent, NSError * _Nullable handlerError) { - switch (handlerStatus) { - case STPPaymentHandlerActionStatusSucceeded: - [self.delegate exampleViewController:self didFinishWithMessage:@"SetupIntent successfully created"]; - break; - case STPPaymentHandlerActionStatusCanceled: - [self.delegate exampleViewController:self didFinishWithMessage:@"Cancelled"]; - break; - case STPPaymentHandlerActionStatusFailed: - [self.delegate exampleViewController:self didFinishWithError:handlerError]; - break; - } - }]; - - }]; -} - -@end diff --git a/Example/Custom Integration.xcodeproj/project.pbxproj b/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj similarity index 83% rename from Example/Custom Integration.xcodeproj/project.pbxproj rename to Example/Non-Card Payment Examples.xcodeproj/project.pbxproj index 10c53298761..6174c522c34 100644 --- a/Example/Custom Integration.xcodeproj/project.pbxproj +++ b/Example/Non-Card Payment Examples.xcodeproj/project.pbxproj @@ -21,15 +21,11 @@ 36B6CB5A234BE3FA00331C38 /* PaymentExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB59234BE3FA00331C38 /* PaymentExampleViewController.m */; }; 36B6CB5D234BEB8400331C38 /* SEPADebitExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB5C234BEB8400331C38 /* SEPADebitExampleViewController.m */; }; 36B6CB64234FD9AA00331C38 /* iDEALExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */; }; - 36D4EA6422DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36D4EA6322DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.m */; }; 8BBD79C6207FD2F900F85BED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8BBD79C8207FD2F900F85BED /* Localizable.strings */; }; - B3BDCADD20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B3BDCADB20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m */; }; B607FFBD2321DA99004203E0 /* MyAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = B607FFBC2321DA99004203E0 /* MyAPIClient.m */; }; B65E8FCC22FA078A0057E64A /* WeChatPayExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */; }; - B66AC61E22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B66AC61D22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m */; }; B6C1FC832330432E0097FC4C /* AlipayExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6C1FC822330432E0097FC4C /* AlipayExampleViewController.swift */; }; C12C50DD1E57B3C800EC6D58 /* BrowseExamplesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C12C50DC1E57B3C800EC6D58 /* BrowseExamplesViewController.m */; }; - C1CACE861E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CACE851E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.m */; }; C1CACE891E5DF7A9002D0821 /* ApplePayExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CACE881E5DF7A9002D0821 /* ApplePayExampleViewController.m */; }; C1CACE941E5E3DF6002D0821 /* SofortExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C1CACE931E5E3DF6002D0821 /* SofortExampleViewController.m */; }; /* End PBXBuildFile section */ @@ -49,7 +45,7 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 04533E871A687F5D00C7E52E /* Custom Integration.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Custom Integration.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 04533E871A687F5D00C7E52E /* Non-Card Payment Examples.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Non-Card Payment Examples.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 04533E8B1A687F5D00C7E52E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 04533E8C1A687F5D00C7E52E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 04533E8E1A687F5D00C7E52E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -64,15 +60,13 @@ 04533F181A688A0A00C7E52E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Constants.m; sourceTree = ""; }; 31A8934B230F6ABD007ABE37 /* FPXExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FPXExampleViewController.h; sourceTree = ""; }; 31A8934C230F6ABD007ABE37 /* FPXExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FPXExampleViewController.m; sourceTree = ""; }; - 366F93AF225FF2A2005CFBF6 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "Custom Integration/README.md"; sourceTree = ""; }; + 366F93AF225FF2A2005CFBF6 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = "Non-Card Payment Examples/README.md"; sourceTree = ""; }; 36B6CB58234BE3FA00331C38 /* PaymentExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentExampleViewController.h; sourceTree = ""; }; 36B6CB59234BE3FA00331C38 /* PaymentExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PaymentExampleViewController.m; sourceTree = ""; }; 36B6CB5B234BEB8400331C38 /* SEPADebitExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SEPADebitExampleViewController.h; sourceTree = ""; }; 36B6CB5C234BEB8400331C38 /* SEPADebitExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SEPADebitExampleViewController.m; sourceTree = ""; }; 36B6CB62234FD9AA00331C38 /* iDEALExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = iDEALExampleViewController.h; sourceTree = ""; }; 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iDEALExampleViewController.m; sourceTree = ""; }; - 36D4EA6222DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CardSetupIntentBackendExampleViewController.h; sourceTree = ""; }; - 36D4EA6322DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CardSetupIntentBackendExampleViewController.m; sourceTree = ""; }; 8BBD79C7207FD2F900F85BED /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; 8BBD79C9207FD31A00F85BED /* zh-Hans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = ""; }; 8BBD79CA207FD32100F85BED /* nl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = ""; }; @@ -83,20 +77,14 @@ 8BBD79CF207FD34200F85BED /* ja */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/Localizable.strings; sourceTree = ""; }; 8BBD79D0207FD34A00F85BED /* nb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = nb; path = nb.lproj/Localizable.strings; sourceTree = ""; }; 8BBD79D1207FD35200F85BED /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = ""; }; - B3BDCADB20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CardAutomaticConfirmationViewController.m; sourceTree = ""; }; - B3BDCADC20EF03010034F7F5 /* CardAutomaticConfirmationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CardAutomaticConfirmationViewController.h; sourceTree = ""; }; B607FFBB2321DA99004203E0 /* MyAPIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyAPIClient.h; sourceTree = ""; }; B607FFBC2321DA99004203E0 /* MyAPIClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyAPIClient.m; sourceTree = ""; }; B65E8FCA22FA078A0057E64A /* WeChatPayExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeChatPayExampleViewController.h; sourceTree = ""; }; B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WeChatPayExampleViewController.m; sourceTree = ""; }; - B66AC61C22CAAB8F0064C551 /* CardSetupIntentExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CardSetupIntentExampleViewController.h; sourceTree = ""; }; - B66AC61D22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CardSetupIntentExampleViewController.m; sourceTree = ""; }; - B6C1FC812330432E0097FC4C /* Custom Integration-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Custom Integration-Bridging-Header.h"; sourceTree = ""; }; + B6C1FC812330432E0097FC4C /* Non-Card Payment Examples-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Non-Card Payment Examples-Bridging-Header.h"; sourceTree = ""; }; B6C1FC822330432E0097FC4C /* AlipayExampleViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlipayExampleViewController.swift; sourceTree = ""; }; C12C50DB1E57B3C800EC6D58 /* BrowseExamplesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BrowseExamplesViewController.h; sourceTree = ""; }; C12C50DC1E57B3C800EC6D58 /* BrowseExamplesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BrowseExamplesViewController.m; sourceTree = ""; }; - C1CACE841E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CardManualConfirmationExampleViewController.h; sourceTree = ""; }; - C1CACE851E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CardManualConfirmationExampleViewController.m; sourceTree = ""; }; C1CACE871E5DF7A9002D0821 /* ApplePayExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplePayExampleViewController.h; sourceTree = ""; }; C1CACE881E5DF7A9002D0821 /* ApplePayExampleViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplePayExampleViewController.m; sourceTree = ""; }; C1CACE921E5E3DF6002D0821 /* SofortExampleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SofortExampleViewController.h; sourceTree = ""; }; @@ -120,23 +108,22 @@ 04533E7E1A687F5D00C7E52E = { isa = PBXGroup; children = ( - 04533E891A687F5D00C7E52E /* Custom Integration */, + 04533E891A687F5D00C7E52E /* Non-Card Payment Examples */, 04533F0E1A68813100C7E52E /* Frameworks */, 04533E881A687F5D00C7E52E /* Products */, 366F93AF225FF2A2005CFBF6 /* README.md */, - B6C1FC812330432E0097FC4C /* Custom Integration-Bridging-Header.h */, ); sourceTree = ""; }; 04533E881A687F5D00C7E52E /* Products */ = { isa = PBXGroup; children = ( - 04533E871A687F5D00C7E52E /* Custom Integration.app */, + 04533E871A687F5D00C7E52E /* Non-Card Payment Examples.app */, ); name = Products; sourceTree = ""; }; - 04533E891A687F5D00C7E52E /* Custom Integration */ = { + 04533E891A687F5D00C7E52E /* Non-Card Payment Examples */ = { isa = PBXGroup; children = ( B6C1FC822330432E0097FC4C /* AlipayExampleViewController.swift */, @@ -146,18 +133,13 @@ C1CACE881E5DF7A9002D0821 /* ApplePayExampleViewController.m */, C12C50DB1E57B3C800EC6D58 /* BrowseExamplesViewController.h */, C12C50DC1E57B3C800EC6D58 /* BrowseExamplesViewController.m */, - B3BDCADC20EF03010034F7F5 /* CardAutomaticConfirmationViewController.h */, - B3BDCADB20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m */, - C1CACE841E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.h */, - C1CACE851E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.m */, - 36D4EA6222DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.h */, - 36D4EA6322DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.m */, - B66AC61C22CAAB8F0064C551 /* CardSetupIntentExampleViewController.h */, - B66AC61D22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m */, 04533F171A688A0A00C7E52E /* Constants.h */, 04533F181A688A0A00C7E52E /* Constants.m */, + B6C1FC812330432E0097FC4C /* Non-Card Payment Examples-Bridging-Header.h */, 31A8934B230F6ABD007ABE37 /* FPXExampleViewController.h */, 31A8934C230F6ABD007ABE37 /* FPXExampleViewController.m */, + 36B6CB62234FD9AA00331C38 /* iDEALExampleViewController.h */, + 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */, 04533E971A687F5D00C7E52E /* Images.xcassets */, 8BBD79C8207FD2F900F85BED /* Localizable.strings */, B607FFBB2321DA99004203E0 /* MyAPIClient.h */, @@ -173,10 +155,8 @@ 04533E8A1A687F5D00C7E52E /* Supporting Files */, B65E8FCA22FA078A0057E64A /* WeChatPayExampleViewController.h */, B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */, - 36B6CB62234FD9AA00331C38 /* iDEALExampleViewController.h */, - 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */, ); - path = "Custom Integration"; + path = "Non-Card Payment Examples"; sourceTree = ""; }; 04533E8A1A687F5D00C7E52E /* Supporting Files */ = { @@ -201,9 +181,9 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 04533E861A687F5D00C7E52E /* Custom Integration */ = { + 04533E861A687F5D00C7E52E /* Non-Card Payment Examples */ = { isa = PBXNativeTarget; - buildConfigurationList = 04533EAA1A687F5E00C7E52E /* Build configuration list for PBXNativeTarget "Custom Integration" */; + buildConfigurationList = 04533EAA1A687F5E00C7E52E /* Build configuration list for PBXNativeTarget "Non-Card Payment Examples" */; buildPhases = ( 04533E831A687F5D00C7E52E /* Sources */, 04533E841A687F5D00C7E52E /* Frameworks */, @@ -215,9 +195,9 @@ ); dependencies = ( ); - name = "Custom Integration"; - productName = "Custom Integration (ObjC)"; - productReference = 04533E871A687F5D00C7E52E /* Custom Integration.app */; + name = "Non-Card Payment Examples"; + productName = "Non-Card Payment Examples"; + productReference = 04533E871A687F5D00C7E52E /* Non-Card Payment Examples.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -236,7 +216,7 @@ }; }; }; - buildConfigurationList = 04533E821A687F5D00C7E52E /* Build configuration list for PBXProject "Custom Integration" */; + buildConfigurationList = 04533E821A687F5D00C7E52E /* Build configuration list for PBXProject "Non-Card Payment Examples" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -258,7 +238,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - 04533E861A687F5D00C7E52E /* Custom Integration */, + 04533E861A687F5D00C7E52E /* Non-Card Payment Examples */, ); }; /* End PBXProject section */ @@ -305,11 +285,7 @@ 36B6CB64234FD9AA00331C38 /* iDEALExampleViewController.m in Sources */, 04533F191A688A0A00C7E52E /* Constants.m in Sources */, C1CACE941E5E3DF6002D0821 /* SofortExampleViewController.m in Sources */, - C1CACE861E5DE6C3002D0821 /* CardManualConfirmationExampleViewController.m in Sources */, 04533EB21A68802E00C7E52E /* ShippingManager.m in Sources */, - B3BDCADD20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m in Sources */, - B66AC61E22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m in Sources */, - 36D4EA6422DFEF1300619BA8 /* CardSetupIntentBackendExampleViewController.m in Sources */, 04533E901A687F5D00C7E52E /* AppDelegate.m in Sources */, B65E8FCC22FA078A0057E64A /* WeChatPayExampleViewController.m in Sources */, 36B6CB5A234BE3FA00331C38 /* PaymentExampleViewController.m in Sources */, @@ -470,6 +446,7 @@ CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -480,12 +457,12 @@ "$(inherited)", "$(PROJECT_DIR)/**", ); - INFOPLIST_FILE = "$(SRCROOT)/Custom Integration/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Non-Card Payment Examples/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.CustomSDKExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Custom Integration-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Non-Card Payment Examples/Non-Card Payment Examples-Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; @@ -499,6 +476,7 @@ CLANG_ENABLE_MODULES = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEBUG_INFORMATION_FORMAT = dwarf; + DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -509,12 +487,12 @@ "$(inherited)", "$(PROJECT_DIR)/**", ); - INFOPLIST_FILE = "$(SRCROOT)/Custom Integration/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Non-Card Payment Examples/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 11.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.stripe.CustomSDKExample; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_OBJC_BRIDGING_HEADER = "Custom Integration-Bridging-Header.h"; + SWIFT_OBJC_BRIDGING_HEADER = "Non-Card Payment Examples/Non-Card Payment Examples-Bridging-Header.h"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -523,7 +501,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 04533E821A687F5D00C7E52E /* Build configuration list for PBXProject "Custom Integration" */ = { + 04533E821A687F5D00C7E52E /* Build configuration list for PBXProject "Non-Card Payment Examples" */ = { isa = XCConfigurationList; buildConfigurations = ( 04533EA81A687F5E00C7E52E /* Debug */, @@ -532,7 +510,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 04533EAA1A687F5E00C7E52E /* Build configuration list for PBXNativeTarget "Custom Integration" */ = { + 04533EAA1A687F5E00C7E52E /* Build configuration list for PBXNativeTarget "Non-Card Payment Examples" */ = { isa = XCConfigurationList; buildConfigurations = ( 04533EAB1A687F5E00C7E52E /* Debug */, diff --git a/Example/Custom Integration.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Example/Non-Card Payment Examples.xcodeproj/project.xcworkspace/contents.xcworkspacedata similarity index 100% rename from Example/Custom Integration.xcodeproj/project.xcworkspace/contents.xcworkspacedata rename to Example/Non-Card Payment Examples.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/Example/Custom Integration.xcodeproj/xcshareddata/xcschemes/Custom Integration.xcscheme b/Example/Non-Card Payment Examples.xcodeproj/xcshareddata/xcschemes/Non-Card Payment Examples.xcscheme similarity index 79% rename from Example/Custom Integration.xcodeproj/xcshareddata/xcschemes/Custom Integration.xcscheme rename to Example/Non-Card Payment Examples.xcodeproj/xcshareddata/xcschemes/Non-Card Payment Examples.xcscheme index 6e881c5ff41..9e3ddb40bbd 100644 --- a/Example/Custom Integration.xcodeproj/xcshareddata/xcschemes/Custom Integration.xcscheme +++ b/Example/Non-Card Payment Examples.xcodeproj/xcshareddata/xcschemes/Non-Card Payment Examples.xcscheme @@ -15,9 +15,9 @@ + BuildableName = "Non-Card Payment Examples.app" + BlueprintName = "Non-Card Payment Examples" + ReferencedContainer = "container:Non-Card Payment Examples.xcodeproj"> @@ -43,9 +43,9 @@ + BuildableName = "Non-Card Payment Examples.app" + BlueprintName = "Non-Card Payment Examples" + ReferencedContainer = "container:Non-Card Payment Examples.xcodeproj"> @@ -66,9 +66,9 @@ + BuildableName = "Non-Card Payment Examples.app" + BlueprintName = "Non-Card Payment Examples" + ReferencedContainer = "container:Non-Card Payment Examples.xcodeproj"> @@ -85,9 +85,9 @@ + BuildableName = "Non-Card Payment Examples.app" + BlueprintName = "Non-Card Payment Examples" + ReferencedContainer = "container:Non-Card Payment Examples.xcodeproj"> diff --git a/Example/Custom Integration/AlipayExampleViewController.swift b/Example/Non-Card Payment Examples/AlipayExampleViewController.swift similarity index 97% rename from Example/Custom Integration/AlipayExampleViewController.swift rename to Example/Non-Card Payment Examples/AlipayExampleViewController.swift index 0cd8c2a8d34..9dc143ec021 100644 --- a/Example/Custom Integration/AlipayExampleViewController.swift +++ b/Example/Non-Card Payment Examples/AlipayExampleViewController.swift @@ -1,6 +1,6 @@ // // AlipayExampleViewController.swift -// Custom Integration +// Non-Card Payment Examples // // Created by Yuki Tokuhiro on 9/16/19. // Copyright © 2019 Stripe. All rights reserved. @@ -76,7 +76,7 @@ extension AlipayExampleViewController { // If the customer has the Alipay app installed, we open it. // Otherwise, we open alipay.com. self.redirectContext = STPRedirectContext(source: source) { sourceID, clientSecret, error in - guard let clientSecret = clientSecret else { + guard error == nil else { self.delegate?.exampleViewController(self, didFinishWithError: error) return } diff --git a/Example/Custom Integration/AppDelegate.h b/Example/Non-Card Payment Examples/AppDelegate.h similarity index 89% rename from Example/Custom Integration/AppDelegate.h rename to Example/Non-Card Payment Examples/AppDelegate.h index 8dac9f4497a..69b857e6050 100644 --- a/Example/Custom Integration/AppDelegate.h +++ b/Example/Non-Card Payment Examples/AppDelegate.h @@ -1,6 +1,6 @@ // // AppDelegate.h -// Custom Integration +// Non-Card Payment Examples // // Created by Jack Flintermann on 1/15/15. // Copyright (c) 2015 Stripe. All rights reserved. diff --git a/Example/Custom Integration/AppDelegate.m b/Example/Non-Card Payment Examples/AppDelegate.m similarity index 100% rename from Example/Custom Integration/AppDelegate.m rename to Example/Non-Card Payment Examples/AppDelegate.m diff --git a/Example/Custom Integration/ApplePayExampleViewController.h b/Example/Non-Card Payment Examples/ApplePayExampleViewController.h similarity index 91% rename from Example/Custom Integration/ApplePayExampleViewController.h rename to Example/Non-Card Payment Examples/ApplePayExampleViewController.h index 256b6598260..1fcfc926c24 100644 --- a/Example/Custom Integration/ApplePayExampleViewController.h +++ b/Example/Non-Card Payment Examples/ApplePayExampleViewController.h @@ -1,6 +1,6 @@ // // ApplePayExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/22/17. // Copyright © 2017 Stripe. All rights reserved. diff --git a/Example/Custom Integration/ApplePayExampleViewController.m b/Example/Non-Card Payment Examples/ApplePayExampleViewController.m similarity index 99% rename from Example/Custom Integration/ApplePayExampleViewController.m rename to Example/Non-Card Payment Examples/ApplePayExampleViewController.m index 3ba5b4b5f67..657bcd5f850 100644 --- a/Example/Custom Integration/ApplePayExampleViewController.m +++ b/Example/Non-Card Payment Examples/ApplePayExampleViewController.m @@ -1,6 +1,6 @@ // // ApplePayExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/22/17. // Copyright © 2017 Stripe. All rights reserved. diff --git a/Example/Custom Integration/BrowseExamplesViewController.h b/Example/Non-Card Payment Examples/BrowseExamplesViewController.h similarity index 94% rename from Example/Custom Integration/BrowseExamplesViewController.h rename to Example/Non-Card Payment Examples/BrowseExamplesViewController.h index e9c90b4a760..8b1f0e73d14 100644 --- a/Example/Custom Integration/BrowseExamplesViewController.h +++ b/Example/Non-Card Payment Examples/BrowseExamplesViewController.h @@ -1,6 +1,6 @@ // // BrowseExamplesViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/17/17. // Copyright © 2017 Stripe. All rights reserved. diff --git a/Example/Custom Integration/BrowseExamplesViewController.m b/Example/Non-Card Payment Examples/BrowseExamplesViewController.m similarity index 76% rename from Example/Custom Integration/BrowseExamplesViewController.m rename to Example/Non-Card Payment Examples/BrowseExamplesViewController.m index b58f825b1d4..fce4f0d1c3b 100644 --- a/Example/Custom Integration/BrowseExamplesViewController.m +++ b/Example/Non-Card Payment Examples/BrowseExamplesViewController.m @@ -1,21 +1,17 @@ // // BrowseExamplesViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/17/17. // Copyright © 2017 Stripe. All rights reserved. // #import -#import "Custom_Integration-Swift.h" +#import "Non_Card_Payment_Examples-Swift.h" #import "BrowseExamplesViewController.h" #import "ApplePayExampleViewController.h" -#import "CardAutomaticConfirmationViewController.h" -#import "CardManualConfirmationExampleViewController.h" -#import "CardSetupIntentBackendExampleViewController.h" -#import "CardSetupIntentExampleViewController.h" #import "iDEALExampleViewController.h" #import "SofortExampleViewController.h" #import "FPXExampleViewController.h" @@ -42,43 +38,31 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - return 11; + return 7; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [UITableViewCell new]; switch (indexPath.row) { case 0: - cell.textLabel.text = @"Card (Automatic Confirmation)"; - break; - case 1: - cell.textLabel.text = @"Card (Manual Confirmation)"; - break; - case 2: - cell.textLabel.text = @"Card (SetupIntent)"; - break; - case 3: - cell.textLabel.text = @"Card (SetupIntent Backend Confirm)"; - break; - case 4: cell.textLabel.text = @"Apple Pay"; break; - case 5: + case 1: cell.textLabel.text = @"Sofort (Sources)"; break; - case 6: + case 2: cell.textLabel.text = @"WeChat Pay (Sources)"; break; - case 7: + case 3: cell.textLabel.text = @"FPX"; break; - case 8: + case 4: cell.textLabel.text = @"SEPA Debit"; break; - case 9: + case 5: cell.textLabel.text = @"iDEAL"; break; - case 10: + case 6: cell.textLabel.text = @"Alipay"; break; } @@ -88,67 +72,43 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UIViewController *viewController; switch (indexPath.row) { - case 0: { - CardAutomaticConfirmationViewController *exampleVC = [CardAutomaticConfirmationViewController new]; - exampleVC.delegate = self; - viewController = exampleVC; - break; - } case 1: { - CardManualConfirmationExampleViewController *exampleVC = [CardManualConfirmationExampleViewController new]; - exampleVC.delegate = self; - viewController = exampleVC; - break; - } - case 2: { - CardSetupIntentExampleViewController *exampleVC = [CardSetupIntentExampleViewController new]; - exampleVC.delegate = self; - viewController = exampleVC; - break; - } - case 3: { - CardSetupIntentBackendExampleViewController *exampleVC = [CardSetupIntentBackendExampleViewController new]; - exampleVC.delegate = self; - viewController = exampleVC; - break; - } - case 4: { ApplePayExampleViewController *exampleVC = [ApplePayExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 5: { + case 2: { SofortExampleViewController *exampleVC = [SofortExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 6: { + case 3: { WeChatPayExampleViewController *exampleVC = [WeChatPayExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 7: { + case 4: { FPXExampleViewController *exampleVC = [FPXExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 8: { + case 5: { SEPADebitExampleViewController *exampleVC = [SEPADebitExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 9: { + case 6: { iDEALExampleViewController *exampleVC = [iDEALExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; break; } - case 10: { + case 7: { AlipayExampleViewController *exampleVC = [AlipayExampleViewController new]; exampleVC.delegate = self; viewController = exampleVC; diff --git a/Example/Custom Integration/Constants.h b/Example/Non-Card Payment Examples/Constants.h similarity index 100% rename from Example/Custom Integration/Constants.h rename to Example/Non-Card Payment Examples/Constants.h diff --git a/Example/Custom Integration/Constants.m b/Example/Non-Card Payment Examples/Constants.m similarity index 100% rename from Example/Custom Integration/Constants.m rename to Example/Non-Card Payment Examples/Constants.m diff --git a/Example/Custom Integration/FPXExampleViewController.h b/Example/Non-Card Payment Examples/FPXExampleViewController.h similarity index 91% rename from Example/Custom Integration/FPXExampleViewController.h rename to Example/Non-Card Payment Examples/FPXExampleViewController.h index d849e4aeb04..e06a9124969 100644 --- a/Example/Custom Integration/FPXExampleViewController.h +++ b/Example/Non-Card Payment Examples/FPXExampleViewController.h @@ -1,6 +1,6 @@ // // FPXExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by David Estes on 8/26/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/FPXExampleViewController.m b/Example/Non-Card Payment Examples/FPXExampleViewController.m similarity index 99% rename from Example/Custom Integration/FPXExampleViewController.m rename to Example/Non-Card Payment Examples/FPXExampleViewController.m index b32429c643e..24115dada17 100644 --- a/Example/Custom Integration/FPXExampleViewController.m +++ b/Example/Non-Card Payment Examples/FPXExampleViewController.m @@ -1,6 +1,6 @@ // // FPXExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by David Estes on 8/26/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Non-Card Payment Examples/Images.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Example/Custom Integration/Images.xcassets/AppIcon.appiconset/Contents.json rename to Example/Non-Card Payment Examples/Images.xcassets/AppIcon.appiconset/Contents.json diff --git a/Example/Custom Integration/Images.xcassets/Contents.json b/Example/Non-Card Payment Examples/Images.xcassets/Contents.json similarity index 100% rename from Example/Custom Integration/Images.xcassets/Contents.json rename to Example/Non-Card Payment Examples/Images.xcassets/Contents.json diff --git a/Example/Custom Integration/Images.xcassets/LaunchImage.launchimage/Contents.json b/Example/Non-Card Payment Examples/Images.xcassets/LaunchImage.launchimage/Contents.json similarity index 100% rename from Example/Custom Integration/Images.xcassets/LaunchImage.launchimage/Contents.json rename to Example/Non-Card Payment Examples/Images.xcassets/LaunchImage.launchimage/Contents.json diff --git a/Example/Custom Integration/Info.plist b/Example/Non-Card Payment Examples/Info.plist similarity index 100% rename from Example/Custom Integration/Info.plist rename to Example/Non-Card Payment Examples/Info.plist diff --git a/Example/Custom Integration/MyAPIClient.h b/Example/Non-Card Payment Examples/MyAPIClient.h similarity index 99% rename from Example/Custom Integration/MyAPIClient.h rename to Example/Non-Card Payment Examples/MyAPIClient.h index c3e053135a1..7469008e847 100644 --- a/Example/Custom Integration/MyAPIClient.h +++ b/Example/Non-Card Payment Examples/MyAPIClient.h @@ -1,6 +1,6 @@ // // ExampleAPIClient.h -// Custom Integration +// Non-Card Payment Examples // // Created by Yuki Tokuhiro on 9/5/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/MyAPIClient.m b/Example/Non-Card Payment Examples/MyAPIClient.m similarity index 99% rename from Example/Custom Integration/MyAPIClient.m rename to Example/Non-Card Payment Examples/MyAPIClient.m index 81ad6551ca4..3d9727b8366 100644 --- a/Example/Custom Integration/MyAPIClient.m +++ b/Example/Non-Card Payment Examples/MyAPIClient.m @@ -1,6 +1,6 @@ // // ExampleAPIClient.m -// Custom Integration +// Non-Card Payment Examples // // Created by Yuki Tokuhiro on 9/5/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration-Bridging-Header.h b/Example/Non-Card Payment Examples/Non-Card Payment Examples-Bridging-Header.h similarity index 100% rename from Example/Custom Integration-Bridging-Header.h rename to Example/Non-Card Payment Examples/Non-Card Payment Examples-Bridging-Header.h diff --git a/Example/Custom Integration/PaymentExampleViewController.h b/Example/Non-Card Payment Examples/PaymentExampleViewController.h similarity index 95% rename from Example/Custom Integration/PaymentExampleViewController.h rename to Example/Non-Card Payment Examples/PaymentExampleViewController.h index a5dd95630d5..c6aba2721cc 100644 --- a/Example/Custom Integration/PaymentExampleViewController.h +++ b/Example/Non-Card Payment Examples/PaymentExampleViewController.h @@ -1,6 +1,6 @@ // // PaymentExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/7/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/PaymentExampleViewController.m b/Example/Non-Card Payment Examples/PaymentExampleViewController.m similarity index 99% rename from Example/Custom Integration/PaymentExampleViewController.m rename to Example/Non-Card Payment Examples/PaymentExampleViewController.m index e1a34264084..7f013b9accc 100644 --- a/Example/Custom Integration/PaymentExampleViewController.m +++ b/Example/Non-Card Payment Examples/PaymentExampleViewController.m @@ -1,6 +1,6 @@ // // PaymentExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/7/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/README.md b/Example/Non-Card Payment Examples/README.md similarity index 63% rename from Example/Custom Integration/README.md rename to Example/Non-Card Payment Examples/README.md index b60efe7156f..09c05e89a8d 100644 --- a/Example/Custom Integration/README.md +++ b/Example/Non-Card Payment Examples/README.md @@ -1,12 +1,12 @@ -# Custom Integration +# Non-Card Payment Examples -This example app demonstrates how to use `STPAPIClient` to accept various payment methods. This may be a useful reference if you're building your own payment flow and not using `STPPaymentContext`. +This example app demonstrates how to use `STPAPIClient` to accept various non-card payment methods. This may be a useful reference if you're building your own payment flow and not using `STPPaymentContext`. For examples of accepting cards, check out [stripe-samples](https://github.com/stripe-samples/accept-a-card-payment). -For a detailed guide, see https://stripe.com/docs/mobile/ios/custom +To run this app: 1. If you haven't already, sign up for a [Stripe account](https://dashboard.stripe.com/register) (it takes seconds). 2. Open `./Stripe.xcworkspace` (not `./Stripe.xcodeproj`) with Xcode -3. Fill in the `stripePublishableKey` constant in `./Example/Custom Integration/Constants.m` with your Stripe [test "Publishable key"](https://dashboard.stripe.com/account/apikeys.). This key should start with `pk_test`. +3. Fill in the `stripePublishableKey` constant in `./Example/Non-Card Payment Examples/Constants.m` with your Stripe [test "Publishable key"](https://dashboard.stripe.com/account/apikeys.). This key should start with `pk_test`. 4. Head to [example-ios-backend](https://github.com/stripe/example-ios-backend/tree/v18.1.0) and click "Deploy to Heroku". Provide your [Stripe test "Secret key"](https://dashboard.stripe.com/account/apikeys.) as the `STRIPE_TEST_SECRET_KEY` environment variable. This key should start with `sk_test`. 5. Fill in the `backendBaseURL` constant in `Constants.m` with the app URL Heroku provides (e.g. "https://my-example-app.herokuapp.com") diff --git a/Example/Custom Integration/SEPADebitExampleViewController.h b/Example/Non-Card Payment Examples/SEPADebitExampleViewController.h similarity index 91% rename from Example/Custom Integration/SEPADebitExampleViewController.h rename to Example/Non-Card Payment Examples/SEPADebitExampleViewController.h index 1a4de4de291..4adbc4d0aa9 100644 --- a/Example/Custom Integration/SEPADebitExampleViewController.h +++ b/Example/Non-Card Payment Examples/SEPADebitExampleViewController.h @@ -1,6 +1,6 @@ // // SEPADebitExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/7/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/SEPADebitExampleViewController.m b/Example/Non-Card Payment Examples/SEPADebitExampleViewController.m similarity index 99% rename from Example/Custom Integration/SEPADebitExampleViewController.m rename to Example/Non-Card Payment Examples/SEPADebitExampleViewController.m index 4b5c466963c..8ced4162660 100644 --- a/Example/Custom Integration/SEPADebitExampleViewController.m +++ b/Example/Non-Card Payment Examples/SEPADebitExampleViewController.m @@ -1,6 +1,6 @@ // // SEPADebitExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/7/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/ShippingManager.h b/Example/Non-Card Payment Examples/ShippingManager.h similarity index 100% rename from Example/Custom Integration/ShippingManager.h rename to Example/Non-Card Payment Examples/ShippingManager.h diff --git a/Example/Custom Integration/ShippingManager.m b/Example/Non-Card Payment Examples/ShippingManager.m similarity index 100% rename from Example/Custom Integration/ShippingManager.m rename to Example/Non-Card Payment Examples/ShippingManager.m diff --git a/Example/Custom Integration/SofortExampleViewController.h b/Example/Non-Card Payment Examples/SofortExampleViewController.h similarity index 91% rename from Example/Custom Integration/SofortExampleViewController.h rename to Example/Non-Card Payment Examples/SofortExampleViewController.h index 478f509cbc1..cfec17f730b 100644 --- a/Example/Custom Integration/SofortExampleViewController.h +++ b/Example/Non-Card Payment Examples/SofortExampleViewController.h @@ -1,6 +1,6 @@ // // SofortExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/22/17. // Copyright © 2017 Stripe. All rights reserved. diff --git a/Example/Custom Integration/SofortExampleViewController.m b/Example/Non-Card Payment Examples/SofortExampleViewController.m similarity index 99% rename from Example/Custom Integration/SofortExampleViewController.m rename to Example/Non-Card Payment Examples/SofortExampleViewController.m index dd3915095e8..d0d3e30cf7b 100644 --- a/Example/Custom Integration/SofortExampleViewController.m +++ b/Example/Non-Card Payment Examples/SofortExampleViewController.m @@ -1,6 +1,6 @@ // // SofortExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Ben Guo on 2/22/17. // Copyright © 2017 Stripe. All rights reserved. diff --git a/Example/Custom Integration/WeChatPayExampleViewController.h b/Example/Non-Card Payment Examples/WeChatPayExampleViewController.h similarity index 92% rename from Example/Custom Integration/WeChatPayExampleViewController.h rename to Example/Non-Card Payment Examples/WeChatPayExampleViewController.h index 87555bf9258..27a93597310 100644 --- a/Example/Custom Integration/WeChatPayExampleViewController.h +++ b/Example/Non-Card Payment Examples/WeChatPayExampleViewController.h @@ -1,6 +1,6 @@ // // WeChatPayExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Yuki Tokuhiro on 8/6/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/WeChatPayExampleViewController.m b/Example/Non-Card Payment Examples/WeChatPayExampleViewController.m similarity index 99% rename from Example/Custom Integration/WeChatPayExampleViewController.m rename to Example/Non-Card Payment Examples/WeChatPayExampleViewController.m index 7a00fb912b9..dd5118546d9 100644 --- a/Example/Custom Integration/WeChatPayExampleViewController.m +++ b/Example/Non-Card Payment Examples/WeChatPayExampleViewController.m @@ -1,6 +1,6 @@ // // WeChatPayExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Yuki Tokuhiro on 8/6/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/de.lproj/Localizable.strings b/Example/Non-Card Payment Examples/de.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/de.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/de.lproj/Localizable.strings diff --git a/Example/Custom Integration/en.lproj/Localizable.strings b/Example/Non-Card Payment Examples/en.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/en.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/en.lproj/Localizable.strings diff --git a/Example/Custom Integration/es.lproj/Localizable.strings b/Example/Non-Card Payment Examples/es.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/es.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/es.lproj/Localizable.strings diff --git a/Example/Custom Integration/fi.lproj/Localizable.strings b/Example/Non-Card Payment Examples/fi.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/fi.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/fi.lproj/Localizable.strings diff --git a/Example/Custom Integration/fr.lproj/Localizable.strings b/Example/Non-Card Payment Examples/fr.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/fr.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/fr.lproj/Localizable.strings diff --git a/Example/Custom Integration/iDEALExampleViewController.h b/Example/Non-Card Payment Examples/iDEALExampleViewController.h similarity index 90% rename from Example/Custom Integration/iDEALExampleViewController.h rename to Example/Non-Card Payment Examples/iDEALExampleViewController.h index 90aa71522a1..ff2b3313e06 100644 --- a/Example/Custom Integration/iDEALExampleViewController.h +++ b/Example/Non-Card Payment Examples/iDEALExampleViewController.h @@ -1,6 +1,6 @@ // // iDEALExampleViewController.h -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/10/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/iDEALExampleViewController.m b/Example/Non-Card Payment Examples/iDEALExampleViewController.m similarity index 98% rename from Example/Custom Integration/iDEALExampleViewController.m rename to Example/Non-Card Payment Examples/iDEALExampleViewController.m index a7694600416..c301a52045e 100644 --- a/Example/Custom Integration/iDEALExampleViewController.m +++ b/Example/Non-Card Payment Examples/iDEALExampleViewController.m @@ -1,6 +1,6 @@ // // iDEALExampleViewController.m -// Custom Integration +// Non-Card Payment Examples // // Created by Cameron Sabol on 10/10/19. // Copyright © 2019 Stripe. All rights reserved. diff --git a/Example/Custom Integration/it.lproj/Localizable.strings b/Example/Non-Card Payment Examples/it.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/it.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/it.lproj/Localizable.strings diff --git a/Example/Custom Integration/ja.lproj/Localizable.strings b/Example/Non-Card Payment Examples/ja.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/ja.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/ja.lproj/Localizable.strings diff --git a/Example/Custom Integration/main.m b/Example/Non-Card Payment Examples/main.m similarity index 91% rename from Example/Custom Integration/main.m rename to Example/Non-Card Payment Examples/main.m index 9bbf5b705a8..84c237af315 100644 --- a/Example/Custom Integration/main.m +++ b/Example/Non-Card Payment Examples/main.m @@ -1,6 +1,6 @@ // // main.m -// Custom Integration +// Non-Card Payment Examples // // Created by Jack Flintermann on 1/15/15. // Copyright (c) 2015 Stripe. All rights reserved. diff --git a/Example/Custom Integration/nb.lproj/Localizable.strings b/Example/Non-Card Payment Examples/nb.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/nb.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/nb.lproj/Localizable.strings diff --git a/Example/Custom Integration/nl.lproj/Localizable.strings b/Example/Non-Card Payment Examples/nl.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/nl.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/nl.lproj/Localizable.strings diff --git a/Example/Custom Integration/zh-Hans.lproj/Localizable.strings b/Example/Non-Card Payment Examples/zh-Hans.lproj/Localizable.strings similarity index 100% rename from Example/Custom Integration/zh-Hans.lproj/Localizable.strings rename to Example/Non-Card Payment Examples/zh-Hans.lproj/Localizable.strings diff --git a/Example/README.md b/Example/README.md index cd6c0398fc6..5b52cb88c24 100644 --- a/Example/README.md +++ b/Example/README.md @@ -1,7 +1,33 @@ # Example +Check out [stripe-samples](https://github.com/stripe-samples) for examples to: + +- [Accept a card payment](https://github.com/stripe-samples/accept-a-card-payment) (PaymentIntents API) +- [Accept a card payment](https://github.com/stripe-samples/card-payment-charges-api) (Charges API) +- [Save a card without payment](https://github.com/stripe-samples/mobile-saving-card-without-payment) (SetupIntents API) + There are 3 example apps included in the repository: -- [**UI Examples** Example/UI Examples/README.md ](/Example/UI%20Examples/README.md) -- [**Basic Integration** Example/Basic Integration/README.md](/Example/Basic%20Integration/README.md) -- [**Custom Integration** Example/Custom Integration/README.md](/Example/Custom%20Integration/README.md) +## [**UI Examples** Example/UI Examples/README.md ](/Example/UI%20Examples/README.md) +This example app lets you quickly try out the SDK's prebuilt UI components. + + +## [**Basic Integration**](/Example/Basic%20Integration/README.md) +

+STPPaymentCardTextField +

+ +This example app demonstrates how to build a payment flow using our prebuilt UI component integration. + + +## [**Non-Card Payment Examples**](/Example/Non-Card%20Payment%20Examples) +This example app demonstrates how to accept various payment methods: + +- Alipay +- Apple Pay +- FPX +- iDEAL +- SEPADebit +- Sofort +- WeChat Pay + diff --git a/Example/UI Examples/README.md b/Example/UI Examples/README.md index 8834537a698..aa5954135fa 100644 --- a/Example/UI Examples/README.md +++ b/Example/UI Examples/README.md @@ -2,7 +2,7 @@ This example app lets you try out the pre-built UI components we provide. -You can run it without any initial setup and it's a great place to start if you're evaluating whether you want to use our [Basic Integration](/Example/Basic%20Integration/README.md) or build your own [Custom Integration](/Example/Custom%20Integration/README.md). +You can run it without any initial setup and it's a great place to start if you're evaluating whether you want to use our [Basic Integration](/Example/Basic%20Integration/README.md) or use the UI components individually. 1. Open `./Stripe.xcworkspace` (not `./Stripe.xcodeproj`) with Xcode 2. Build and run the "UI Examples" scheme diff --git a/README.md b/README.md index f0951de8fca..10d74a3fd16 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,9 @@ [![CocoaPods](https://img.shields.io/cocoapods/l/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios/blob/master/LICENSE) [![CocoaPods](https://img.shields.io/cocoapods/p/Stripe.svg?style=flat)](https://github.com/stripe/stripe-ios#) -The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details. +The Stripe iOS SDK makes it quick and easy to build an excellent payment experience in your iOS app. We provide powerful and customizable UI screens and elements that can be used out-of-the-box to collect your users' payment details. We also expose the low-level APIs that power those UIs so that you can build fully custom experiences. -

-STPPaymentCardTextField -

- -We also expose the low-level APIs that power those UIs so that you can build fully custom experiences. See our [iOS Integration Guide](https://stripe.com/docs/mobile/ios/setup) to get started! +See our [📚 integration guides](https://stripe.com/docs/payments) to get started, or [📘 browse the SDK reference](https://stripe.dev/stripe-ios/docs/index.html). > Updating to a newer version of the SDK? See our [migration guide](https://github.com/stripe/stripe-ios/blob/master/MIGRATING.md) and [changelog](https://github.com/stripe/stripe-ios/blob/master/CHANGELOG.md). @@ -35,21 +31,29 @@ Table of contents **Simplified Security**: We make it simple for you to collect sensitive data such as credit card numbers and remain [PCI compliant](https://stripe.com/docs/security#pci-dss-guidelines). This means the sensitive data is sent directly to Stripe instead of passing through your server. For more information, see our [Integration Security Guide](https://stripe.com/docs/security). -**Apple Pay**: We provide a seamless integration with [Apple Pay](https://stripe.com/apple-pay). After [installing the SDK](https://stripe.com/docs/mobile/ios/setup), see our full guide to [accept Apple Pay in your iOS app](https://stripe.com/docs/apple-pay#native). +**Apple Pay**: We provide a [seamless integration with Apple Pay](https://stripe.com/docs/apple-pay). -**Native UI**: We provide out-of-the-box native screens and elements so that you can get started quickly without having to think about designing the right interfaces. For example, [STPPaymentCardTextField](https://stripe.com/docs/mobile/ios/custom#stppaymentcardtextfield) is a UIView that collects and validates card details. [STPAddCardViewController](https://stripe.com/docs/mobile/ios/custom#stpaddcardviewcontroller) is a UIViewController that also creates the Stripe API payment object for you. See our [Custom Integration Guide](https://stripe.com/docs/mobile/ios/custom). +**Stripe API**: We provide [low-level APIs](https://stripe.dev/stripe-ios/docs/Classes/STPAPIClient.html) that correspond to objects and methods in the Stripe API. You can build your own entirely custom UI on top of this layer, while still taking advantage of utilities like [STPCardValidator](https://stripe.dev/stripe-ios/docs/Classes/STPCardValidator.html) to validate your user’s input. + +**Native UI**: We provide native screens and elements to collect payment and shipping details. For example, [STPPaymentCardTextField](https://stripe.dev/stripe-ios/docs/Classes/STPPaymentCardTextField.html) is a UIView that collects and validates card details: + +

+STPPaymentCardTextField +

+ +You can use these individually, or take all of the prebuilt UI in one flow by following the [Basic Integration guide](https://stripe.com/docs/mobile/ios/basic).

STPAddCardViewControllerSTPPaymentOptionsViewControllerSTPShippingAddressViewController

-We also offer all of our UI components bundled into an all-in-one class designed to handle collecting, saving, and reusing your user’s payment details, as well as collecting shipping info. Take our entire checkout flow at once by following the [STPPaymentContext guide](https://stripe.com/docs/mobile/ios/standard). +From left to right: [STPAddCardViewController](https://stripe.dev/stripe-ios/docs/Classes/STPAddCardViewController.html), [STPPaymentOptionsViewController](https://stripe.dev/stripe-ios/docs/Classes/STPPaymentOptionsViewController.html), [STPShippingAddressViewController](https://stripe.dev/stripe-ios/docs/Classes/STPShippingAddressViewController.html) **Card Scanning**: We support card scanning capabilities using card.io. See our [Card IO](#card-io) section. ## Releases -We recommend that you install the Stripe iOS SDK using a package manager such as [Cocoapods or Carthage](https://stripe.com/docs/mobile/ios#getting-started). If you prefer to link the library manually, please use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page because we consider the master branch to be unstable. +We recommend installing the Stripe iOS SDK using a package manager such as Cocoapods or Carthage. If you link the library manually, use a version from our [releases](https://github.com/stripe/stripe-ios/releases) page. If you're reading this on GitHub.com, please make sure you are looking at the [tagged version](https://github.com/stripe/stripe-ios/tags) that corresponds to the release you have installed. Otherwise, the instructions and example code may be mismatched with your copy. You can read the latest tagged version of this README and browse the associated code on GitHub using [this link](https://github.com/stripe/stripe-ios/tree/v18.2.0). @@ -62,24 +66,31 @@ The Stripe iOS SDK requires Xcode 10.1 or later and is compatible with apps targ ### Integration -Please see our [iOS Integration Guide](https://stripe.com/docs/mobile/ios/setup) which explains SDK installation, collecting payment information, Apple Pay integration, and more. For more fine-grained documentation for all of the classes and methods, please see our full [Stripe iOS SDK Reference](http://stripe.github.io/stripe-ios/docs/index.html). +See our [📚 integration guides](https://stripe.com/docs/payments) to get started, or [browse the 📘 SDK reference](https://stripe.dev/stripe-ios/docs/index.html) for fine-grained documentation of all the classes and methods in the SDK. ### Examples There are 3 example apps included in the repository: -- [**UI Examples** Example/UI Examples/README.md ](/Example/UI%20Examples/README.md). - - This example lets you try out the pre-built UI components we provide. -- [**Custom Integration** Example/Custom Integration/README.md](/Example/Custom%20Integration/README.md) - - This example demonstrates how to uset push `STPAPIClient` to accept various payment methods. -- [**Basic Integration** Example/Basic Integration/README.md](/Example/Basic%20Integration/README.md) - - This example demonstrates how to build a payment flow using our pre-built UI component integration (`STPPaymentContext`). +- [UI Examples](/Example/UI%20Examples). + - This example lets you quickly try out the SDK's prebuilt UI components using a mock backend—just build and run! +- [Basic Integration](/Example/Basic%20Integration) + - This example demonstrates how to build a payment flow using our prebuilt UI component integration (`STPPaymentContext`). +- [Non-Card Payment Examples](/Example/Non-Card%20Payment%20Examples) + - This example demonstrates how to use `STPAPIClient` to accept various non-card payment methods. + +Check out [stripe-samples](https://github.com/stripe-samples/) for more, including: + +- [Accepting a card payment](https://github.com/stripe-samples/accept-a-card-payment) (PaymentIntents API) +- [Saving a card without payment](https://github.com/stripe-samples/mobile-saving-card-without-payment) (SetupIntents API) +- [Accepting a card payment](https://github.com/stripe-samples/card-payment-charges-api) (Charges API) + ## Card IO -To add card scanning capabilities to our prebuilt UI components, you can simply [install card.io](https://github.com/card-io/card.io-iOS-SDK#setup) alongside our SDK. You'll also need to set `NSCameraUsageDescription` in your application's plist, and provide a reason for accessing the camera (e.g. "To scan cards"). +To add card scanning capabilities to our prebuilt UI components, [install card.io](https://github.com/card-io/card.io-iOS-SDK#setup) alongside our SDK. You'll also need to set `NSCameraUsageDescription` in your application's plist, and provide a reason for accessing the camera (e.g. "To scan cards"). -To try this out, you can run `./install_cardio.rb`, which will download and install card.io in the Basic Integration project. Now, when you run the example app on a device, you'll see a "Scan Card" button when adding a new card. +Demo this in our [Basic Integration example app](/Example/Basic&20Integration) by running `./install_cardio.rb`, which will download and install card.io in the project. Now, when you run the example app on a device, you'll see a "Scan Card" button when adding a new card. ## Contributing diff --git a/STYLEGUIDE.md b/STYLEGUIDE.md index 9f3ccc698b3..91917ee5616 100644 --- a/STYLEGUIDE.md +++ b/STYLEGUIDE.md @@ -113,7 +113,7 @@ static NSString * const STPSDKVersion = @"11.0.0"; - `stripe-ios/Stripe/` - `stripe-ios/Tests/Tests/` - `stripe-ios/Example/Basic Integration/` - - `stripe-ios/Example/Custom Integration/` + - `stripe-ios/Example/Non-Card Payment Examples/` - Save public header files in `stripe-ios/Stripe/PublicHeaders/` for Cocoapods compatibility diff --git a/Stripe.xcworkspace/contents.xcworkspacedata b/Stripe.xcworkspace/contents.xcworkspacedata index 37ae3e5eb22..35c313e2ac8 100644 --- a/Stripe.xcworkspace/contents.xcworkspacedata +++ b/Stripe.xcworkspace/contents.xcworkspacedata @@ -11,6 +11,6 @@ location = "group:Example/Basic Integration.xcodeproj"> + location = "group:Example/Non-Card Payment Examples.xcodeproj"> diff --git a/ci_scripts/run_builds.sh b/ci_scripts/run_builds.sh index 22d18aff708..e6d80242b5d 100755 --- a/ci_scripts/run_builds.sh +++ b/ci_scripts/run_builds.sh @@ -37,7 +37,7 @@ fi xcodebuild build \ -workspace "Stripe.xcworkspace" \ - -scheme "Custom Integration" \ + -scheme "Non-Card Payment Examples" \ -sdk "iphonesimulator" \ -destination "platform=iOS Simulator,name=iPhone 7,OS=12.2" \ | xcpretty diff --git a/ui-examples.png b/ui-examples.png new file mode 100644 index 00000000000..9ad38a5bee4 Binary files /dev/null and b/ui-examples.png differ