mirror of
https://github.com/itflow-org/itflow
synced 2026-12-06 19:19:00 +00:00
Bump stripe-php from 21.0.0 to 21.3.2
This commit is contained in:
@@ -42,6 +42,13 @@ abstract class WebhookSignature
|
||||
$header
|
||||
);
|
||||
}
|
||||
if (empty($secret)) {
|
||||
throw Exception\SignatureVerificationException::factory(
|
||||
'No webhook secret value was provided. It should start with `whsec_`',
|
||||
$payload,
|
||||
$header
|
||||
);
|
||||
}
|
||||
|
||||
// Check if expected signature is found in list of signatures from
|
||||
// header
|
||||
@@ -124,6 +131,27 @@ abstract class WebhookSignature
|
||||
return $signatures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the `Stripe-Signature` header for a given webhook body & secret. Useful for signing payloads in unit tests.
|
||||
*
|
||||
* @param string $payload the webhook body to sign
|
||||
* @param string $secret the webhook endpoint's signing secret
|
||||
* @param null|int $timestamp unix timestamp to use (defaults to current time)
|
||||
*
|
||||
* @return string the full `Stripe-Signature` header value
|
||||
*/
|
||||
public static function generateSignatureHeader($payload, $secret, $timestamp = null)
|
||||
{
|
||||
if (null === $timestamp) {
|
||||
$timestamp = \time();
|
||||
}
|
||||
$scheme = self::EXPECTED_SCHEME;
|
||||
$signedPayload = "{$timestamp}.{$payload}";
|
||||
$signature = self::computeSignature($signedPayload, $secret);
|
||||
|
||||
return "t={$timestamp},{$scheme}={$signature}";
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the signature for a given payload and secret.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user