使用codeigniter的条带支付无法获得动态金额


stripe payment using codeigniter not getting dynamic amount

每当我在金额字段中添加静态金额值时,它都可以正常工作但无论我在哪里使它动态,它都会在这个页面上向我显示一个空白页面,没有错误/Stripe_payment/checkout。

require_once(APPPATH . 'libraries/Stripe/lib/Stripe.php');
    // Get the credit card details submitted by the form
    if(isset($_POST['stripeToken'])){
        $token = $_POST['stripeToken'];
    }
    $txtPayTotalp = $_POST['txtPayTotalp'];
    $txtPayIdp = $_POST['txtPayIdp'];
    $p = array(
        "amount" => $_POST['txtPayTotalp'],
        "currency" => "aud",
        "card" => $token,
        "description" => "hlkglfjfltylthyjl"
    );
    $charge = Stripe_Charge::create( $p );

这是我的控制器Stripe_payment.php

   <form class="form-horizontal" id="form-pay" action="<?php echo base_url('index.php/Stripe_payment/checkout'); ?>" method="POST" style="padding-top:10px !important; margin-left: 250px;">
           <input type="hidden" name="txtPayTotalp" id="txtPayTotalp" value="">
           <input type="hidden" name="txtPayIdp" id="txtPayIdp" value="">
        <script id="a1"
            src="https://checkout.stripe.com/checkout.js" class="stripe-button"
            data-key="Key"
            data-image="<?php echo base_url('img/hederImg.png'); ?>"
            data-name="PREST LAUNDRY"
            data-description="So Clean............"
            data-amount="2345"
           >
        </script>
    </form>

这是我的观点。请帮我解决这个问题提前谢谢。

  // Get the credit card details submitted by the form
            if(isset($_POST['stripeToken'])){
                $token = $_POST['stripeToken'];
            }
            // Create a Customer
            $customer = Stripe_Customer::create(array(
              "source" => $token,
              "description" => "Test Customer")
            );       
            $txtPayTotalp = $_POST['txtPayTotalp'];
            $txtPayIdp = $_POST['txtPayIdp'];
            $this->session->set_userdata('amount', $_POST['txtPayTotalp']);
            $val = floatval($this->session->userdata('amount'));
            $p = array(
                "amount" => $val,
                "currency" => "usd",
                "card" => $token,
                "description" => "Test Payment"
            );

为了检查金额的数据类型,我检查了vardump($p);金额为字符串格式。我使用floatval()来更改amount的数据类型,它很有效。

$val=floatval($this->session->userdata('amount'));