5

I would like to connect one Razorpay Payment API with WordPress, API has authentication token using username and password.

is there any builtin functionality available in WordPress to make a call and handle response?

Thamaraiselvam
  • 6,961
  • 8
  • 45
  • 71
Aiyaz Khorajia
  • 598
  • 2
  • 11
  • 2
    There is a plugin available for WooCommerce https://wordpress.org/plugins/woo-razorpay/. However, if you want to make custom calls using a builtin Wordpress function, you can make use of Requests Class. https://developer.wordpress.org/reference/classes/requests/ – Faisal Umair Oct 25 '17 at 05:50

1 Answers1

7

you can use wp_remote_get()

for example

wp_remote_get( 'http://www.example.com/index.php?action=foo', array( 'timeout' => 120, 'httpversion' => '1.1' ) );

you can also control all request parameters like headers and body data.

Default Usage

global $wp_version;
$args = array(
    'timeout'     => 5,
    'redirection' => 5,
    'httpversion' => '1.0',
    'user-agent'  => 'WordPress/' . $wp_version . '; ' . home_url(),
    'blocking'    => true,
    'headers'     => array(),
    'cookies'     => array(),
    'body'        => null,
    'compress'    => false,
    'decompress'  => true,
    'sslverify'   => true,
    'stream'      => false,
    'filename'    => null
); 

Reference : More info

Thamaraiselvam
  • 6,961
  • 8
  • 45
  • 71