Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples #1363

Merged
merged 13 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Example/Custom Integration.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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 */; };
C12C50DD1E57B3C800EC6D58 /* BrowseExamplesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C12C50DC1E57B3C800EC6D58 /* BrowseExamplesViewController.m */; };
Expand Down Expand Up @@ -74,6 +75,8 @@
8BBD79D1207FD35200F85BED /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
B3BDCADB20EF03010034F7F5 /* CardAutomaticConfirmationViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CardAutomaticConfirmationViewController.m; sourceTree = "<group>"; };
B3BDCADC20EF03010034F7F5 /* CardAutomaticConfirmationViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CardAutomaticConfirmationViewController.h; sourceTree = "<group>"; };
B607FFBB2321DA99004203E0 /* MyAPIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyAPIClient.h; sourceTree = "<group>"; };
B607FFBC2321DA99004203E0 /* MyAPIClient.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyAPIClient.m; sourceTree = "<group>"; };
B65E8FCA22FA078A0057E64A /* WeChatPayExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WeChatPayExampleViewController.h; sourceTree = "<group>"; };
B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WeChatPayExampleViewController.m; sourceTree = "<group>"; };
B66AC61C22CAAB8F0064C551 /* CardSetupIntentExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CardSetupIntentExampleViewController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -105,10 +108,10 @@
04533E7E1A687F5D00C7E52E = {
isa = PBXGroup;
children = (
366F93AF225FF2A2005CFBF6 /* README.md */,
04533E891A687F5D00C7E52E /* Custom Integration */,
04533F0E1A68813100C7E52E /* Frameworks */,
04533E881A687F5D00C7E52E /* Products */,
366F93AF225FF2A2005CFBF6 /* README.md */,
);
sourceTree = "<group>";
};
Expand Down Expand Up @@ -139,12 +142,14 @@
B66AC61D22CAAB8F0064C551 /* CardSetupIntentExampleViewController.m */,
04533F171A688A0A00C7E52E /* Constants.h */,
04533F181A688A0A00C7E52E /* Constants.m */,
31A8934B230F6ABD007ABE37 /* FPXExampleViewController.h */,
31A8934C230F6ABD007ABE37 /* FPXExampleViewController.m */,
04533E971A687F5D00C7E52E /* Images.xcassets */,
8BBD79C8207FD2F900F85BED /* Localizable.strings */,
B607FFBB2321DA99004203E0 /* MyAPIClient.h */,
B607FFBC2321DA99004203E0 /* MyAPIClient.m */,
04533EB01A68802E00C7E52E /* ShippingManager.h */,
04533EB11A68802E00C7E52E /* ShippingManager.m */,
31A8934B230F6ABD007ABE37 /* FPXExampleViewController.h */,
31A8934C230F6ABD007ABE37 /* FPXExampleViewController.m */,
C1CACE921E5E3DF6002D0821 /* SofortExampleViewController.h */,
C1CACE931E5E3DF6002D0821 /* SofortExampleViewController.m */,
04533E8A1A687F5D00C7E52E /* Supporting Files */,
Expand Down Expand Up @@ -286,6 +291,7 @@
04533E901A687F5D00C7E52E /* AppDelegate.m in Sources */,
B65E8FCC22FA078A0057E64A /* WeChatPayExampleViewController.m in Sources */,
C1CACE891E5DF7A9002D0821 /* ApplePayExampleViewController.m in Sources */,
B607FFBD2321DA99004203E0 /* MyAPIClient.m in Sources */,
04533E8D1A687F5D00C7E52E /* main.m in Sources */,
31A8934D230F6ABD007ABE37 /* FPXExampleViewController.m in Sources */,
C12C50DD1E57B3C800EC6D58 /* BrowseExamplesViewController.m in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions Example/Custom Integration/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
return YES;
}

/**
This method is implemented to route returnURLs back to the Stripe SDK.

@see https://stripe.com/docs/mobile/ios/authentication#return-url
*/
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
BOOL stripeHandled = [Stripe handleStripeURLCallbackWithURL:url];
if (stripeHandled) {
Expand Down
6 changes: 4 additions & 2 deletions Example/Custom Integration/ApplePayExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
//

#import <Stripe/Stripe.h>

#import "ApplePayExampleViewController.h"
#import "BrowseExamplesViewController.h"
#import "Constants.h"
#import "ShippingManager.h"
#import "MyAPIClient.h"

/**
This example demonstrates creating a payment using Apple Pay. First, we configure a PKPaymentRequest
Expand Down Expand Up @@ -169,8 +171,8 @@ - (void)_createAndConfirmPaymentIntentWithPaymentMethod:(STPPaymentMethod *)paym
};

// 1. Create a PaymentIntent on the backend. This is typically done at the beginning of the checkout flow.
[self.delegate createBackendPaymentIntentWithAmount:@(1000) completion:^(STPBackendResult status, NSString *clientSecret, NSError *error) {
if (status == STPBackendResultFailure || error) {
[[MyAPIClient sharedClient] createPaymentIntentWithCompletion:^(MyAPIClientResult status, NSString *clientSecret, NSError *error) {
if (status == MyAPIClientResultFailure || error) {
self.applePayError = error;
finishWithStatus(PKPaymentAuthorizationStatusFailure);
return;
Expand Down
24 changes: 0 additions & 24 deletions Example/Custom Integration/BrowseExamplesViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,11 @@
#import <UIKit/UIKit.h>
#import <Stripe/Stripe.h>

typedef NS_ENUM(NSInteger, STPBackendResult) {
STPBackendResultSuccess,
STPBackendResultFailure,
};

typedef void (^STPPaymentIntentCreationHandler)(STPBackendResult status, NSString *clientSecret, NSError *error);
typedef void (^STPPaymentIntentCreateAndConfirmHandler)(STPBackendResult status, NSString *clientSecret, NSError *error);
typedef void (^STPConfirmPaymentIntentCompletionHandler)(STPBackendResult status, NSString *clientSecret, NSError *error);
typedef void (^STPCreateSetupIntentCompletionHandler)(STPBackendResult status, NSString *clientSecret, NSError *error);


@protocol ExampleViewControllerDelegate <STPAuthenticationContext>

- (void)exampleViewController:(UIViewController *)controller didFinishWithMessage:(NSString *)message;
- (void)exampleViewController:(UIViewController *)controller didFinishWithError:(NSError *)error;

- (void)createBackendPaymentIntentWithAmount:(NSNumber *)amount completion:(STPPaymentIntentCreationHandler)completion;
- (void)createAndConfirmPaymentIntentWithAmount:(NSNumber *)amount
paymentMethod:(NSString *)paymentMethodID
returnURL:(NSString *)returnURL
completion:(STPPaymentIntentCreateAndConfirmHandler)completion;
- (void)confirmPaymentIntent:(STPPaymentIntent *)paymentIntent completion:(STPConfirmPaymentIntentCompletionHandler)completion;


// if paymentMethodID != nil, this will also confirm on the backend
- (void)createSetupIntentWithPaymentMethod:(NSString *)paymentMethodID
returnURL:(NSString *)returnURL
completion:(STPCreateSetupIntentCompletionHandler)completion;

@end

@interface BrowseExamplesViewController : UITableViewController
Expand Down
Loading