Version 5.0.0 beta 9
This commit is contained in:
1 parent
214f649f1d
commit
56979f8ee8
202 files changed
+4403
-1123
No files matched your search
@@ -329,61 +329,6 @@ class stripeWebhookHandler
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
/**
|
||||
* A payment intent failed so we need to mark the transaction as failed locally
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function paymentIntentFailed(): string
|
||||
{
|
||||
/* Check the status */
|
||||
if ( !in_array( $this->transaction->status, [ Transaction::STATUS_GATEWAY_PENDING, Transaction::STATUS_PENDING ] ) )
|
||||
{
|
||||
if ( $this->transaction->status === Transaction::STATUS_REFUSED )
|
||||
{
|
||||
return 'ALREADY_PROCESSED';
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('BAD_STATUS');
|
||||
}
|
||||
}
|
||||
|
||||
/* Validate the charge with Stripe */
|
||||
try
|
||||
{
|
||||
$pi = $this->transaction->method->api( 'payment_intents/' . $this->data['data']['object']['id'], null, 'get' );
|
||||
if ( !is_array( $pi['last_payment_error'] ) )
|
||||
{
|
||||
throw new Exception;
|
||||
}
|
||||
}
|
||||
catch ( Exception $e )
|
||||
{
|
||||
throw new Exception('INVALID_PI');
|
||||
}
|
||||
|
||||
/* Mark it failed */
|
||||
$this->transaction->status = Transaction::STATUS_REFUSED;
|
||||
$extra = $this->transaction->extra;
|
||||
$extra['history'][] = array( 's' => Transaction::STATUS_REFUSED, 'noteRaw' => $this->data['data']['object']['last_payment_error']['message'] );
|
||||
$this->transaction->extra = $extra;
|
||||
$this->transaction->save();
|
||||
$this->transaction->member->log( 'transaction', array(
|
||||
'type' => 'paid',
|
||||
'status' => Transaction::STATUS_REFUSED,
|
||||
'id' => $this->transaction->id,
|
||||
'invoice_id' => $this->transaction->invoice->id,
|
||||
'invoice_title' => $this->transaction->title,
|
||||
), FALSE );
|
||||
|
||||
/* Send notification */
|
||||
$this->transaction->sendNotification();
|
||||
|
||||
/* Return */
|
||||
return 'OK';
|
||||
}
|
||||
|
||||
/**
|
||||
* A chargeback/dispute has been made against a transaction so we need to mark it as such locally
|
||||
*
|
||||
@@ -520,7 +465,7 @@ class stripeWebhookHandler
|
||||
public function run( string $signature ) : string
|
||||
{
|
||||
/* Ignore anything we don't care about */
|
||||
if ( !isset( $this->data['type'] ) or !in_array( $this->data['type'], array( 'source.chargeable', 'charge.succeeded', 'charge.failed', 'charge.dispute.created', 'charge.dispute.closed', 'payment_intent.payment_failed' ) ) )
|
||||
if ( !isset( $this->data['type'] ) or !in_array( $this->data['type'], array( 'source.chargeable', 'charge.succeeded', 'charge.failed', 'charge.dispute.created', 'charge.dispute.closed' ) ) )
|
||||
{
|
||||
return 'UNNEEDED_TYPE';
|
||||
}
|
||||
@@ -679,8 +624,6 @@ class stripeWebhookHandler
|
||||
return $this->disputeCreated();
|
||||
case 'charge.dispute.closed':
|
||||
return $this->disputeClosed();
|
||||
case 'payment_intent.payment_failed':
|
||||
return $this->paymentIntentFailed();
|
||||
default:
|
||||
return 'UNNEEDED_TYPE';
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user