Store payment method on request

This commit is contained in:
Benjamin Beganović 2021-10-13 13:56:28 +02:00
parent e8b390f4d7
commit 5d98b28828
2 changed files with 14 additions and 6 deletions

View File

@ -67,16 +67,15 @@ class SEPA
public function paymentResponse(PaymentResponseRequest $request)
{
$gateway_response = json_decode($request->gateway_response);
$this->stripe->payment_hash->data = array_merge((array) $this->stripe->payment_hash->data, $request->all());
$this->stripe->payment_hash->save();
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
$this->storePaymentMethod($gateway_response);
if ($request->store_card) {
$this->storePaymentMethod($gateway_response);
}
return $this->processSuccessfulPayment($gateway_response->id);
}
@ -97,7 +96,7 @@ class SEPA
'gateway_type_id' => GatewayType::SEPA,
];
$this->stripe->createPayment($data, Payment::STATUS_PENDING);
$payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
SystemLogger::dispatch(
['response' => $this->stripe->payment_hash->data, 'data' => $data],
@ -108,7 +107,7 @@ class SEPA
$this->stripe->client->company,
);
return redirect()->route('client.payments.index');
return redirect()->route('client.payments.show', $payment->hashed_id);
}
public function processUnsuccessfulPayment()

View File

@ -134,6 +134,15 @@ class ProcessSEPA {
'input[name="gateway_response"]'
).value = JSON.stringify(result.paymentIntent);
let tokenBillingCheckbox = document.querySelector(
'input[name="token-billing-checkbox"]:checked'
);
if (tokenBillingCheckbox) {
document.querySelector('input[name="store_card"]').value =
tokenBillingCheckbox.value;
}
document.getElementById('server-response').submit();
}