function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
seriouslykylamvpseriouslykylamvp 

Callout without return 1% of instances

We have custom APEX code that utilizes a PaaS library from Click and Pledge. We make a call-out to Click & Pledge to process a credit card or ACH payment. Approximately 1% of the time, we never receive a response at all - the code just seems to terminate. It doesn't get to the next line of execution, and no exception is caught though it is in a try/catch block for a generic exception. We know the callout is definitely executed because a payment is created in Click & Pledge but there is no return happening.

How is it possible that the code doesn't make it to the line after the callout, and also doesn't go into the exception block? No engineer we've worked with who has looked at this has ever seen that happen. Is it some sort of network issue potentially? Also, we have never been able to reproduce this but we have done some tracking on how many times it happens and it's nearly consistently 1%. The reason this is such an important issue despite the low volume is because we think the payment hasn't gone through since we've created no record of it one way or the other due to the code never getting past the callout, so the parent is able to pay again, which makes them angry, looks bad for us, and causes a lot of refund work on our side.

Here is the block of code we are having an issue with. 

try {
result = PaymentProcessor.processCreditCard(itemName, itemPrice, creditCardInfo, tracker, false);//NAIS-1810

// [DP] 07.06.2015 NAIS-1933 Opp and sale TLI are now created just after payment attempt, regardless of whether or not it was successful
if (theOpportunity == null || theOpportunity.Id == null){
Opportunity createdOpp = FinanceAction.createOppAndTransaction(new Set{thePfs.Id}, false)[0];
theOpportunity.ID = createdOpp.Id;
}

if (result.isSuccess == true) {
// tliToUpdate.Transaction_Status__c = 'Posted';
transactionLineItemId = PaymentUtils.insertCreditCardTransactionLineItem(theOpportunity.Id, itemPrice, paymentData.ccCardType, paymentData.ccCardNumberLast4Digits, result);
}
else {
transactionLineItemId = PaymentUtils.insertCreditCardTransactionLineItem(theOpportunity.Id, itemPrice, paymentData.ccCardType, paymentData.ccCardNumberLast4Digits, result);
handleTransactionError(result);
}

} catch (Exception e){
if (PaymentProcessor.SETTINGS.Custom_Debug__c){
Custom_Debug__c cd = new Custom_Debug__c();
cd.Message__c = 'Processing failed: ' +e.getMessage();
insert cd;
}
this.pageError = true;
this.errorMessage = 'There was an error with your payment. Please contact NAIS before retrying. Error: ' + e.getMessage();
return handlePaymentError();
}
Daniel BallingerDaniel Ballinger
One possibility is Apex throwing an exception that you can't catch. It may be that the SOAP response exceeds the allowed heap size. Or it may be a limit exception on how long the Apex can execute for.

Are you getting any Unhandled Apex Exception emails?