Skip to content

Instantly share code, notes, and snippets.

/Pay.php
Created Oct 9, 2017

Embed
What would you like to do?
<?php
$product_name = $_POST["product_name"];
$price = $_POST["product_price"];
$name = $_POST["name"];
$phone = $_POST["phone"];
$email = $_POST["email"];
include 'src/instamojo.php';
$api = new Instamojo\Instamojo('YOU_PRIVATE_API_KEY', 'YOUR_PRIVATE_AUTH_TOKEN','https://test.instamojo.com/api/1.1/');
try {
$response = $api->paymentRequestCreate(array(
"purpose" => $product_name,
"amount" => $price,
"buyer_name" => $name,
"phone" => $phone,
"send_email" => true,
"send_sms" => true,
"email" => $email,
'allow_repeated_payments' => false,
"redirect_url" => "http://YOUR_WEBSITE.COM/thankyou.php",
"webhook" => "http://YOUR_WEBSITE.COM/webhook.php"
));
//print_r($response);
$pay_ulr = $response['longurl'];
//Redirect($response['longurl'],302); //Go to Payment page
header("Location: $pay_ulr");
exit();
}
catch (Exception $e) {
print('Error: ' . $e->getMessage());
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.