Skip to content

Instantly share code, notes, and snippets.

Created October 9, 2017 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7b0276ccd6c726e64c506c71cb7f9ca3 to your computer and use it in GitHub Desktop.
Save anonymous/7b0276ccd6c726e64c506c71cb7f9ca3 to your computer and use it in GitHub Desktop.
<?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