我有一个电子商务网站上,我嵌入了一个instamojo支付按钮。在我的instamojo仪表板中指定的金额是INR 200。我希望动态更改数量,使其与mongodb数据库中定义的数量相等。在不使用REST API的情况下,如何实现这一点?
例如:而不是在instamojo支付网关上的“200卢比”或“最低200卢比”,我希望金额的价值等于我的网站上为该特定产品指定的价值。
发布于 2016-08-19 23:26:31
我认为没有像将价格值作为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());
}发布于 2019-11-15 15:32:06
<?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'];
}
}包括'src/instamojo.php';
@$api =新建Instamojo\Instamojo(test_d895d58336b76a4042ae3b70851,test_12bb1df4f178cbbbed8ddaa3d9b,'https://test.instamojo.com/api/1.1/');
尝试{
$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();}
捕获(异常$e) {
print('Error: ' . $e->getMessage());}
?>
```javascripthttps://stackoverflow.com/questions/36544193
复制相似问题