Improve gateway descriptions for Stripe - credit card + acss

This commit is contained in:
David Bomba 2023-02-23 11:29:16 +11:00
parent 070b4fa6cf
commit aa82f50150
3 changed files with 5 additions and 22 deletions

View File

@ -143,7 +143,7 @@ class ACSS
'setup_future_usage' => 'off_session',
'payment_method_types' => ['acss_debit'],
'customer' => $this->stripe->findOrCreateCustomer(),
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices').': '.collect($data['invoices'])->pluck('invoice_number')),
'description' => $this->stripe->getDescription(false),
'metadata' => [
'payment_hash' => $this->stripe->payment_hash->hash,
'gateway_type_id' => GatewayType::ACSS,
@ -185,7 +185,7 @@ class ACSS
$this->stripe->payment_hash->save();
if (property_exists($gateway_response, 'status') && $gateway_response->status == 'processing') {
// $this->storePaymentMethod($gateway_response);
return $this->processSuccessfulPayment($gateway_response->id);
}

View File

@ -60,8 +60,7 @@ class CreditCard
public function paymentView(array $data)
{
$invoice_numbers = collect($data['invoices'])->pluck('invoice_number')->implode(',');
$description = ctrans('texts.stripe_payment_text', ['invoicenumber' => $invoice_numbers, 'amount' => Number::formatMoney($data['total']['amount_with_fee'], $this->stripe->client), 'client' => $this->stripe->client->present()->name()], $this->stripe->client->company->locale());
$description = $this->stripe->getDescription(false);
$payment_intent_data = [
'amount' => $this->stripe->convertToStripeAmount($data['total']['amount_with_fee'], $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
@ -81,19 +80,6 @@ class CreditCard
return render('gateways.stripe.credit_card.pay', $data);
}
private function decodeUnicodeString($string)
{
return html_entity_decode($string, ENT_QUOTES, 'UTF-8');
// return iconv("UTF-8", "ISO-8859-1//TRANSLIT", $this->decode_encoded_utf8($string));
}
private function decode_encoded_utf8($string)
{
return preg_replace_callback('#\\\\u([0-9a-f]{4})#ism', function ($matches) {
return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UCS-2BE');
}, $string);
}
public function paymentResponse(PaymentResponseRequest $request)
{
$this->stripe->init();
@ -166,8 +152,6 @@ class CreditCard
$this->stripe->client->company,
);
//If the user has come from a subscription double check here if we need to redirect.
//08-08-2022
if ($payment->invoices()->whereHas('subscription')->exists()) {
$subscription = $payment->invoices()->first()->subscription;
@ -175,7 +159,6 @@ class CreditCard
return redirect($subscription->webhook_configuration['return_url']);
}
}
//08-08-2022
return redirect()->route('client.payments.show', ['payment' => $this->stripe->encodePrimaryKey($payment->id)]);
}

View File

@ -121,7 +121,7 @@ class AutoBillInvoice extends AbstractService
$payment_hash = PaymentHash::create([
'hash' => Str::random(64),
'data' => ['invoices' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount, 'invoice_number' => $this->invoice->number]]],
'data' => ['amount_with_fee' => $amount + $fee, 'invoices' => [['invoice_id' => $this->invoice->hashed_id, 'amount' => $amount, 'invoice_number' => $this->invoice->number]]],
'fee_total' => $fee,
'fee_invoice_id' => $this->invoice->id,
]);