Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -74,7 +74,7 @@ class stripeWebhookHandler
|
||||
}
|
||||
|
||||
/* Validate the source with Stripe */
|
||||
$source = $this->transaction->method->api( 'sources/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
$source = $this->transaction->method->api( 'sources/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ), null, 'get' );
|
||||
if ( $source['client_secret'] != $this->data['data']['object']['client_secret'] )
|
||||
{
|
||||
throw new \Exception('BAD_SECRET');
|
||||
@@ -130,7 +130,7 @@ class stripeWebhookHandler
|
||||
/* Validate the charge with Stripe */
|
||||
try
|
||||
{
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ), null, 'get' );
|
||||
if ( !\in_array( $charge['status'], array( 'succeeded', 'paid' ) ) )
|
||||
{
|
||||
throw new \Exception;
|
||||
@@ -206,7 +206,7 @@ class stripeWebhookHandler
|
||||
/* Validate the charge with Stripe */
|
||||
try
|
||||
{
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ), null, 'get' );
|
||||
if ( !\in_array( $charge['status'], array( 'succeeded', 'paid' ) ) )
|
||||
{
|
||||
throw new \Exception;
|
||||
@@ -281,7 +281,7 @@ class stripeWebhookHandler
|
||||
/* Validate the charge with Stripe */
|
||||
try
|
||||
{
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
$charge = $this->transaction->method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ), null, 'get' );
|
||||
if ( $charge['status'] !== 'failed' )
|
||||
{
|
||||
throw new \Exception;
|
||||
@@ -323,7 +323,7 @@ class stripeWebhookHandler
|
||||
/* Validate the dispute with Stripe */
|
||||
try
|
||||
{
|
||||
$dispute = $this->transaction->method->api( 'disputes/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
$dispute = $this->transaction->method->api( 'disputes/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ), null, 'get' );
|
||||
if ( !\in_array( $dispute['status'], array( 'needs_response', 'warning_needs_response' ) ) )
|
||||
{
|
||||
throw new \Exception;
|
||||
@@ -331,7 +331,7 @@ class stripeWebhookHandler
|
||||
|
||||
if ( \substr( $this->transaction->gw_id, 0, 3 ) === 'pi_' )
|
||||
{
|
||||
$paymentIntent = $this->transaction->method->api( 'payment_intents/' . $this->transaction->gw_id );
|
||||
$paymentIntent = $this->transaction->method->api( 'payment_intents/' . $this->transaction->gw_id, null, 'get' );
|
||||
|
||||
$ok = FALSE;
|
||||
foreach ( $paymentIntent['charges']['data'] as $charge )
|
||||
@@ -398,7 +398,7 @@ class stripeWebhookHandler
|
||||
$dispute = $this->transaction->method->api( 'disputes/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['id'] ) );
|
||||
if ( \substr( $this->transaction->gw_id, 0, 3 ) === 'pi_' )
|
||||
{
|
||||
$paymentIntent = $this->transaction->method->api( 'payment_intents/' . $this->transaction->gw_id );
|
||||
$paymentIntent = $this->transaction->method->api( 'payment_intents/' . $this->transaction->gw_id, null, 'get' );
|
||||
|
||||
$ok = FALSE;
|
||||
foreach ( $paymentIntent['charges']['data'] as $charge )
|
||||
@@ -476,7 +476,7 @@ class stripeWebhookHandler
|
||||
{
|
||||
try
|
||||
{
|
||||
$charge = $method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['charge'] ) );
|
||||
$charge = $method->api( 'charges/' . preg_replace( '/[^A-Z0-9_]/i', '', $this->data['data']['object']['charge'] ), null, 'get' );
|
||||
if ( isset( $charge['payment_intent'] ) )
|
||||
{
|
||||
$paymentIntentId = $charge['payment_intent'];
|
||||
@@ -618,6 +618,7 @@ class stripeWebhookHandler
|
||||
$class = new stripeWebhookHandler( trim( @file_get_contents('php://input') ) );
|
||||
try
|
||||
{
|
||||
sleep( 5 ); // Stripe can send web hooks very quickly, we need to delay to ensure we've processed the transaction first.
|
||||
$response = $class->run( isset( $_SERVER['HTTP_STRIPE_SIGNATURE'] ) ? $_SERVER['HTTP_STRIPE_SIGNATURE'] : '' );
|
||||
\IPS\Output::i()->sendOutput( $response, 200, 'text/plain' );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user