This worked for me (from 3rd-party Integration Github Issues)
It’s based on the maybe outdated MailChimp example
https://github.com/zaus/forms-3rdparty-integration/issues/74#issuecomment-260978289
I modified it slightly and added and modified some comments:
if(!class_exists('Forms3rdParty_Callbacks')):
/**
Encapsulate any and all 3rd-party service callback functions
*/
class Forms3rdParty_Callbacks {
public function __construct(){
// actions require 2 parameters: 3rd-party response, results placeholders
// NOTE: customize this hook name to match your Service (in the admin settings)
// or use Forms3rdPartyIntegration_service to affect all the forms
add_action('Forms3rdPartyIntegration_service', array(&$this, 'forms3rdParty_action'), 10, 2);
}//-- function __construct
/**
@Param $response the remote-request response
@Param $results
*/
public function forms3rdParty_action($response, $results){
try{
// look once more for success message, in case someone didn't set up the success clause
if( false !== strpos($response, '"status":"ok"') ) :
// Decode the received JSON to array
$response_json = json_decode($response, true);
//after converting to array output a certain json value (for example "description") to the success message next to the form on page, or whatever it might be in your case
$results['message'] = 'Success! The response;' $response_json["description"];
//This is used for adding things to mail (if sent)
$results['attach'] = $response;
else:
$results['errors'] = array('Failed');
endif;
} catch(Exception $ex){
$results['errors'] = array($ex->getMessage());
}
}//-- function 3rdParty_action
}//--- class Forms3rdParty_Callbacks
//start 'em up
$Forms3rdPartycallback_instance = new Forms3rdParty_Callbacks();
endif; //class-exists