IV. Processing

processgateway_function( $payment_type, $details )

This function is hooked to the wpjobster_processafter_sample_gateway action, which is called when your gateway responds to the site with the payment status.

First of all you need to check if the answer from the gateway is successful. We also recommend checking if the amount paid is correct.

Then, based on the response that you get, you have 2 actions that you can run and the rest of the work is done on our side.

Example:

function processgateway_function( $payment_type, $details ) {
 
    $credentials        = $this->get_gateway_credentials();
    $key                = $credentials['key'];
    $merchant_key       = $credentials['merchant_key'];
    $sample_payment_url = $credentials['sample_payment_url'];
 
    // you will usually get the response from the gateway as $_POST
    $status   = $_POST['status'];
    $amount   = $_POST['amount'];
    $order_id = $_POST['order_id'];
 
    $payment_response = $serialise = maybe_serialize( $_REQUEST );
 
    if ( $status == 'success' ) {
        $payment_details = "success action returned"; // any info you may find useful for debug
        do_action( "wpjobster_" . $payment_type . "_payment_success",
            $order_id,
            $this->unique_slug,
            $payment_details,
            $payment_response
        );
        die();
    } else {
        $payment_details = "Failed action returned"; // any info you may find useful for debug
        do_action( "wpjobster_" . $payment_type . "_payment_failed",
            $order_id,
            $this->unique_slug,
            $payment_details,
            $payment_response
        );
        die();
    }
}