From 306250e3b28d27555d4f2c805714ca84617f8eb0 Mon Sep 17 00:00:00 2001 From: Ibby Hadeed Date: Sat, 8 Jul 2017 08:55:18 -0400 Subject: [PATCH] fix(ios): update publishable key for existing client if exists closes #18 --- src/ios/CordovaStripe.m | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/ios/CordovaStripe.m b/src/ios/CordovaStripe.m index 2ce2c94..188da65 100644 --- a/src/ios/CordovaStripe.m +++ b/src/ios/CordovaStripe.m @@ -10,15 +10,18 @@ - (void)setPublishableKey:(CDVInvokedUrlCommand*)command NSString* publishableKey = [[command arguments] objectAtIndex:0]; [[STPPaymentConfiguration sharedConfiguration] setPublishableKey:publishableKey]; - CDVPluginResult* result = [CDVPluginResult - resultWithStatus: CDVCommandStatus_OK]; - [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; if (self.client == nil) { // init client if doesn't exist client = [[STPAPIClient alloc] init]; + } else { + [self.client setPublishableKey:publishableKey]; } + CDVPluginResult* result = [CDVPluginResult + resultWithStatus: CDVCommandStatus_OK]; + [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; + } - (void)throwNotInitializedError:(CDVInvokedUrlCommand *) command