diff --git a/CHANGELOG b/CHANGELOG
index 1c76526..feca40b 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+=== 3.0.3 2017-05-24
+
+* Hotfix Ensure we notify caller when showing or dismissing our dialogs
+
=== 2.1.1 2016-12-08
* Hotfix Add TransactionParams to PaystackIOSStatic's headers
diff --git a/Example/Paystack iOS Example/Info.plist b/Example/Paystack iOS Example/Info.plist
index 2066a10..d634ff9 100644
--- a/Example/Paystack iOS Example/Info.plist
+++ b/Example/Paystack iOS Example/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 3.0.2
+ 3.0.3
CFBundleSignature
????
CFBundleVersion
- 4
+ 5
LSRequiresIPhoneOS
UILaunchStoryboardName
diff --git a/Example/Paystack iOS Example/ViewController.swift b/Example/Paystack iOS Example/ViewController.swift
index 0553f9b..6e9e192 100644
--- a/Example/Paystack iOS Example/ViewController.swift
+++ b/Example/Paystack iOS Example/ViewController.swift
@@ -106,7 +106,7 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
let transactionParams = PSTCKTransactionParams.init();
transactionParams.access_code = newCode as String;
// use library to create charge and get its reference
- PSTCKAPIClient.shared().chargeCard(self.cardDetailsForm.cardParams, forTransaction: transactionParams, on: self, didEndWithError: { (error, reference) -> Void in
+ PSTCKAPIClient.shared().chargeCard(self.cardDetailsForm.cardParams, forTransaction: transactionParams, on: self, didEndWithError: { (error, reference) in
self.outputOnLabel(str: "Charge errored")
// what should I do if an error occured?
print(error)
@@ -131,13 +131,20 @@ class ViewController: UIViewController, PSTCKPaymentCardTextFieldDelegate {
}
}
self.chargeCardButton.isEnabled = true;
- }, didRequestValidation: { (reference) -> Void in
+ }, didRequestValidation: { (reference) in
self.outputOnLabel(str: "requested validation: " + reference)
- }, didTransactionSuccess: { (reference) -> Void in
+ }, willPresentDialog: {
+ // make sure dialog can show
+ // if using a "processing" dialog, please hide it
+ self.outputOnLabel(str: "will show a dialog")
+ }, dismissedDialog: {
+ // if using a processing dialog, please make it visible again
+ self.outputOnLabel(str: "dismissed dialog")
+ }) { (reference) in
self.outputOnLabel(str: "succeeded: " + reference)
self.chargeCardButton.isEnabled = true;
self.verifyTransaction(reference: reference)
- })
+ }
return
}
diff --git a/Paystack.podspec b/Paystack.podspec
index 27b9557..4de3687 100644
--- a/Paystack.podspec
+++ b/Paystack.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'Paystack'
- s.version = '3.0.2'
+ s.version = '3.0.3'
s.summary = 'Paystack is a web-based API helping African Businesses accept payments online.'
s.description = <<-DESC
Paystack makes it easy for African Businesses to accept Mastercard, Visa and Verve cards from anyone, anywhere in the world.
diff --git a/Paystack/Info.plist b/Paystack/Info.plist
index b769343..e2eae83 100644
--- a/Paystack/Info.plist
+++ b/Paystack/Info.plist
@@ -15,11 +15,11 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 3.0.2
+ 3.0.3
CFBundleSignature
????
CFBundleVersion
- 4
+ 5
NSPrincipalClass
diff --git a/Paystack/PSTCKAPIClient.m b/Paystack/PSTCKAPIClient.m
index a072a59..9c260e1 100644
--- a/Paystack/PSTCKAPIClient.m
+++ b/Paystack/PSTCKAPIClient.m
@@ -91,6 +91,8 @@ @interface PSTCKAPIClient ()
@property(nonatomic, retain) PSTCKTransactionParams *transaction;
@property(nonatomic, copy) PSTCKErrorCompletionBlock errorCompletion;
@property(nonatomic, copy) PSTCKTransactionCompletionBlock beforeValidateCompletion;
+@property(nonatomic, copy) PSTCKNotifyCompletionBlock showingDialogCompletion;
+@property(nonatomic, copy) PSTCKNotifyCompletionBlock dialogDismissedCompletion;
@property(nonatomic, copy) PSTCKTransactionCompletionBlock successCompletion;
@property int INVALID_DATA_SENT_RETRIES;
@end
@@ -245,14 +247,13 @@ - (void)chargeCard:(nonnull PSTCKCardParams *)card
forTransaction:(nonnull PSTCKTransactionParams *)transaction
onViewController:(nonnull UIViewController *)viewController
didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
-didRequestValidation:(nullable PSTCKTransactionCompletionBlock)beforeValidateCompletion
didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion {
NSCAssert(card != nil, @"'card' is required for a charge");
NSCAssert(errorCompletion != nil, @"'errorCompletion' is required to handle any errors encountered while charging");
NSCAssert(viewController != nil, @"'viewController' is required to show any alerts that may be needed");
NSCAssert(transaction != nil, @"'transaction' is required so we may know who to charge");
NSCAssert(successCompletion != nil, @"'successCompletion' is required so you can continue the process after charge succeeds. Remember to verify on server before giving value.");
- [self startWithCard:card forTransaction:transaction onViewController:viewController didEndWithError:errorCompletion didRequestValidation:beforeValidateCompletion didTransactionSuccess:successCompletion];
+ [self startWithCard:card forTransaction:transaction onViewController:viewController didEndWithError:errorCompletion didTransactionSuccess:successCompletion];
if(PROCESSING){
[self didEndWithProcessingError];
@@ -268,17 +269,54 @@ - (void)chargeCard:(nonnull PSTCKCardParams *)card
[self makeChargeRequest:data atStage:PSTCKChargeStageNoHandle];
}
+- (void)chargeCard:(nonnull PSTCKCardParams *)card
+ forTransaction:(nonnull PSTCKTransactionParams *)transaction
+ onViewController:(nonnull UIViewController *)viewController
+ didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
+didRequestValidation:(nonnull PSTCKTransactionCompletionBlock)beforeValidateCompletion
+ willPresentDialog:(nonnull PSTCKNotifyCompletionBlock)showingDialogCompletion
+ dismissedDialog:(nonnull PSTCKNotifyCompletionBlock)dialogDismissedCompletion
+didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion {
+ self.beforeValidateCompletion = beforeValidateCompletion;
+ self.showingDialogCompletion = showingDialogCompletion;
+ self.dialogDismissedCompletion = dialogDismissedCompletion;
+ [self chargeCard:card forTransaction:transaction onViewController:viewController didEndWithError:errorCompletion didTransactionSuccess:successCompletion];
+
+}
+
+- (void)chargeCard:(nonnull PSTCKCardParams *)card
+ forTransaction:(nonnull PSTCKTransactionParams *)transaction
+ onViewController:(nonnull UIViewController *)viewController
+ didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
+ willPresentDialog:(nonnull PSTCKNotifyCompletionBlock)showingDialogCompletion
+ dismissedDialog:(nonnull PSTCKNotifyCompletionBlock)dialogDismissedCompletion
+didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion {
+ self.showingDialogCompletion = showingDialogCompletion;
+ self.dialogDismissedCompletion = dialogDismissedCompletion;
+ [self chargeCard:card forTransaction:transaction onViewController:viewController didEndWithError:errorCompletion didTransactionSuccess:successCompletion];
+
+}
+
+- (void)chargeCard:(nonnull PSTCKCardParams *)card
+ forTransaction:(nonnull PSTCKTransactionParams *)transaction
+ onViewController:(nonnull UIViewController *)viewController
+ didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
+didRequestValidation:(nonnull PSTCKTransactionCompletionBlock)beforeValidateCompletion
+didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion {
+ self.beforeValidateCompletion = beforeValidateCompletion;
+ [self chargeCard:card forTransaction:transaction onViewController:viewController didEndWithError:errorCompletion didTransactionSuccess:successCompletion];
+
+}
+
- (void)startWithCard:(nonnull PSTCKCardParams *)card
forTransaction:(nonnull PSTCKTransactionParams *)transaction
onViewController:(nonnull UIViewController *)viewController
didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
- didRequestValidation:(nullable PSTCKTransactionCompletionBlock)beforeValidateCompletion
didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion {
self.card = card;
self.transaction = transaction;
self.viewController = viewController;
self.errorCompletion = errorCompletion;
- self.beforeValidateCompletion = beforeValidateCompletion;
self.successCompletion = successCompletion;
self.serverTransaction = [PSTCKServerTransaction new];
@@ -346,9 +384,7 @@ - (void) makeChargeRequest:(NSData *)data
}
- (void) requestPin{
- [self.operationQueue addOperationWithBlock:^{
- self.beforeValidateCompletion(self.serverTransaction.reference);
- }];
+ [self notifyShowingDialog];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"Enter CARD PIN"
message:@"To confirm that you are the owner of this card please enter your card PIN"
preferredStyle:UIAlertControllerStyleAlert];
@@ -357,6 +393,7 @@ - (void) requestPin{
actionWithTitle:@"Continue" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[action isEnabled]; // Just to avoid Unused error
+ [self notifyDialogDismissed];
NSString *provided = ((UITextField *)[alert.textFields objectAtIndex:0]).text;
NSString *handle = [PSTCKCardValidator sanitizedNumericStringForString:provided];
if(handle == nil ||
@@ -386,13 +423,13 @@ - (void) requestPin{
}
- (void) requestAuth:(NSString * _Nonnull) url{
- [self.operationQueue addOperationWithBlock:^{
- self.beforeValidateCompletion(self.serverTransaction.reference);
- }];
+ [self notifyShowingDialog];
+ [self notifyBeforeValidate];
PSTCKAuthViewController* authorizer = [[[PSTCKAuthViewController alloc] init]
initWithURL:[NSURL URLWithString:url]
handler:^{
[self.viewController dismissViewControllerAnimated:YES completion:nil];
+ [self notifyDialogDismissed];
[self makeChargeRequest:nil
atStage:PSTCKChargeStageRequery];
}];
@@ -405,9 +442,8 @@ - (void) requestAuth:(NSString * _Nonnull) url{
}
- (void) requestOtp:(NSString * _Nonnull) otpmessage{
- [self.operationQueue addOperationWithBlock:^{
- self.beforeValidateCompletion(self.serverTransaction.reference);
- }];
+ [self notifyShowingDialog];
+ [self notifyBeforeValidate];
UIAlertController* tkalert = [UIAlertController alertControllerWithTitle:@"Enter OTP"
message:otpmessage
preferredStyle:UIAlertControllerStyleAlert];
@@ -416,6 +452,7 @@ - (void) requestOtp:(NSString * _Nonnull) otpmessage{
actionWithTitle:@"Continue" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
[action isEnabled]; // Just to avoid Unused error
+ [self notifyDialogDismissed];
NSString *provided = ((UITextField *)[tkalert.textFields objectAtIndex:0]).text;
PSTCKValidationParams *validateParams = [PSTCKValidationParams alloc];
validateParams.trans = self.serverTransaction.id;
@@ -499,6 +536,32 @@ - (void)didEndSuccessfully{
}];
}
+- (void)notifyShowingDialog{
+ if(self.showingDialogCompletion == NULL){
+ return;
+ }
+ [self.operationQueue addOperationWithBlock:^{
+ self.showingDialogCompletion();
+ }];
+}
+- (void)notifyDialogDismissed{
+ if(self.dialogDismissedCompletion == NULL){
+ return;
+ }
+ [self.operationQueue addOperationWithBlock:^{
+ self.dialogDismissedCompletion();
+ }];
+}
+- (void)notifyBeforeValidate{
+ if(self.beforeValidateCompletion == NULL){
+ return;
+ }
+ [self.operationQueue addOperationWithBlock:^{
+ self.beforeValidateCompletion(self.serverTransaction.reference);
+ }];
+}
+
+
- (void)didEndWithErrorMessage:(NSString *)errorString{
NSDictionary *userInfo = @{
NSLocalizedDescriptionKey: PSTCKCardErrorProcessingErrorUserMessage,
diff --git a/Paystack/PublicHeaders/PSTCKAPIClient.h b/Paystack/PublicHeaders/PSTCKAPIClient.h
index 8bb0927..8a96b2f 100644
--- a/Paystack/PublicHeaders/PSTCKAPIClient.h
+++ b/Paystack/PublicHeaders/PSTCKAPIClient.h
@@ -8,8 +8,8 @@
#import
#endif
-static NSString *const __nonnull PSTCKSDKVersion = @"3.0.2";
-static NSString *const __nonnull PSTCKSDKBuild = @"11";
+static NSString *const __nonnull PSTCKSDKVersion = @"3.0.3";
+static NSString *const __nonnull PSTCKSDKBuild = @"12";
@class PSTCKCard, PSTCKCardParams, PSTCKTransactionParams, PSTCKToken;
@@ -21,6 +21,7 @@ static NSString *const __nonnull PSTCKSDKBuild = @"11";
*/
typedef void (^PSTCKErrorCompletionBlock)(NSError * __nonnull error, NSString * __nullable reference);
typedef void (^PSTCKTransactionCompletionBlock)(NSString * __nonnull reference);
+typedef void (^PSTCKNotifyCompletionBlock)();
/**
A top-level class that imports the rest of the Paystack SDK. This class used to contain several methods to create Paystack tokens, but those are now deprecated in
@@ -67,16 +68,32 @@ typedef void (^PSTCKTransactionCompletionBlock)(NSString * __nonnull reference);
@interface PSTCKAPIClient (CreditCards)
/**
- * Converts an PSTCKCardParams object into a Paystack token using the Paystack API.
+ * Charges a PSTCKCardParams object using the Paystack API.
*
* @param card The user's card details. Cannot be nil. @see https://paystack.com/docs/api#create_card_token
- * @param completion The callback to run with the returned Paystack token (and any errors that may have occurred).
*/
- (void) chargeCard:(nonnull PSTCKCardParams *)card
forTransaction:(nonnull PSTCKTransactionParams *)transaction
onViewController:(nonnull UIViewController *)viewController
didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
- didRequestValidation:(nullable PSTCKTransactionCompletionBlock)beforeValidateCompletion
+ didRequestValidation:(nonnull PSTCKTransactionCompletionBlock)beforeValidateCompletion
+ didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion;
+
+- (void) chargeCard:(nonnull PSTCKCardParams *)card
+ forTransaction:(nonnull PSTCKTransactionParams *)transaction
+ onViewController:(nonnull UIViewController *)viewController
+ didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
+ didRequestValidation:(nonnull PSTCKTransactionCompletionBlock)beforeValidateCompletion
+ willPresentDialog:(nonnull PSTCKNotifyCompletionBlock)showingDialogCompletion
+ dismissedDialog:(nonnull PSTCKNotifyCompletionBlock)dialogDismissedCompletion
+ didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion;
+
+- (void) chargeCard:(nonnull PSTCKCardParams *)card
+ forTransaction:(nonnull PSTCKTransactionParams *)transaction
+ onViewController:(nonnull UIViewController *)viewController
+ didEndWithError:(nonnull PSTCKErrorCompletionBlock)errorCompletion
+ willPresentDialog:(nonnull PSTCKNotifyCompletionBlock)showingDialogCompletion
+ dismissedDialog:(nonnull PSTCKNotifyCompletionBlock)dialogDismissedCompletion
didTransactionSuccess:(nonnull PSTCKTransactionCompletionBlock)successCompletion;
@end
diff --git a/VERSION b/VERSION
index b502146..75a22a2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.0.2
+3.0.3