feat: ✨ Added basic currency support for invoices
This commit is contained in:
parent
681980c21f
commit
53f6e0586c
3 changed files with 90 additions and 6 deletions
|
@ -31,6 +31,7 @@ use PayPalCheckoutSdk\Orders\OrdersCaptureRequest;
|
||||||
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
|
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
|
||||||
use PayPalHttp\HttpException;
|
use PayPalHttp\HttpException;
|
||||||
use Stripe\Stripe;
|
use Stripe\Stripe;
|
||||||
|
use Symfony\Component\Intl\Currencies;
|
||||||
|
|
||||||
|
|
||||||
class PaymentController extends Controller
|
class PaymentController extends Controller
|
||||||
|
@ -199,7 +200,7 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
||||||
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid', $creditProduct->currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -342,7 +343,7 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
||||||
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid', $creditProduct->currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
|
@ -368,7 +369,7 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
||||||
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid', $creditProduct->currency_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
//redirect back to home
|
//redirect back to home
|
||||||
|
@ -428,7 +429,7 @@ class PaymentController extends Controller
|
||||||
|
|
||||||
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
//only create invoice if SETTINGS::INVOICE:ENABLED is true
|
||||||
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
if (config('SETTINGS::INVOICE:ENABLED') == 'true') {
|
||||||
$this->createInvoice($user, $payment, 'paid');
|
$this->createInvoice($user, $payment, 'paid', strtoupper($paymentIntent->currency));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (HttpException $ex) {
|
} catch (HttpException $ex) {
|
||||||
|
@ -502,7 +503,7 @@ class PaymentController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function createInvoice($user, $payment, $paymentStatus)
|
protected function createInvoice($user, $payment, $paymentStatus, $currencyCode)
|
||||||
{
|
{
|
||||||
$creditProduct = CreditProduct::where('id', $payment->credit_product_id)->first();
|
$creditProduct = CreditProduct::where('id', $payment->credit_product_id)->first();
|
||||||
//create invoice
|
//create invoice
|
||||||
|
@ -553,6 +554,8 @@ class PaymentController extends Controller
|
||||||
->delimiter("-")
|
->delimiter("-")
|
||||||
->sequence($newInvoiceID)
|
->sequence($newInvoiceID)
|
||||||
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
|
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
|
||||||
|
->currencyCode($currencyCode)
|
||||||
|
->currencySymbol(Currencies::getSymbol($currencyCode))
|
||||||
->notes($notes);
|
->notes($notes);
|
||||||
|
|
||||||
if (file_exists($logoPath)) {
|
if (file_exists($logoPath)) {
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
"spatie/laravel-query-builder": "^3.6",
|
"spatie/laravel-query-builder": "^3.6",
|
||||||
"spatie/laravel-validation-rules": "^3.0",
|
"spatie/laravel-validation-rules": "^3.0",
|
||||||
"stripe/stripe-php": "^7.107",
|
"stripe/stripe-php": "^7.107",
|
||||||
|
"symfony/intl": "^6.0",
|
||||||
"yajra/laravel-datatables-oracle": "~9.0"
|
"yajra/laravel-datatables-oracle": "~9.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
|
82
composer.lock
generated
82
composer.lock
generated
|
@ -4,7 +4,7 @@
|
||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "1c860d07605bb48da56d1bb780a82bda",
|
"content-hash": "d932d84040780b815f087c1d18a1e41d",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "asm89/stack-cors",
|
"name": "asm89/stack-cors",
|
||||||
|
@ -5366,6 +5366,86 @@
|
||||||
],
|
],
|
||||||
"time": "2022-01-28T11:06:03+00:00"
|
"time": "2022-01-28T11:06:03+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/intl",
|
||||||
|
"version": "v6.0.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/intl.git",
|
||||||
|
"reference": "eeddf6ca4cb4767e554c82182d1ddd5a7ff94f4d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/intl/zipball/eeddf6ca4cb4767e554c82182d1ddd5a7ff94f4d",
|
||||||
|
"reference": "eeddf6ca4cb4767e554c82182d1ddd5a7ff94f4d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.0.2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"symfony/filesystem": "^5.4|^6.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Component\\Intl\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Bernhard Schussek",
|
||||||
|
"email": "bschussek@gmail.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Eriksen Costa",
|
||||||
|
"email": "eriksen.costa@infranology.com.br"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Igor Wiedler",
|
||||||
|
"email": "igor@wiedler.ch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Provides a PHP replacement layer for the C intl extension that includes additional data from the ICU library",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"i18n",
|
||||||
|
"icu",
|
||||||
|
"internationalization",
|
||||||
|
"intl",
|
||||||
|
"l10n",
|
||||||
|
"localization"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/intl/tree/v6.0.3"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2022-01-02T09:55:41+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/mime",
|
"name": "symfony/mime",
|
||||||
"version": "v5.4.3",
|
"version": "v5.4.3",
|
||||||
|
|
Loading…
Reference in a new issue