Skip to content

Commit 6d3bb56

Browse files
committed
[fix] PROCESSING should not be stopped whe throwing a Conflict Error
1 parent 5da3917 commit 6d3bb56

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

-127 KB
Loading
-127 KB
Loading

Paystack/PSTCKAPIClient.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,14 @@ - (void) makeChargeRequest:(NSData *)data
333333
atStage:stage];
334334
return;
335335
}
336+
if([[responseObject message].lowercaseString isEqual:@"access code has expired"] && [[responseObject status] isEqual:@"0"]){
337+
NSDictionary *userInfo = @{
338+
NSLocalizedDescriptionKey: PSTCKExpiredAccessCodeErrorMessage,
339+
PSTCKErrorMessageKey: PSTCKExpiredAccessCodeErrorMessage
340+
};
341+
[self didEndWithError:[[NSError alloc] initWithDomain:PaystackDomain code:PSTCKExpiredAccessCodeError userInfo:userInfo]];
342+
return;
343+
}
336344
[self handleResponse:responseObject];
337345
}];
338346
}
@@ -502,7 +510,9 @@ - (void)didEndWithProcessingError{
502510
NSLocalizedDescriptionKey: PSTCKCardErrorProcessingTransactionMessage,
503511
PSTCKErrorMessageKey: PSTCKCardErrorProcessingTransactionMessage
504512
};
505-
[self didEndWithError:[[NSError alloc] initWithDomain:PaystackDomain code:PSTCKConflictError userInfo:userInfo]];
513+
[self.operationQueue addOperationWithBlock:^{
514+
self.errorCompletion([[NSError alloc] initWithDomain:PaystackDomain code:PSTCKConflictError userInfo:userInfo], self.serverTransaction.reference);
515+
}];
506516
}
507517

508518
@end

Paystack/PublicHeaders/PaystackError.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ typedef NS_ENUM(NSInteger, PSTCKErrorCode) {
1818
PSTCKCardErrorProcessingError = 80, // Paystack Checkout encountered an error.
1919
PSTCKTransactionError = 90, // Something was wrong with the given transaction details.
2020
PSTCKConflictError = 100, // A transaction was started while SDK was processing another
21+
PSTCKExpiredAccessCodeError = 110, // The access code is not usable
2122
};
2223

2324
#pragma mark userInfo keys
@@ -50,6 +51,7 @@ FOUNDATION_EXPORT NSString * __nonnull const PSTCKIncorrectCVC;
5051

5152
#pragma mark Strings
5253

54+
#define PSTCKExpiredAccessCodeErrorMessage NSLocalizedString(@"There was a problem completing your request", @"Error when access code has no valid transaction")
5355
#define PSTCKCardErrorInvalidNumberUserMessage NSLocalizedString(@"Your card's number is invalid", @"Error when the card number is not valid")
5456
#define PSTCKCardErrorProcessingTransactionMessage NSLocalizedString(@"Please wait", @"Error when chargeCard is called while the SDK is still processing a transaction")
5557
#define PSTCKCardErrorInvalidCVCUserMessage NSLocalizedString(@"Your card's security code is invalid", @"Error when the card's CVC is not valid")

0 commit comments

Comments
 (0)