Stripe: Support for new webhooks format

This commit is contained in:
Benjamin Beganović 2021-08-04 16:19:01 +02:00
parent 6740e348a1
commit ab890f770e

View File

@ -387,21 +387,23 @@ class StripePaymentDriver extends BaseDriver
return $this->payment_method->processVerification($request, $payment_method); return $this->payment_method->processVerification($request, $payment_method);
} }
public function processWebhookRequest(PaymentWebhookRequest $request, Payment $payment) public function processWebhookRequest(PaymentWebhookRequest $request)
{ {
if ($request->type == 'source.chargeable') { if ($request->type === 'charge.succeeded' || $request->type === 'source.chargeable') {
$payment->status_id = Payment::STATUS_COMPLETED; foreach ($request->data as $transaction) {
$payment->save(); $payment = Payment::query()
->where('transaction_reference', $transaction['id'])
->where('company_id', $request->getCompany()->id)
->first();
if ($payment) {
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->save();
}
}
} }
if ($request->type == 'charge.succeeded') { return response()->json([], 200);
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->save();
}
// charge.failed, charge.refunded
return response([], 200);
} }
public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash) public function tokenBilling(ClientGatewayToken $cgt, PaymentHash $payment_hash)