Table of Contents
Overview
The OfflineProcessingManager
Class is used to access the details of stored pending and failed requests. This includes details such as the number of requests in the offline pending and failed queues, as well as the total amount stored within each queue. It also provides the functionality to delete or retry transactions stored in the failed request queue.
*Implementation of the OfflineProcessingManager
Class and the following functionality is mandatory if you wish to process offline transactions.
Logging Offline Requests
The integrator will need to keep a log of all pending and failed offline requests. We suggest that this log is ideally stored in a back office for ease of access and retrieval if logs are requested by Creditcall.
Items that need to be logged:
- Total number of stored pending offline requests:
- iOS:
- (NSInteger) numberOfStoredRequestsError: (NSError **) error
- Android:
public int numberOfStoredRequests( ) throws StorageException
- iOS:
- Total number of stored failed offline requests:
- iOS:
- (NSInteger) numberOfFailedRequestsError: (NSError **) error
- Android:
public int numberOfFailedRequests() throws StorageException
- iOS:
- The amount, date and time, type of transaction, user reference, and error codes for all failed transactions:
- iOS:
NSError *e; // initialize Offline Processing Manager OfflineProcessingManager *offlineProcessingManager = [[OfflineProcessingManager alloc] init]; NSArray *failedOfflineRequests = [offlineProcessingManager failedOfflineRequestsError:&e]; for(OfflineRequest *request in failedOfflineRequests){ NSLog(@"Amount: %@ \nDate/Time: %@ \nType: %@\nUser Reference: %@\n\n", request.amount, request.dateTime, request.Type, request.UserReference); }
- Android:
OfflineProcessingManager offlineProcessingManager = new OfflineProcessingManager(); List<OfflineRequest> failedOfflineRequests = null; try { failedOfflineRequests = offlineProcessingManager.failedOfflineRequests(); } catch (StorageException e) { e.printStackTrace(); } if(failedOfflineRequests != null) { for (OfflineRequest failedOfflineRequest : failedOfflineRequests) { //Log the following items Log.d("Amount: ", failedOfflineRequest.amount()); Log.d("DateAndTime: ", failedOfflineRequest.dateAndTime()); Log.d("Type: ", failedOfflineRequest.type().toString()); Log.d("UserReference: ", failedOfflineRequest.userReference()); Log.d("ErrorCodes: ", failedOfflineRequest.errorCodes().toString()); } } }
- iOS:
Retry Failed Transactions
The integrator will need to implement the following function so that failed transactions can be retried. We suggest that this functionality be hidden in a settings menu / password protected so staff do not keep resubmitted failed transactions when it isn't required. Please note, it is the integrators responsibility to ensure all transactions have reached our platform and are confirmed/committed. The below example is to provide a working code example but does not keep on retrying to submit a failed transaction until approved/declined by our platform. This is something your integration needs to do.
- Resend a failed transaction request:
- iOS:
//Invoked when the resending of the failed offline request is completed. //OfflineDelegate in .h equivalent OfflineProcessingManager *offlineProcessingManager = [[OfflineProcessingManager alloc] init]; NSArray *failedOfflineRequests = [offlineProcessingManager failedOfflineRequestsError:&e]; // Example on how to send the failed offline request at index 0 OfflineRequest *firstFailed = [failedOfflineRequests firstObject]; if(firstFailed) { offlineProcessingManager resendFailedTransactionRequest:firstFailed delegate:self error:&e] } else { NSLog(@"No failed offline requests remaining"); } // offlineRequest will also need to be implemented -(void)offlineRequest:(OfflineRequest *)request resent:(BOOL)success errorCodes:(NSArray *)errorCodes{ if(success){ NSLog("offlineRequest successful"); } else { NSLog(@"Error: %@", errorCodes); } }
- Android:
//Invoked when the resending of the failed offline request is completed. IOfflineListener offlineListener = new IOfflineListener() { @Override public void offlineRequestResent(OfflineRequest offlineRequest, boolean b, List<CardEaseMobileErrorCode> list) { //Check whether the resent request was successful } }; //... //Example on how to send the failed offline request at index 0 of List<OfflineRequest> OfflineProcessingManager offlineProcessingManager = new OfflineProcessingManager(); List<OfflineRequest> failedOfflineRequests = null; try { failedOfflineRequests = offlineProcessingManager.failedOfflineRequests(); } catch (StorageException e) { e.printStackTrace(); } if(failedOfflineRequests != null) { OfflineRequest failedOfflineRequest = failedOfflineRequests.get(0); try { offlineProcessingManager.resendFailedTransactionRequest(failedOfflineRequest, offlineListener); } catch (StorageException e) { e.printStackTrace(); } }
- iOS: