Table of Contents
Overview
The RequestQueueStatus 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. This was formerly known as the OfflineProcessingManager class in the old API.
You can also utilize the RequestQueueStatus to process and retry failed transactions, as included in the examples below.
Implementation
*Implementation of the RequestQueueStatus class and the following functionality is mandatory if you wish to process offline transactions (including deferred authorizations). Please note, that it is the responsibility of the integrator 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.
Android:
log("Querying offline queue..."); // Create a Parameters object and fill it with ChipDnaMobile status Parameters statusParameters = ChipDnaMobile.getInstance().getStatus(null); try { // Deserialize the RequestQueueStatus key value from the status parameters into a RequestQueueStatus object RequestQueueStatus reqQueueStatus = ChipDnaMobileSerializer.deserializeRequestQueueStatus(statusParameters.getValue(ParameterKeys.RequestQueueStatus)); // Log useful information regarding the pending and failed queue, as well as type of failed log("Pending: "+reqQueueStatus.getTotalNumberOfPendingRequests()); log("Failed: "+reqQueueStatus.getTotalNumberOfFailedRequests()); log("Pending Req Total: "+reqQueueStatus.getPendingRequestTotalsByRequestType()); // Iterate through our failed offline requests, pulling the userReference if (reqQueueStatus.getTotalNumberOfFailedRequests() > 0) { log("Retrying failed requests..."); // Iterate through our failed offline requests, pulling the userReference for (String userReference : reqQueueStatus.getFailedOfflineRequests()) { Parameters userReferenceParameters = new Parameters(); userReferenceParameters.add(ParameterKeys.UserReference, userReference); // Retry the failed transaction Parameters response = ChipDnaMobile.getInstance().retryFailedOfflineRequest(userReferenceParameters); // Report if transaction retry attempt is successful or not if (response.containsKey(ParameterKeys.TransactionResult) && response.getValue(ParameterKeys.TransactionResult).equals(ParameterValues.Approved)) log(userReference+" : Approved"); else log(userReference+" : Declined"); // Report any errors if (response.containsKey(ParameterKeys.Result) && response.getValue(ParameterKeys.Result).equals(ParameterValues.FALSE)) log("Error: " + response.getValue(ParameterKeys.Error)); } } } catch (XmlPullParserException|IOException e) { log(e.getLocalizedMessage()); }
iOS:
[self log:@"Querying offline queue..."]; // Create a Parameters object and fill it with ChipDnaMobile status CCParameters *statusParameters = [[ChipDnaMobile sharedInstance] getStatus:nil]; // Deserialize the CCParamRequestQueueStatus key value from the status parameters into a RequestQueueStatus object RequestQueueStatus *reqQueueStatus = [ChipDnaMobileSerializer deserializeRequestQueueStatus:[statusParameters valueForKey:CCParamRequestQueueStatus]]; // Log useful information regarding the pending and failed queue, as well as type of failed [self log:[NSString stringWithFormat:@"Pending: %ld", (long)reqQueueStatus.totalNumberOfPendingRequests]]; [self log:[NSString stringWithFormat:@"Failed: %ld", (long)reqQueueStatus.totalNumberOfFailedRequires]]; [self log:[NSString stringWithFormat:@"Pending Req Total: %ld", (long)reqQueueStatus.totalPendingValueStored]]; if (reqQueueStatus.totalNumberOfFailedRequires > 0 ) { [self log:@"Retrying failed requests..."]; // Iterate through our failed offline requests, pulling the userReference for (NSString * userReference in [reqQueueStatus failedOfflineRequests]) { CCParameters * userReferenceParameters = [[CCParameters alloc] init]; [userReferenceParameters setValue:userReference forKey:CCParamUserReference]; // Retry the failed transaction CCParameters * response = [[ChipDnaMobile sharedInstance] retryFailedOfflineRequest:userReferenceParameters]; // Report if transaction retry attempt is successful or not if ([[response valueForKey:CCParamTransactionResult] isEqualToString:CCValueApproved]) { [self log:[NSString stringWithFormat:@"%@ : Approved", userReference]]; } else { [self log:[NSString stringWithFormat:@"%@ : Declined", userReference]]; } // Report any errors if([[response valueForKey:CCParamError] isEqualToString:CCValueFalse]){ [self log:[NSString stringWithFormat:@"Error: %@", [response valueForKey:CCParamError]]]; } } }