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

EPS PaymentMethod Bindings #1578

Merged
merged 7 commits into from
May 19, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions Example/Non-Card Payment Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
36B6CB5D234BEB8400331C38 /* SEPADebitExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB5C234BEB8400331C38 /* SEPADebitExampleViewController.m */; };
36B6CB64234FD9AA00331C38 /* iDEALExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */; };
448895B424526C6B00F7D0C2 /* Przelewy24ExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 448895B324526C6B00F7D0C2 /* Przelewy24ExampleViewController.m */; };
69A6C306246E63A2005FF304 /* EPSExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A6C305246E63A2005FF304 /* EPSExampleViewController.m */; };
44BDCFE4245A4CAE007EE6D5 /* BancontactExampleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 44BDCFE3245A4CAE007EE6D5 /* BancontactExampleViewController.m */; };
8BBD79C6207FD2F900F85BED /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8BBD79C8207FD2F900F85BED /* Localizable.strings */; };
B607FFBD2321DA99004203E0 /* MyAPIClient.m in Sources */ = {isa = PBXBuildFile; fileRef = B607FFBC2321DA99004203E0 /* MyAPIClient.m */; };
Expand Down Expand Up @@ -80,6 +81,8 @@
36B6CB63234FD9AA00331C38 /* iDEALExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = iDEALExampleViewController.m; sourceTree = "<group>"; };
448895B224526C6B00F7D0C2 /* Przelewy24ExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Przelewy24ExampleViewController.h; sourceTree = "<group>"; };
448895B324526C6B00F7D0C2 /* Przelewy24ExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Przelewy24ExampleViewController.m; sourceTree = "<group>"; };
69A6C304246E6225005FF304 /* EPSExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = EPSExampleViewController.h; sourceTree = "<group>"; };
69A6C305246E63A2005FF304 /* EPSExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = EPSExampleViewController.m; sourceTree = "<group>"; };
44BDCFE2245A4CAE007EE6D5 /* BancontactExampleViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BancontactExampleViewController.h; sourceTree = "<group>"; };
44BDCFE3245A4CAE007EE6D5 /* BancontactExampleViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BancontactExampleViewController.m; sourceTree = "<group>"; };
8BBD79C7207FD2F900F85BED /* en */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -181,6 +184,8 @@
04533E8A1A687F5D00C7E52E /* Supporting Files */,
B65E8FCA22FA078A0057E64A /* WeChatPayExampleViewController.h */,
B65E8FCB22FA078A0057E64A /* WeChatPayExampleViewController.m */,
69A6C304246E6225005FF304 /* EPSExampleViewController.h */,
69A6C305246E63A2005FF304 /* EPSExampleViewController.m */,
);
path = "Non-Card Payment Examples";
sourceTree = "<group>";
Expand Down Expand Up @@ -325,6 +330,7 @@
04533E8D1A687F5D00C7E52E /* main.m in Sources */,
31A8934D230F6ABD007ABE37 /* FPXExampleViewController.m in Sources */,
36B6CB5D234BEB8400331C38 /* SEPADebitExampleViewController.m in Sources */,
69A6C306246E63A2005FF304 /* EPSExampleViewController.m in Sources */,
C12C50DD1E57B3C800EC6D58 /* BrowseExamplesViewController.m in Sources */,
364FC2D024201F62002879EB /* AUBECSDebitExampleViewController.m in Sources */,
448895B424526C6B00F7D0C2 /* Przelewy24ExampleViewController.m in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "SEPADebitExampleViewController.h"
#import "SofortExampleViewController.h"
#import "WeChatPayExampleViewController.h"
#import "EPSExampleViewController.h"

/**
This view controller presents different examples, each of which demonstrates creating a payment using a different payment method or integration.
Expand All @@ -42,7 +43,7 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 13;
return 14;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
Expand Down Expand Up @@ -87,6 +88,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
case 12:
cell.textLabel.text = @"Bancontact";
break;
case 13:
cell.textLabel.text = @"EPS";
break;
}
return cell;
}
Expand Down Expand Up @@ -179,6 +183,12 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
viewController = exampleVC;
break;
}
case 13: {
EPSExampleViewController *exampleVC = [EPSExampleViewController new];
exampleVC.delegate = self;
viewController = exampleVC;
break;
}
}
[self.navigationController pushViewController:viewController animated:YES];
}
Expand Down
18 changes: 18 additions & 0 deletions Example/Non-Card Payment Examples/EPSExampleViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// EPSExampleViewControllewrViewController.h
// Non-Card Payment Examples
//
// Created by Shengwei Wu on 5/15/20.
// Copyright © 2020 Stripe. All rights reserved.
//

#import "PaymentExampleViewController.h"

NS_ASSUME_NONNULL_BEGIN

@interface EPSExampleViewController : PaymentExampleViewController


@end

NS_ASSUME_NONNULL_END
94 changes: 94 additions & 0 deletions Example/Non-Card Payment Examples/EPSExampleViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// EPSExampleViewController.m
// Non-Card Payment Examples
//
// Created by Shengwei Wu on 5/15/20.
// Copyright © 2020 Stripe. All rights reserved.
//

#import "EPSExampleViewController.h"

#import "MyAPIClient.h"


NS_ASSUME_NONNULL_BEGIN

@interface EPSExampleViewController ()
// Category Defintions
@end

@implementation EPSExampleViewController {
UITextField *_nameField;
}


- (void)viewDidLoad {
[super viewDidLoad];

self.title = @"EPS";

_nameField = [[UITextField alloc] init];
_nameField.borderStyle = UITextBorderStyleRoundedRect;
_nameField.textContentType = UITextContentTypeName;
_nameField.placeholder = @"Name";
_nameField.translatesAutoresizingMaskIntoConstraints = NO;
[self.view addSubview:_nameField];


[self.payButton setTitle:@"Pay with EPS" forState:UIControlStateNormal];
[self.payButton sizeToFit];

[NSLayoutConstraint activateConstraints:@[
[_nameField.centerXAnchor constraintEqualToAnchor:self.payButton.centerXAnchor],
[_nameField.bottomAnchor constraintEqualToAnchor:self.payButton.topAnchor constant:-12.f],
[_nameField.widthAnchor constraintEqualToConstant:240.f],
]];
}

- (void)payButtonSelected {
[super payButtonSelected];
[self updateUIForPaymentInProgress:YES];

[[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];

STPPaymentMethodBillingDetails *billingDetails = [[STPPaymentMethodBillingDetails alloc] init];
billingDetails.name = self->_nameField.text;


STPPaymentMethodEPSParams *eps = [[STPPaymentMethodEPSParams alloc] init];

// EPS does not require additional parameters so we only need to pass the init-ed
// STPPaymentMethodEPSParams instance to STPPaymentMethodParams
paymentIntentParams.paymentMethodParams = [STPPaymentMethodParams paramsWithEPS:eps
billingDetails:billingDetails
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:@"country=at"];
}


@end

NS_ASSUME_NONNULL_END
Loading