mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-23 20:00:33 -04:00
Fixes for eway error handling
This commit is contained in:
parent
e75218e557
commit
1b6534378d
@ -14,6 +14,7 @@ namespace App\Export\CSV;
|
|||||||
use App\Utils\Number;
|
use App\Utils\Number;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
|
use App\Models\GatewayType;
|
||||||
use League\Fractal\Manager;
|
use League\Fractal\Manager;
|
||||||
use Illuminate\Support\Carbon;
|
use Illuminate\Support\Carbon;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -50,6 +51,7 @@ class BaseExport
|
|||||||
"private_notes" => "client.private_notes",
|
"private_notes" => "client.private_notes",
|
||||||
"industry" => "client.industry_id",
|
"industry" => "client.industry_id",
|
||||||
"size" => "client.size_id",
|
"size" => "client.size_id",
|
||||||
|
"work_phone" => "client.phone",
|
||||||
"address1" => "client.address1",
|
"address1" => "client.address1",
|
||||||
"address2" => "client.address2",
|
"address2" => "client.address2",
|
||||||
"city" => "client.city",
|
"city" => "client.city",
|
||||||
@ -248,6 +250,7 @@ class BaseExport
|
|||||||
return '';
|
return '';
|
||||||
|
|
||||||
match($parts[0]) {
|
match($parts[0]) {
|
||||||
|
'contact' => $value = $this->resolveClientContactKey($parts[1], $entity, $transformer),
|
||||||
'client' => $value = $this->resolveClientKey($parts[1], $entity, $transformer),
|
'client' => $value = $this->resolveClientKey($parts[1], $entity, $transformer),
|
||||||
'invoice' => $value = $this->resolveInvoiceKey($parts[1], $entity, $transformer),
|
'invoice' => $value = $this->resolveInvoiceKey($parts[1], $entity, $transformer),
|
||||||
'payment' => $value = $this->resolvePaymentKey($parts[1], $entity, $transformer),
|
'payment' => $value = $this->resolvePaymentKey($parts[1], $entity, $transformer),
|
||||||
@ -257,6 +260,15 @@ class BaseExport
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function resolveClientContactKey($column, $entity, $transformer)
|
||||||
|
{
|
||||||
|
|
||||||
|
$primary_contact = $entity->client->primary_contact()->first() ?? $entity->client->contacts()->first();
|
||||||
|
|
||||||
|
return $primary_contact?->{$column} ?? '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private function resolveClientKey($column, $entity, $transformer)
|
private function resolveClientKey($column, $entity, $transformer)
|
||||||
{
|
{
|
||||||
$transformed_client = $transformer->includeClient($entity);
|
$transformed_client = $transformer->includeClient($entity);
|
||||||
@ -271,14 +283,26 @@ class BaseExport
|
|||||||
if($column == 'user_id')
|
if($column == 'user_id')
|
||||||
return $entity->client->user->present()->name();
|
return $entity->client->user->present()->name();
|
||||||
|
|
||||||
|
if($column == 'country_id')
|
||||||
|
return $entity->client->country ? ctrans("texts.country_{$entity->client->country->name}") : '';
|
||||||
|
|
||||||
|
if($column == 'shipping_country_id')
|
||||||
|
return $entity->client->shipping_country ? ctrans("texts.country_{$entity->client->shipping_country->name}") : '';
|
||||||
|
|
||||||
|
if($column == 'size_id')
|
||||||
|
return $entity->client->size?->name ?? '';
|
||||||
|
|
||||||
|
if($column == 'industry_id')
|
||||||
|
return $entity->client->industry?->name ?? '';
|
||||||
|
|
||||||
|
if ($column == 'currency_id') {
|
||||||
|
return $entity->client->currency() ? $entity->client->currency()->code : $entity->company->currency()->code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(array_key_exists($column, $transformed_client))
|
if(array_key_exists($column, $transformed_client))
|
||||||
return $transformed_client[$column];
|
return $transformed_client[$column];
|
||||||
|
|
||||||
$primary_contact = $entity->client->primary_contact()->first() ?? $entity->client->contacts()->first();
|
|
||||||
|
|
||||||
if($primary_contact && array_key_exists($column, $primary_contact->toArray()))
|
|
||||||
return $primary_contact->{$column};
|
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -310,6 +334,12 @@ class BaseExport
|
|||||||
if(!$payment)
|
if(!$payment)
|
||||||
return '';
|
return '';
|
||||||
|
|
||||||
|
if($column == 'method')
|
||||||
|
return $payment->translatedType();
|
||||||
|
|
||||||
|
if($column == 'currency')
|
||||||
|
return $payment?->currency?->code ?? '';
|
||||||
|
|
||||||
$payment_transformer = new PaymentTransformer();
|
$payment_transformer = new PaymentTransformer();
|
||||||
$transformed_payment = $payment_transformer->transform($payment);
|
$transformed_payment = $payment_transformer->transform($payment);
|
||||||
|
|
||||||
@ -447,25 +477,33 @@ class BaseExport
|
|||||||
$header = [];
|
$header = [];
|
||||||
|
|
||||||
foreach (array_merge($this->input['report_keys'], $this->forced_keys) as $value) {
|
foreach (array_merge($this->input['report_keys'], $this->forced_keys) as $value) {
|
||||||
|
|
||||||
|
$prefix = '';
|
||||||
|
|
||||||
$key = array_search($value, $this->entity_keys);
|
$key = array_search($value, $this->entity_keys);
|
||||||
|
|
||||||
if(!$key) {
|
if(!$key) {
|
||||||
|
$prefix = stripos($value, 'client.') !== false ? ctrans('texts.client') : ctrans('texts.contact');
|
||||||
$key = array_search($value, $this->client_report_keys);
|
$key = array_search($value, $this->client_report_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$key) {
|
if(!$key) {
|
||||||
|
$prefix = ctrans('texts.invoice');
|
||||||
$key = array_search($value, $this->invoice_report_keys);
|
$key = array_search($value, $this->invoice_report_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$key) {
|
if(!$key) {
|
||||||
|
$prefix = ctrans('texts.quote');
|
||||||
$key = array_search($value, $this->quote_report_keys);
|
$key = array_search($value, $this->quote_report_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$key) {
|
if(!$key) {
|
||||||
|
$prefix = ctrans('texts.credit');
|
||||||
$key = array_search($value, $this->credit_report_keys);
|
$key = array_search($value, $this->credit_report_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$key) {
|
if(!$key) {
|
||||||
|
$prefix = ctrans('texts.payment');
|
||||||
$key = array_search($value, $this->payment_report_keys);
|
$key = array_search($value, $this->payment_report_keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,7 +513,7 @@ class BaseExport
|
|||||||
$key = str_replace('contact.', '', $key);
|
$key = str_replace('contact.', '', $key);
|
||||||
$key = str_replace('payment.', '', $key);
|
$key = str_replace('payment.', '', $key);
|
||||||
|
|
||||||
$header[] = ctrans("texts.{$key}");
|
$header[] = "{$prefix} " . ctrans("texts.{$key}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $header;
|
return $header;
|
||||||
|
@ -152,6 +152,10 @@ class CreditExport extends BaseExport
|
|||||||
$entity['client.country_id'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : '';
|
$entity['client.country_id'] = $credit->client->country ? ctrans("texts.country_{$credit->client->country->name}") : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (in_array('client.shipping_country_id', $this->input['report_keys'])) {
|
||||||
|
$entity['client.shipping_country_id'] = $credit->client->shipping_country ? ctrans("texts.country_{$credit->client->shipping_country->name}") : '';
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array('currency_id', $this->input['report_keys'])) {
|
if (in_array('currency_id', $this->input['report_keys'])) {
|
||||||
$entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $credit->company->currency()->code;
|
$entity['currency_id'] = $credit->client->currency() ? $credit->client->currency()->code : $credit->company->currency()->code;
|
||||||
}
|
}
|
||||||
@ -172,6 +176,20 @@ class CreditExport extends BaseExport
|
|||||||
$entity['credit.status'] = $credit->stringStatus($credit->status_id);
|
$entity['credit.status'] = $credit->stringStatus($credit->status_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(in_array('client.payment_terms', $this->input['report_keys'])) {
|
||||||
|
$entity['client.payment_terms'] = $credit->client->getSetting('payment_terms');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array('client.size_id', $this->input['report_keys'])) {
|
||||||
|
$entity['client.size_id'] = $credit->client->size?->name ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if(in_array('client.industry_id', $this->input['report_keys'])) {
|
||||||
|
$entity['client.industry_id'] = $credit->client->industry?->name ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nlog($entity);
|
nlog($entity);
|
||||||
|
|
||||||
return $entity;
|
return $entity;
|
||||||
|
@ -464,6 +464,11 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
return $this->belongsTo(Industry::class);
|
return $this->belongsTo(Industry::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function size()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Size::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function locale()
|
public function locale()
|
||||||
{
|
{
|
||||||
if (! $this->language()) {
|
if (! $this->language()) {
|
||||||
|
@ -34,7 +34,8 @@ class PaymentType extends StaticModel
|
|||||||
*/
|
*/
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
|
|
||||||
const CREDIT = 32;
|
const BANK_TRANSFER = 1;
|
||||||
|
const CASH = 2;
|
||||||
const ACH = 4;
|
const ACH = 4;
|
||||||
const VISA = 5;
|
const VISA = 5;
|
||||||
const MASTERCARD = 6;
|
const MASTERCARD = 6;
|
||||||
@ -53,11 +54,14 @@ class PaymentType extends StaticModel
|
|||||||
const MAESTRO = 20;
|
const MAESTRO = 20;
|
||||||
const SOLO = 21;
|
const SOLO = 21;
|
||||||
const SWITCH = 22;
|
const SWITCH = 22;
|
||||||
|
const VENMO = 24;
|
||||||
const ALIPAY = 27;
|
const ALIPAY = 27;
|
||||||
const SOFORT = 28;
|
const SOFORT = 28;
|
||||||
const SEPA = 29;
|
const SEPA = 29;
|
||||||
const GOCARDLESS = 30;
|
const GOCARDLESS = 30;
|
||||||
const CRYPTO = 31;
|
const CRYPTO = 31;
|
||||||
|
const CREDIT = 32;
|
||||||
|
const ZELLE = 33;
|
||||||
const MOLLIE_BANK_TRANSFER = 34;
|
const MOLLIE_BANK_TRANSFER = 34;
|
||||||
const KBC = 35;
|
const KBC = 35;
|
||||||
const BANCONTACT = 36;
|
const BANCONTACT = 36;
|
||||||
@ -76,10 +80,12 @@ class PaymentType extends StaticModel
|
|||||||
const BACS = 49;
|
const BACS = 49;
|
||||||
const STRIPE_BANK_TRANSFER = 50;
|
const STRIPE_BANK_TRANSFER = 50;
|
||||||
const CASH_APP = 51;
|
const CASH_APP = 51;
|
||||||
const VENMO = 24;
|
|
||||||
|
|
||||||
public array $type_names = [
|
public array $type_names = [
|
||||||
|
self::BANK_TRANSFER => 'payment_type_Bank Transfer',
|
||||||
|
self::CASH => 'payment_type_Cash',
|
||||||
self::CREDIT => 'payment_type_Credit',
|
self::CREDIT => 'payment_type_Credit',
|
||||||
|
self::ZELLE => 'payment_type_Zelle',
|
||||||
self::ACH => 'payment_type_ACH',
|
self::ACH => 'payment_type_ACH',
|
||||||
self::VISA => 'payment_type_Visa Card',
|
self::VISA => 'payment_type_Visa Card',
|
||||||
self::MASTERCARD => 'payment_type_MasterCard',
|
self::MASTERCARD => 'payment_type_MasterCard',
|
||||||
|
@ -70,16 +70,14 @@ class CreditCard
|
|||||||
|
|
||||||
$response = $this->eway_driver->init()->eway->createCustomer(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
|
$response = $this->eway_driver->init()->eway->createCustomer(\Eway\Rapid\Enum\ApiMethod::DIRECT, $transaction);
|
||||||
|
|
||||||
if(property_exists($response, 'ResponseMessage'))
|
if($response->getErrors()) {
|
||||||
$response_status = ErrorCode::getStatus($response->ResponseMessage);
|
|
||||||
|
|
||||||
if (! $response_status['success']) {
|
$response_status['message'] = \Eway\Rapid::getMessage($response->getErrors()[0]);
|
||||||
|
|
||||||
$this->eway_driver->sendFailureMail($response_status['message']);
|
$this->eway_driver->sendFailureMail($response_status['message']);
|
||||||
|
|
||||||
$this->logResponse($response);
|
$this->logResponse($response);
|
||||||
|
|
||||||
|
|
||||||
throw new PaymentFailed($response_status['message'] ?? 'Unknown response from gateway, please contact you merchant.', 400);
|
throw new PaymentFailed($response_status['message'] ?? 'Unknown response from gateway, please contact you merchant.', 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user