簡體   English   中英

在Stripe Payment Gateway中使用變量作為金額

[英]Using a variable for amount in Stripe Payment Gateway

我正在嘗試將Stripe付款集成到我的網站上。 我有一個PHP變量'$ val',其價格是從表單發送的

$val = $_POST['myFieldName'];

我正在嘗試使用此變量來收取條紋持有的數量

 Stripe_Charge::create(array(
                             "amount" =>  $val ,
                            "currency" => "gbp",
                            "card" => $_POST['stripeToken']));

但是似乎Stripe除了這個變量不會。 它在頁面上顯示“ Missing required param:amount”錯誤。它只想接受一個實際的整數,例如“ 1234”,我嘗試使用=> intval($ var)螺母將其強制轉換為int,但沒有任何樂趣。 有人可以告訴我我要去哪里錯了

Thnks

你應該試試這個

Stripe_Charge::create(array(
  "amount" => 400,
  "currency" => "usd",
  "card" => "tok_14igbg2eZvKYlo2Cm0Akcrhg", // obtained with Stripe.js
  "description" => "Charge for test@example.com"
));

根據文檔缺少description字段

我遇到同樣的問題,但是當您最終進入付款頁面時,這是我的編碼錯誤,只需在表單提交按鈕“ name =“ myFieldName”>前添加此行

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM