diff --git a/StripeNative.xcodeproj/project.pbxproj b/StripeNative.xcodeproj/project.pbxproj
index d47c4cc..1dbdd2c 100644
--- a/StripeNative.xcodeproj/project.pbxproj
+++ b/StripeNative.xcodeproj/project.pbxproj
@@ -211,6 +211,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/example/node_modules/react-native/React/**",
+ "$(SRCROOT)/../../ios/Pods/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = StripeNative;
@@ -230,6 +231,7 @@
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
"$(SRCROOT)/../react-native/React/**",
"$(SRCROOT)/example/node_modules/react-native/React/**",
+ "$(SRCROOT)/../../ios/Pods/**",
);
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = StripeNative;
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.xcodeproj/project.xcworkspace/xcshareddata/StripeNative.xcscmblueprint b/StripeNative.xcodeproj/project.xcworkspace/xcshareddata/StripeNative.xcscmblueprint
new file mode 100644
index 0000000..2a040ec
--- /dev/null
+++ b/StripeNative.xcodeproj/project.xcworkspace/xcshareddata/StripeNative.xcscmblueprint
@@ -0,0 +1,30 @@
+{
+ "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "A3B345E78B69520AC98822C93DEFACE150C81645",
+ "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
+
+ },
+ "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
+ "1DF63C5B8814492D030C2A6247051230915D5511" : 9223372036854775807,
+ "A3B345E78B69520AC98822C93DEFACE150C81645" : 9223372036854775807
+ },
+ "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "218AAF75-D61D-4ACF-B6A8-C42F40562327",
+ "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
+ "1DF63C5B8814492D030C2A6247051230915D5511" : "..",
+ "A3B345E78B69520AC98822C93DEFACE150C81645" : "react-native-stripe\/"
+ },
+ "DVTSourceControlWorkspaceBlueprintNameKey" : "StripeNative",
+ "DVTSourceControlWorkspaceBlueprintVersion" : 204,
+ "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "StripeNative.xcodeproj",
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
+ {
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "bitbucket.org:flyvictor\/mobile-seats.git",
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "1DF63C5B8814492D030C2A6247051230915D5511"
+ },
+ {
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "github.com:flyvictor\/react-native-stripe.git",
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
+ "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "A3B345E78B69520AC98822C93DEFACE150C81645"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/StripeNative/PaymentViewController.h b/StripeNative/PaymentViewController.h
index 7743f51..21ee425 100644
--- a/StripeNative/PaymentViewController.h
+++ b/StripeNative/PaymentViewController.h
@@ -21,6 +21,7 @@
@interface PaymentViewController : UIViewController
@property (nonatomic) NSString* amount;
+@property (nonatomic) NSString* currency;
@property (nonatomic, weak) id delegate;
@end
diff --git a/StripeNative/PaymentViewController.m b/StripeNative/PaymentViewController.m
index 7c2490a..49e3a50 100644
--- a/StripeNative/PaymentViewController.m
+++ b/StripeNative/PaymentViewController.m
@@ -8,14 +8,14 @@
// See https://github.com/stripe/stripe-ios.
//
-#import
+#import
#import
#import "PaymentViewController.h"
@interface PaymentViewController ()
@property (weak, nonatomic) STPPaymentCardTextField *paymentTextField;
-@property (weak, nonatomic) UITextField *emailField;
+// @property (weak, nonatomic) UITextField *emailField;
@property (weak, nonatomic) UIActivityIndicatorView *activityIndicator;
@end
@@ -30,7 +30,7 @@ - (void)viewDidLoad {
}
// Setup save button
- NSString *title = [NSString stringWithFormat:@"Pay $%@", self.amount];
+ NSString *title = [NSString stringWithFormat:@"Pay %@%@", self.currency, self.amount];
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;
@@ -43,23 +43,23 @@ - (void)viewDidLoad {
self.paymentTextField = paymentTextField;
[self.view addSubview:paymentTextField];
- // Setup email field: hack it up to look just like the Stripe field
- UITextField *emailField = [[UITextField alloc] init];
- [emailField setPlaceholder:@"Email address"];
- UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 44)];
- emailField.leftView = paddingView;
- emailField.leftViewMode = UITextFieldViewModeAlways;
- emailField.layer.cornerRadius = 5.0f;
- emailField.layer.borderColor = [[UIColor colorWithRed:171.0/255.0
- green:171.0/255.0
- blue:171.0/255.0
- alpha:1.0] CGColor];
- emailField.layer.borderWidth = 1.0f;
- [emailField addTarget:self
- action:@selector(textFieldDidChange)
- forControlEvents:UIControlEventEditingChanged];
- self.emailField = emailField;
- [self.view addSubview:emailField];
+ // // Setup email field: hack it up to look just like the Stripe field
+ // UITextField *emailField = [[UITextField alloc] init];
+ // [emailField setPlaceholder:@"Email address"];
+ // UIView *paddingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 44)];
+ // emailField.leftView = paddingView;
+ // emailField.leftViewMode = UITextFieldViewModeAlways;
+ // emailField.layer.cornerRadius = 5.0f;
+ // emailField.layer.borderColor = [[UIColor colorWithRed:171.0/255.0
+ // green:171.0/255.0
+ // blue:171.0/255.0
+ // alpha:1.0] CGColor];
+ // emailField.layer.borderWidth = 1.0f;
+ // [emailField addTarget:self
+ // action:@selector(textFieldDidChange)
+ // forControlEvents:UIControlEventEditingChanged];
+ // self.emailField = emailField;
+ // [self.view addSubview:emailField];
// Setup Activity Indicator
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
@@ -68,34 +68,34 @@ - (void)viewDidLoad {
[self.view addSubview:activityIndicator];
}
-- (BOOL)emailFieldIsValid {
- NSString *emailRegex =
- @"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"
- @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
- @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
- @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
- @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
- @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
- @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
- NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES[c] %@", emailRegex];
- return [emailTest evaluateWithObject:self.emailField.text];
-}
+// - (BOOL)emailFieldIsValid {
+// NSString *emailRegex =
+// @"(?:[a-z0-9!#$%\\&'*+/=?\\^_`{|}~-]+(?:\\.[a-z0-9!#$%\\&'*+/=?\\^_`{|}"
+// @"~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\"
+// @"x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-"
+// @"z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5"
+// @"]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-"
+// @"9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21"
+// @"-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
+// NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES[c] %@", emailRegex];
+// return [emailTest evaluateWithObject:self.emailField.text];
+// }
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGFloat padding = 15;
CGFloat width = CGRectGetWidth(self.view.frame) - (padding * 2);
self.paymentTextField.frame = CGRectMake(padding, padding, width, 44);
- self.emailField.frame = CGRectMake(padding, padding*2+44, width, 44);
+ // self.emailField.frame = CGRectMake(padding, padding*2+44, width, 44);
self.activityIndicator.center = self.view.center;
}
- (void)paymentCardTextFieldDidChange:(nonnull STPPaymentCardTextField *)textField {
- self.navigationItem.rightBarButtonItem.enabled = textField.isValid && [self emailFieldIsValid];
+ self.navigationItem.rightBarButtonItem.enabled = textField.isValid; // && [self emailFieldIsValid];
}
- (void)textFieldDidChange {
- self.navigationItem.rightBarButtonItem.enabled = self.paymentTextField.isValid && [self emailFieldIsValid];
+ self.navigationItem.rightBarButtonItem.enabled = self.paymentTextField.isValid; // && [self emailFieldIsValid];
}
- (void)cancel:(id)sender {
@@ -108,7 +108,7 @@ - (void)cancel:(id)sender {
}
- (void)save:(id)sender {
- if (!([self.paymentTextField isValid] && [self emailFieldIsValid])) {
+ if (!([self.paymentTextField isValid])) {
return;
}
if (![Stripe defaultPublishableKey]) {
@@ -129,7 +129,7 @@ - (void)save:(id)sender {
[self.delegate paymentViewController:self didFinishWithToken:nil email:nil error:error];
}
NSLog(@"Successfully got token: %@", token);
- [self.delegate paymentViewController:self didFinishWithToken:token email:self.emailField.text error:nil];
+ [self.delegate paymentViewController:self didFinishWithToken:token email:nil error:nil];
}];
}
diff --git a/StripeNative/StripeNativeManager.h b/StripeNative/StripeNativeManager.h
index c241c64..d0c3629 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 "React/RCTViewManager.h"
#import "PaymentViewController.h"
@interface StripeNativeManager : NSObject
diff --git a/StripeNative/StripeNativeManager.m b/StripeNative/StripeNativeManager.m
index 2dfb87f..53bd8c5 100644
--- a/StripeNative/StripeNativeManager.m
+++ b/StripeNative/StripeNativeManager.m
@@ -5,10 +5,10 @@
// Copyright (c) 2015 Lane Rettig. All rights reserved.
//
-#import
+#import
-#import
-#import "RCTUtils.h"
+#import "React/RCTEventDispatcher.h"
+#import "React/RCTUtils.h"
#import "PaymentViewController.h"
#import "StripeNativeManager.h"
@@ -161,9 +161,13 @@ -(void)paymentAuthorizationViewControllerDidFinish:(PKPaymentAuthorizationViewCo
# pragma mark - Card form
-- (void)beginCustomPaymentWithAmount:(NSString *)amount {
+- (void)beginCustomPaymentWithAmount:(NSString *)amount args:(NSDictionary *)args {
+
+ NSString* currencyCode = args[@"currencySymbol"] ? args[@"currencySymbol"] : @"£";
+
PaymentViewController *paymentViewController = [[PaymentViewController alloc] initWithNibName:nil bundle:nil];
paymentViewController.amount = amount;
+ paymentViewController.currency = currencyCode;
paymentViewController.delegate = self;
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:paymentViewController];
[rootViewController presentViewController:navController animated:YES completion:nil];
@@ -183,7 +187,7 @@ - (void)paymentViewController:(PaymentViewController *)controller didFinishWithT
// Convert token to string and add additional information.
promiseResolver(@[
token.tokenId,
- @{@"emailAddress": email},
+ @{},
@{},
]);
}
@@ -228,19 +232,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 args:args 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 args:(NSDictionary *)args resolver:(RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject) {
promiseResolver = resolve;
promiseRejector = reject;
resolved = FALSE;
- [self beginCustomPaymentWithAmount:amount];
+ [self beginCustomPaymentWithAmount:amount args:args];
}
RCT_EXPORT_METHOD(success: (RCTPromiseResolveBlock)resolve rejector:(RCTPromiseRejectBlock)reject)
diff --git a/index.ios.js b/index.ios.js
index 74ef076..5e196d5 100644
--- a/index.ios.js
+++ b/index.ios.js
@@ -1,3 +1,4 @@
+//TESTING
var React = require('react-native');
var NativeModules = React.NativeModules;
var { StripeNativeManager } = NativeModules;
@@ -69,8 +70,9 @@ var NativeStripe = {
return StripeNativeManager.paymentRequestWithApplePay(summaryItems, options);
},
- paymentRequestWithCardForm(items) {
- return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString());
+ paymentRequestWithCardForm(items, options) {
+ console.log('paymentRequestWithCardForm', items, options);
+ return StripeNativeManager.paymentRequestWithCardForm(getTotal(items).toFixed(2).toString(), options);
},
};