0
我遇到了Stripe問題,它會很高興地創建令牌並將其發送到我的PHP充電腳本,此時在條紋控制面板上創建了一個200 OK - Token
日誌。它只是不會收費的卡,據我所知,我已經做好了一切,我沒有得到任何錯誤,在PHP或從條紋API。Stripe not being the cards
error_reporting(E_ALL);
ini_set('display_errors', 1);
$error = 0;
require_once('stripe-php-master/init.php');
$trialAPIKey = "sk_test_???"; // These are the SECRET keys!
$liveAPIKey = "sk_live_???";
\Stripe\Stripe::$apiBase = "https://api-tls12.stripe.com";
// Switch to change between live and test environments
\Stripe\Stripe::setApiKey($trialAPIKey);
/* \Stripe\Stripe::setApiKey($liveAPIKey); */
$token = $_POST['token'];
$price = $_POST['amount'];
$price = $price * 100;
$desc = $_POST['desc'];
try {
$charge = \Stripe\Charge::create(array(
"amount" => $price,
"currency" => "gbp",
"source" => $token,
"description" => $desc
));
} catch(\Stripe\Error\Card $e) {
// The card has been declined
$error++;
}
if($error>=1) {
echo "There was an error processing your card, please try again.";
} else {
echo "Thank you, your payment was successful.";
}