From d2c2a442951c3ea834fab4ddc15a2dc4695e31e9 Mon Sep 17 00:00:00 2001 From: Izabela Date: Wed, 2 Nov 2016 16:40:37 +0100 Subject: [PATCH 1/4] Changes for mobile-app --- .../project.xcworkspace/contents.xcworkspacedata | 7 +++++++ StripeNative/PaymentViewController.h | 1 + StripeNative/PaymentViewController.m | 7 ++++++- StripeNative/StripeNativeManager.m | 9 +++++---- 4 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 StripeNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata diff --git a/StripeNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/StripeNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/StripeNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/StripeNative/PaymentViewController.h b/StripeNative/PaymentViewController.h index 7743f51..93902cb 100644 --- a/StripeNative/PaymentViewController.h +++ b/StripeNative/PaymentViewController.h @@ -21,6 +21,7 @@ @interface PaymentViewController : UIViewController @property (nonatomic) NSString* amount; +@property (nonatomic) NSString* email; @property (nonatomic, weak) id delegate; @end diff --git a/StripeNative/PaymentViewController.m b/StripeNative/PaymentViewController.m index 7c2490a..78b86cb 100644 --- a/StripeNative/PaymentViewController.m +++ b/StripeNative/PaymentViewController.m @@ -30,7 +30,9 @@ - (void)viewDidLoad { } // Setup save button - NSString *title = [NSString stringWithFormat:@"Pay $%@", self.amount]; + float num = [self.amount floatValue]; + num = num/100; + NSString *title = [NSString stringWithFormat:@"Pay £%.2f", num ]; UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleDone target:self action:@selector(save:)]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)]; saveButton.enabled = NO; @@ -45,6 +47,9 @@ - (void)viewDidLoad { // Setup email field: hack it up to look just like the Stripe field UITextField *emailField = [[UITextField alloc] init]; + if (self.email != nil){ + emailField.text=self.email; + } [emailField setPlaceholder:@"Email address"]; UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 44)]; emailField.leftView = paddingView; diff --git a/StripeNative/StripeNativeManager.m b/StripeNative/StripeNativeManager.m index 51b710a..c75c917 100644 --- a/StripeNative/StripeNativeManager.m +++ b/StripeNative/StripeNativeManager.m @@ -161,10 +161,11 @@ -(void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewCo # pragma mark - Card form -- (void)beginCustomPaymentWithAmount:(NSString *)amount { +- (void)beginCustomPaymentWithAmount:(NSString *)amount email:(NSString *)email { PaymentViewController *paymentViewController = [[PaymentViewController alloc] initWithNibName:nil bundle:nil]; paymentViewController.amount = amount; paymentViewController.delegate = self; + paymentViewController.email = email; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:paymentViewController]; [rootViewController presentViewController:navController animated:YES completion:nil]; } @@ -228,19 +229,19 @@ - (void)paymentViewController:(PaymentViewController *)controller didFinishWithT else if (args[@"fallbackOnCardForm"]) { // The last item for Apple Pay is the "summary" item with the total. NSString *amount = [[items lastObject][@"amount"] stringValue]; - [self paymentRequestWithCardForm:amount resolver:resolve rejector:reject]; + [self paymentRequestWithCardForm:amount email:nil resolver:resolve rejector:reject]; } else { reject(nil, nil, [NSError errorWithDomain:StripeNativeDomain code:SNOtherError userInfo:@{NSLocalizedDescriptionKey:@"Apple Pay not enabled and fallback option false"}]); } } -RCT_EXPORT_METHOD(paymentRequestWithCardForm:(NSString *)amount resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) { +RCT_EXPORT_METHOD(paymentRequestWithCardForm:(NSString *)amount email:(NSString *)email resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) { promiseResolver = resolve; promiseRejector = reject; resolved = FALSE; - [self beginCustomPaymentWithAmount:amount]; + [self beginCustomPaymentWithAmount:amount email:email]; } RCT_EXPORT_METHOD(success: (RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) From 5e5ac37571d6c4c329f41467ab89760db8838c47 Mon Sep 17 00:00:00 2001 From: Izabela Date: Wed, 2 Nov 2016 16:55:29 +0100 Subject: [PATCH 2/4] Changes for mobile-app --- index.ios.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.ios.js b/index.ios.js index 74ef076..33507e3 100644 --- a/index.ios.js +++ b/index.ios.js @@ -69,8 +69,8 @@ var NativeStripe = { return StripeNativeManager.paymentRequestWithApplePay(summaryItems, options); }, - paymentRequestWithCardForm(items) { - return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString()); + paymentRequestWithCardForm(items, email) { + return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString(), email); }, }; From b6b602cfa6950a878296f1241e270d795eecc3c3 Mon Sep 17 00:00:00 2001 From: Izabela Date: Thu, 10 Nov 2016 11:55:20 +0100 Subject: [PATCH 3/4] CurrencySymbol added as a parameter for a payment with card form --- StripeNative/PaymentViewController.h | 1 + StripeNative/PaymentViewController.m | 7 ++++++- StripeNative/StripeNativeManager.m | 13 +++++++++---- index.ios.js | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/StripeNative/PaymentViewController.h b/StripeNative/PaymentViewController.h index 93902cb..612ffaf 100644 --- a/StripeNative/PaymentViewController.h +++ b/StripeNative/PaymentViewController.h @@ -22,6 +22,7 @@ @property (nonatomic) NSString* amount; @property (nonatomic) NSString* email; +@property (nonatomic) NSString* currencySymbol; @property (nonatomic, weak) id delegate; @end diff --git a/StripeNative/PaymentViewController.m b/StripeNative/PaymentViewController.m index 78b86cb..d087c18 100644 --- a/StripeNative/PaymentViewController.m +++ b/StripeNative/PaymentViewController.m @@ -32,7 +32,12 @@ - (void)viewDidLoad { // Setup save button float num = [self.amount floatValue]; num = num/100; - NSString *title = [NSString stringWithFormat:@"Pay £%.2f", num ]; + NSString *title; + if (self.currencySymbol != nil){ + title = [NSString stringWithFormat:@"Pay %@%.2f", self.currencySymbol, num ]; + } else { + title = [NSString stringWithFormat:@"Pay $%.2f", num ]; + } UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleDone target:self action:@selector(save:)]; UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancel:)]; saveButton.enabled = NO; diff --git a/StripeNative/StripeNativeManager.m b/StripeNative/StripeNativeManager.m index c75c917..7b26783 100644 --- a/StripeNative/StripeNativeManager.m +++ b/StripeNative/StripeNativeManager.m @@ -161,15 +161,20 @@ -(void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewCo # pragma mark - Card form -- (void)beginCustomPaymentWithAmount:(NSString *)amount email:(NSString *)email { +- (void)beginCustomPaymentWithAmount:(NSString *)amount email:(NSString *)email currencySymbol:(NSString *)currencySymbol { PaymentViewController *paymentViewController = [[PaymentViewController alloc] initWithNibName:nil bundle:nil]; paymentViewController.amount = amount; paymentViewController.delegate = self; paymentViewController.email = email; + paymentViewController.currencySymbol = currencySymbol; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:paymentViewController]; [rootViewController presentViewController:navController animated:YES completion:nil]; } +- (void)beginCustomPaymentWithAmount:(NSString *)amount email:(NSString *)email { + [self beginCustomPaymentWithAmount:amount email:email currencySymbol:nil]; +} + - (void)paymentViewController:(PaymentViewController *)controller didFinishWithToken:(STPToken *)token email:(NSString *)email error:(NSError *)error { [rootViewController dismissViewControllerAnimated:YES completion:^{ resolved = TRUE; @@ -229,19 +234,19 @@ - (void)paymentViewController:(PaymentViewController *)controller didFinishWithT else if (args[@"fallbackOnCardForm"]) { // The last item for Apple Pay is the "summary" item with the total. NSString *amount = [[items lastObject][@"amount"] stringValue]; - [self paymentRequestWithCardForm:amount email:nil resolver:resolve rejector:reject]; + [self paymentRequestWithCardForm:amount email:nil currencySymbol:nil resolver:resolve rejector:reject]; } else { reject(nil, nil, [NSError errorWithDomain:StripeNativeDomain code:SNOtherError userInfo:@{NSLocalizedDescriptionKey:@"Apple Pay not enabled and fallback option false"}]); } } -RCT_EXPORT_METHOD(paymentRequestWithCardForm:(NSString *)amount email:(NSString *)email resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) { +RCT_EXPORT_METHOD(paymentRequestWithCardForm:(NSString *)amount email:(NSString *)email currencySymbol:(NSString *) currencySymbol resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) { promiseResolver = resolve; promiseRejector = reject; resolved = FALSE; - [self beginCustomPaymentWithAmount:amount email:email]; + [self beginCustomPaymentWithAmount:amount email:email currencySymbol:currencySymbol]; } RCT_EXPORT_METHOD(success: (RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) diff --git a/index.ios.js b/index.ios.js index 33507e3..a8cb742 100644 --- a/index.ios.js +++ b/index.ios.js @@ -69,8 +69,8 @@ var NativeStripe = { return StripeNativeManager.paymentRequestWithApplePay(summaryItems, options); }, - paymentRequestWithCardForm(items, email) { - return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString(), email); + paymentRequestWithCardForm(items, email, currencySymbol) { + return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString(), email, currencySymbol); }, }; From 0bbaf9137bf97e0b553bab48cb559a3bec00b972 Mon Sep 17 00:00:00 2001 From: Izabela Date: Tue, 14 Feb 2017 16:03:37 +0100 Subject: [PATCH 4/4] Library prepared for react 0.40 --- StripeNative/StripeNativeManager.h | 2 +- StripeNative/StripeNativeManager.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/StripeNative/StripeNativeManager.h b/StripeNative/StripeNativeManager.h index c241c64..ad20a59 100644 --- a/StripeNative/StripeNativeManager.h +++ b/StripeNative/StripeNativeManager.h @@ -5,7 +5,7 @@ // Copyright (c) 2015 Lane Rettig. All rights reserved. // -#import "RCTViewManager.h" +#import #import "PaymentViewController.h" @interface StripeNativeManager : NSObject diff --git a/StripeNative/StripeNativeManager.m b/StripeNative/StripeNativeManager.m index 7b26783..2f8ecca 100644 --- a/StripeNative/StripeNativeManager.m +++ b/StripeNative/StripeNativeManager.m @@ -7,8 +7,8 @@ #import -#import "RCTEventDispatcher.h" -#import "RCTUtils.h" +#import +#import #import "PaymentViewController.h" #import "StripeNativeManager.h"