Jump to content

simple payment form


mohammad2232
 Share

Recommended Posts

hello

i have 3 php smple file for local payment company that i tried to make simple form for work with that but really i can't do that!

i just read some php , html , css references in w3schools step by step but i don't know where is problem!?

these are free sample file

functions.php

function send($api, $amount, $redirect, $factorNumber=null) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://pay.ir/payment/send');
	curl_setopt($ch, CURLOPT_POSTFIELDS,"api=$api&amount=$amount&redirect=$redirect&factorNumber=$factorNumber");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	$res = curl_exec($ch);
	curl_close($ch);
	return $res;
}

function verify($api, $transId) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://pay.ir/payment/verify');
	curl_setopt($ch, CURLOPT_POSTFIELDS, "api=$api&transId=$transId");
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	$res = curl_exec($ch);
	curl_close($ch);
	return $res;
}

send.php

include_once("functions.php");
$api = 'test';
$amount = 'Amount';
$redirect = 'Callback';
$factorNumber = 123;
$result = send($api,$amount,$redirect,$factorNumber);
$result = json_decode($result);
if($result->status) {
	$go = "https://pay.ir/payment/gateway/$result->transId";
	header("Location: $go");
} else {
	echo $result->errorMessage;
}

verify.php

include_once("functions.php");
$api = 'test';
$transId = $_POST['transId'];
$result = verify($api,$transId);
$result = json_decode($result);
print_r($result);

and i create index.php

<!DOCTYPE html>
<html>
<body>

<form method="post" action="/send.php">
  Name: <input type="text" name="fname">
  <br>
  <br>
    price: <input type="number" name="Amount">

  <input type="submit">
</form>


</body>
</html>

but this is not work

can anybody help me thanks

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...