【问题标题】:Instamojo - Adding Custom amountInstamojo - 添加自定义金额
【发布时间】:2016-04-11 09:01:01
【问题描述】:

我有一个嵌入了 instamojo 支付按钮的电子商务网站。我的 instamojo 仪表板中指定的金额是 200 印度卢比。我想动态更改金额,使其等于 mongodb 数据库中定义的金额。在不使用 REST API 的情况下如何实现?

例如:我希望金额值等于我的网站上为该特定产品指定的值,而不是 instamojo 支付网关上的“200 卢比”或“最低 200 卢比”。

【问题讨论】:

  • 这太离题了。应该关闭

标签: payment-gateway payment instamojo


【解决方案1】:

我认为没有像将价格值作为 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());
}

【讨论】:

  • 这太离题了。应该关闭
【解决方案2】:
<?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());
}

?>

【讨论】:

    猜你喜欢
    • 2020-09-02
    • 2021-10-25
    • 1970-01-01
    • 2012-06-29
    • 2016-01-01
    • 2016-02-11
    • 2020-01-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多