我有一个电子商务网站,在该网站上嵌入了一个 instamojo 支付按钮。我的 instamojo 仪表板中指定的金额是 200 卢比。我想动态更改金额,使其等于 mongodb 数据库中定义的金额。我如何在不使用 REST API 的情况下实现这一目标?
例如:我希望金额值等于我的网站上为该特定产品指定的值,而不是 instamojo 支付网关上的“Rs 200”或“Minimum Rs 200”。
我有一个电子商务网站,在该网站上嵌入了一个 instamojo 支付按钮。我的 instamojo 仪表板中指定的金额是 200 卢比。我想动态更改金额,使其等于 mongodb 数据库中定义的金额。我如何在不使用 REST API 的情况下实现这一目标?
例如:我希望金额值等于我的网站上为该特定产品指定的值,而不是 instamojo 支付网关上的“Rs 200”或“Minimum Rs 200”。
我认为没有像将价格值作为 URL 变量传递的简单方法。您需要使用 REST API 或 php 库并通过
try {
$response = $api->paymentRequestCreate(array(
"purpose" => "FIFA 16",
"amount" => "3499",
"send_email" => true,
"email" => "foo@example.com",
"redirect_url" => "http://www.example.com/handle_redirect.php"
));
print_r($response);
}
catch (Exception $e) {
print('Error: ' . $e->getMessage());
}
<?php
include 'database.php';//include database
$pricesql="SELECT * FROM `price`";//this is price table which i can update and this table contain 3 type of price
$response=mysqli_query($conn,$pricesql);
$price=mysqli_fetch_assoc($response);
$price_teacher= $price['price_teacher'];
$price_student= $price['price_student'];
$price_institute= $price['price_institute'];
}
}
```
include 'src/instamojo.php';
@$api = new Instamojo\Instamojo(test_d895d58336b76a4042ae3b70851, test_12bb1df4f178cbbbed8ddaa3d9b, 'https://test.instamojo.com/api/1.1/');
try {
$response = $api->paymentRequestCreate(array(
"purpose" => $product_name,
"custom_fields"=>$cars,
"amount" => $price,//here you can pass amount(remove my comment)
"send_email" => true,
"email" => $email,
"buyer_name"=> $name,
"phone"=>$phone,
"send_sms"=> true,
"allow_repeated_payments"=>false,
"redirect_url" => "http://localhost/bteacher/thankyou.php"
//"webhook"=>
));
$pay_url = $response['longurl'];
header("Location: $pay_url");
exit();
}
catch (Exception $e) {
print('Error: ' . $e->getMessage());
}
?>