有人可以帮我弄清楚为什么此条纹Webhook在测试模式下正确响应(通过给响应“ Worked!”),但是在实时模式下却没有响应!这是我的webhook端点:
<?php
require_once('../vendor/autoload.php');
// 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
\Stripe\Stripe::setApiKey("####");
// You can find your endpoint's secret in your webhook settings
$endpoint_secret = '####';
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400); // PHP 5.4 or greater
exit();
} catch(\Stripe\Error\SignatureVerification $e) {
// Invalid signature
http_response_code(400); // PHP 5.4 or greater
exit();
}
// This function is leveraged to search through the JSON for specific values
function searchArrayValueByKey(array $array, $search) {
foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $value) {
if ($search === $key)
return $value;
}
return false;
}
$input = @file_get_contents("php://input"); // this gets the POST data provided when the webhook pings this page
$event_json = json_decode($input, TRUE); // decode the JSON, and TRUE turns it into a multidimensional array
$type = searchArrayValueByKey($event_json, 'type'); // Check the type of event sent from Stripe.com - example "charge.succeeded"
switch ($type) { // depending on the event fired by Stripe, do something different.
case "account.updated":
echo 'Worked!';
break;
case "balance.available":
echo 'Worked!';
break;
case "charge.captured":
echo 'Worked!';
break;
case "charge.refunded":
echo 'Worked!';
break;
case "charge.succeeded":
echo 'Worked!';
break;
case "charge.updated":
echo 'Worked!';
break;
case "charge.failed":
echo 'Worked!';
break;
case "charge.dispute.created":
echo 'Worked!';
break;
case "charge.dispute.updated":
echo 'Worked!';
break;
case "charge.dispute.closed":
echo 'Worked!';
break;
case "coupon.created":
echo 'Worked!';
break;
case "coupon.deleted":
echo 'Worked!';
break;
case "customer.created":
echo 'Worked!';
break;
case "customer.updated":
echo 'Worked!';
break;
case "customer.deleted":
echo 'Worked!';
break;
case "customer.card.created":
echo 'Worked!';
break;
case "customer.card.updated":
echo 'Worked!';
break;
case "customer.card.deleted":
echo 'Worked!';
break;
case "customer.discount.created":
echo 'Worked!';
break;
case "customer.discount.updated":
echo 'Worked!';
break;
case "customer.discount.deleted":
echo 'Worked!';
break;
case "customer.subscription.created":
echo 'Worked!';
break;
case "customer.subscription.updated":
echo 'Worked!';
break;
case "customer.subscription.deleted":
echo 'Worked!';
break;
case "customer.subscription.trial_will_end":
echo 'Worked!';
break;
case "invoice.created":
echo 'Worked!';
break;
case "invoice.updated":
echo 'worked!';
break;
case "invoice.payment_succeeded":
echo 'Worked!';
break;
case "invoice.payment_failed":
echo 'Worked!';
break;
case "invoiceitem.created":
echo 'Worked!';
break;
case "invoiceitem.updated":
echo 'Worked!';
break;
case "invoiceitem.deleted":
echo 'Worked!';
break;
case "plan.created":
echo 'Worked!';
break;
case "plan.updated":
echo 'Worked!';
break;
case "plan.deleted":
echo 'Worked!';
break;
case "transfer.created":
echo 'Worked!';
break;
case "transfer.updated":
echo 'Worked!';
break;
case "transfer.paid":
echo 'Worked!';
break;
case "transfer.failed":
echo 'Worked!';
break;
default:
// An error has occured, this was not a Stripe.com event - log into your Stripe.com account and check the log.
}
http_response_code(200);
?>
在实时和测试之间切换时,我确保更改了我的秘密密钥和端点密钥。
我已经尝试了一切!甚至尝试联系条纹都无济于事,他们只是说他们无能为力。
任何对我做错事情的见解将不胜感激。