PHP code example of paytring / php
1. Go to this page and download the library: Download paytring/php library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
paytring / php example snippets
$api_key = "test_123";
$api_secret = "secret_123";
$paytring = new \Paytring\Php\Api($api_key, $api_secret);
$amount_in_paisa = "100";
$receipt_number = "10123450";
$merchant_callback_url = "https://httpbin/post";
$customer_info = [
'name' => 'John Doe',
'email' => '[email protected] ',
'phone' => '9234567890',
];
$payment_info = [
"currency" => "INR",
"pg" => "payu",
"pg_pool_id" => ""
];
$billing_address = [
"firstname" => "BillingFirstname",
"lastname" => "BillingLastname",
"phone" => "09999999999",
"line1" => "Billing Address Line 1",
"line2" => "Billing Address Line 2",
"city" => "Gurugram",
"state" => "Haryana",
"country" => "India",
"zipcode" => "122001"
];
$shipping_address = [
"firstname" => "ShippingFirstname",
"lastname" => "ShippingLastname",
"phone" => "09999999999",
"line1" => "Shipping Address Line 1",
"line2" => "Shipping Address Line 2",
"city" => "Gurugram",
"state" => "Haryana",
"country" => "India",
"zipcode" => "122001"
];
$notes = [
"udf1" => "udf1",
"udf2" => "udf2",
"udf3" => "udf3",
"udf4" => "udf4",
"udf5" => "udf5"
];
$response = $paytring->CreateOrder(
$amount_in_paisa,
$receipt_number,
$merchant_callback_url,
$customer_info,
$payment_info,
$billing_address,
$shipping_address,
$notes
);
var_dump($response);
$api_key = "test_123";
$api_secret = "secret_123";
$paytring = new \Paytring\Php\Api($api_key, $api_secret);
$pg_order_id = "d234ew32r4345fd";
$fetch_response = $paytring->FetchOrder($pg_order_id);
var_dump($fetch_response);