3

I have a problem. I should do a custom gateway. I know the basics. I read the documentation. URL data to be transmitted (such as user name, the amount of the transaction). My question is how to redirect the user to the payment page of the bank? What is the command and where to give the exact url? And then the returned data must be processed what method? cURL or something else? I could not find any real solution to the problem.

szebasztian
  • 171
  • 3
  • 14

1 Answers1

1

Different gateway's have different needs, if your gateway uses a POST, you can use this to POST the data, and get a response.. it is better than cURL.

$response = wp_remote_post( $environment_url, array(
                    'method'    => 'POST',
                    'body'      => http_build_query( $payload ),
                    'timeout'   => 90,
                    'sslverify' => false,
                ) );

// Retrieve the body's response if no errors found
$response_body = wp_remote_retrieve_body( $response );
$response_headers = wp_remote_retrieve_headers( $response );

// Payload would look something like this.
$payload = array(
    "amount" => $order.get_total(), 
    "reference" => $order->get_order_number(),
    "orderid" => $order->id,
    "return_url" => $this->get_return_url($order)  //return to thank you page.
);

//use this if you need to redirect the user to the payment page of the bank.
$querystring = http_build_query( $payload );

return array(
                'result'   => 'success',
                'redirect' => $environment_url . '?' . $querystring,
            );
hamish
  • 1,141
  • 1
  • 12
  • 21