• seriouslykylamvp
  • NEWBIE
  • 0 Points
  • Member since 2013


  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
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();
}

The organization uses the nonprofit Common Ground application to manage their donations and it has a ton of validation rules, workflow rules, triggers and more. However, they have pulled the plug on the product and will shut it down in a couple months. So of course now we're seeing issues that never came up before. Namely, on entering a new opportunity the following error pops up:

 

Invalid data. Review all error messages below to correct your data. Apex trigger cx.OpprtunityAll caused and unexpected exception, contact your administrator. cx.OpportunityAll: execution of AfterUpdate caused by: System.DmlExcepption: Update failed. First exception on row 0 with id a0eF0000002JL9nlAG; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION. Pledges from organizations should always have the organization's Org Donor Proxy as the Contact.: [cx__Contact__c]: (cx)

ac

Let me know what else you need to help us sort this out. Thank you!

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();
}