在Stripe中一切工作正常 - 令牌生成,寫入儀表板中的「日誌」部分等。但沒有完成任何費用。即使我完成了條紋文檔給出的所有錯誤處理,我也沒有從Stripe或我的代碼中得到任何錯誤。我該如何解決這個問題?帶條紋充電卡
require_once ("vendor/autoload.php");
if ($_POST) {
echo "catch if";
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
StripeStripe::setApiKey("myApyKey");
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create a charge: this will charge the user's card
try {
echo "charging";
$charge = StripeCharge::create(array(
"amount" => 1000, // Amount in cents
"currency" => "eur",
"source" => $token,
"description" => "Example charge"
));
}
catch(StripeErrorCard $e) {
// Since it's a decline, \Stripe\Error\Card will be caught
$body = $e->getJsonBody();
$err = $body['error'];
print ('Status is:' . $e->getHttpStatus() . "\n");
print ('Type is:' . $err['type'] . "\n");
print ('Code is:' . $err['code'] . "\n");
// param is '' in this case
print ('Param is:' . $err['param'] . "\n");
print ('Message is:' . $err['message'] . "\n");
}
catch(StripeErrorRateLimit $e) {
// Too many requests made to the API too quickly
}
catch(StripeErrorInvalidRequest $e) {
// Invalid parameters were supplied to Stripe's API
}
catch(StripeErrorAuthentication $e) {
// Authentication with Stripe's API failed
// (maybe you changed API keys recently)
}
catch(StripeErrorApiConnection $e) {
// Network communication with Stripe failed
}
catch(StripeErrorBase $e) {
// Display a very generic error to the user, and maybe send
// yourself an email
}
catch(Exception $e) {
// Something else happened, completely unrelated to Stripe
}
你的漁獲大多默默地失敗。要麼刪除它們,要麼讓它們做一些明顯的事情,比如'print'OH SHIT Stripe InvalidRequest「;' – ceejayoz
在這行之後嘗試$ err = $ body ['error'];的print_r($ ERR);並看到錯誤。 –