mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Merge pull request #6472 from turbo124/v5-develop
Updates for authorize.net
This commit is contained in:
commit
17ba910ba2
@ -81,6 +81,8 @@ class InvoiceItemSum
|
|||||||
|
|
||||||
private function push()
|
private function push()
|
||||||
{
|
{
|
||||||
|
nlog($this->sub_total . " + ". $this->getLineTotal());
|
||||||
|
|
||||||
$this->sub_total += $this->getLineTotal();
|
$this->sub_total += $this->getLineTotal();
|
||||||
|
|
||||||
$this->line_items[] = $this->item;
|
$this->line_items[] = $this->item;
|
||||||
@ -103,7 +105,15 @@ class InvoiceItemSum
|
|||||||
if ($this->invoice->is_amount_discount) {
|
if ($this->invoice->is_amount_discount) {
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
$this->setLineTotal($this->getLineTotal() - $this->formatValue($this->item->discount, $this->currency->precision));
|
||||||
} else {
|
} else {
|
||||||
$this->setLineTotal($this->getLineTotal() - $this->formatValue(round($this->item->line_total * ($this->item->discount / 100), 2), $this->currency->precision));
|
|
||||||
|
/*Test 16-08-2021*/
|
||||||
|
$discount = ($this->item->line_total * ($this->item->discount / 100));
|
||||||
|
$this->setLineTotal($this->formatValue(($this->getLineTotal() - $discount), $this->currency->precision));
|
||||||
|
/*Test 16-08-2021*/
|
||||||
|
|
||||||
|
//replaces the following
|
||||||
|
|
||||||
|
// $this->setLineTotal($this->getLineTotal() - $this->formatValue(round($this->item->line_total * ($this->item->discount / 100), 2), $this->currency->precision));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
$this->item->is_amount_discount = $this->invoice->is_amount_discount;
|
||||||
|
@ -433,9 +433,14 @@ class CompanyGatewayController extends BaseController
|
|||||||
*/
|
*/
|
||||||
public function destroy(DestroyCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
public function destroy(DestroyCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
$company_gateway->driver(new Client)
|
||||||
|
->disconnect();
|
||||||
|
|
||||||
$company_gateway->delete();
|
$company_gateway->delete();
|
||||||
|
|
||||||
return $this->itemResponse($company_gateway->fresh());
|
return $this->itemResponse($company_gateway->fresh());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,6 +81,8 @@ class StripeConnectController extends BaseController
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MultiDB::findAndSetDbByCompanyKey($request->getTokenContent()['company_key']);
|
||||||
|
|
||||||
$company = Company::where('company_key', $request->getTokenContent()['company_key'])->first();
|
$company = Company::where('company_key', $request->getTokenContent()['company_key'])->first();
|
||||||
|
|
||||||
$company_gateway = CompanyGateway::query()
|
$company_gateway = CompanyGateway::query()
|
||||||
|
@ -175,7 +175,8 @@ class ReminderJob implements ShouldQueue
|
|||||||
$invoice->line_items = $invoice_items;
|
$invoice->line_items = $invoice_items;
|
||||||
|
|
||||||
/**Refresh Invoice values*/
|
/**Refresh Invoice values*/
|
||||||
$invoice = $invoice->calc()->getInvoice()->save();
|
$invoice->calc()->getInvoice()->save();
|
||||||
|
$invoice->fresh();
|
||||||
$invoice->service()->deletePdf();
|
$invoice->service()->deletePdf();
|
||||||
|
|
||||||
nlog("adjusting client balance and invoice balance by ". ($invoice->balance - $temp_invoice_balance));
|
nlog("adjusting client balance and invoice balance by ". ($invoice->balance - $temp_invoice_balance));
|
||||||
|
@ -115,7 +115,7 @@ class AuthorizeCreditCard
|
|||||||
];
|
];
|
||||||
|
|
||||||
$logger_message = [
|
$logger_message = [
|
||||||
'server_response' => $response->getTransactionResponse()->getTransId(),
|
'server_response' => $response->getTransId(),
|
||||||
'data' => $this->formatGatewayResponse($data, $vars),
|
'data' => $this->formatGatewayResponse($data, $vars),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -130,11 +130,11 @@ class AuthorizeCreditCard
|
|||||||
];
|
];
|
||||||
|
|
||||||
$logger_message = [
|
$logger_message = [
|
||||||
'server_response' => $response->getTransactionResponse()->getTransId(),
|
'server_response' => $response->getTransId(),
|
||||||
'data' => $this->formatGatewayResponse($data, $vars),
|
'data' => $this->formatGatewayResponse($data, $vars),
|
||||||
];
|
];
|
||||||
|
|
||||||
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $amount);
|
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransId(), $this->authorize->client->company, $amount);
|
||||||
|
|
||||||
SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client, $this->authorize->client->company);
|
SystemLogger::dispatch($logger_message, SystemLog::CATEGORY_GATEWAY_RESPONSE, SystemLog::EVENT_GATEWAY_FAILURE, SystemLog::TYPE_AUTHORIZE, $this->authorize->client, $this->authorize->client->company);
|
||||||
|
|
||||||
@ -147,8 +147,8 @@ class AuthorizeCreditCard
|
|||||||
{
|
{
|
||||||
$response = $data['response'];
|
$response = $data['response'];
|
||||||
|
|
||||||
if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
|
// if ($response != null && $response->getMessages()->getResultCode() == 'Ok') {
|
||||||
|
if ($response != null && $response->getMessages() != null) {
|
||||||
return $this->processSuccessfulResponse($data, $request);
|
return $this->processSuccessfulResponse($data, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,7 +165,7 @@ class AuthorizeCreditCard
|
|||||||
$payment_record['amount'] = $amount;
|
$payment_record['amount'] = $amount;
|
||||||
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
|
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;
|
||||||
$payment_record['gateway_type_id'] = GatewayType::CREDIT_CARD;
|
$payment_record['gateway_type_id'] = GatewayType::CREDIT_CARD;
|
||||||
$payment_record['transaction_reference'] = $response->getTransactionResponse()->getTransId();
|
$payment_record['transaction_reference'] = $response->getTransId();
|
||||||
|
|
||||||
$payment = $this->authorize->createPayment($payment_record);
|
$payment = $this->authorize->createPayment($payment_record);
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ class AuthorizeCreditCard
|
|||||||
];
|
];
|
||||||
|
|
||||||
$logger_message = [
|
$logger_message = [
|
||||||
'server_response' => $data['response']->getTransactionResponse()->getTransId(),
|
'server_response' => $data['response']->getTransId(),
|
||||||
'data' => $this->formatGatewayResponse($data, $vars),
|
'data' => $this->formatGatewayResponse($data, $vars),
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ class AuthorizeCreditCard
|
|||||||
$response = $data['response'];
|
$response = $data['response'];
|
||||||
$amount = array_key_exists('amount_with_fee', $data) ? $data['amount_with_fee'] : 0;
|
$amount = array_key_exists('amount_with_fee', $data) ? $data['amount_with_fee'] : 0;
|
||||||
|
|
||||||
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransactionResponse()->getTransId(), $this->authorize->client->company, $data['amount_with_fee']);
|
PaymentFailureMailer::dispatch($this->authorize->client, $response->getTransId(), $this->authorize->client->company, $data['amount_with_fee']);
|
||||||
|
|
||||||
throw new \Exception(ctrans('texts.error_title'));
|
throw new \Exception(ctrans('texts.error_title'));
|
||||||
}
|
}
|
||||||
@ -216,15 +216,20 @@ class AuthorizeCreditCard
|
|||||||
$code = '';
|
$code = '';
|
||||||
$description = '';
|
$description = '';
|
||||||
|
|
||||||
if($response->getTransactionResponse()->getMessages() !== null){
|
if($response->getMessages() !== null){
|
||||||
$code = $response->getTransactionResponse()->getMessages()[0]->getCode();
|
$code = $response->getMessages()[0]->getCode();
|
||||||
$description = $response->getTransactionResponse()->getMessages()[0]->getDescription();
|
$description = $response->getMessages()[0]->getDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->getErrors() != null) {
|
||||||
|
$code = $response->getErrors()[0]->getErrorCode();
|
||||||
|
$description = $response->getErrors()[0]->getErrorText();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'transaction_reference' => $response->getTransactionResponse()->getTransId(),
|
'transaction_reference' => $response->getTransId(),
|
||||||
'amount' => $vars['amount'],
|
'amount' => $vars['amount'],
|
||||||
'auth_code' => $response->getTransactionResponse()->getAuthCode(),
|
'auth_code' => $response->getAuthCode(),
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
'description' => $description,
|
'description' => $description,
|
||||||
'invoices' => $vars['invoices'],
|
'invoices' => $vars['invoices'],
|
||||||
|
@ -93,7 +93,7 @@ class ChargePaymentProfile
|
|||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'response' => $response,
|
'response' => $tresponse,
|
||||||
'amount' => $amount,
|
'amount' => $amount,
|
||||||
'profile_id' => $profile_id,
|
'profile_id' => $profile_id,
|
||||||
'payment_profile_id' => $payment_profile_id,
|
'payment_profile_id' => $payment_profile_id,
|
||||||
|
@ -631,4 +631,9 @@ class BaseDriver extends AbstractPaymentDriver
|
|||||||
|
|
||||||
return $types;
|
return $types;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function disconnect()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,4 +547,29 @@ class StripePaymentDriver extends BaseDriver
|
|||||||
{
|
{
|
||||||
return (new Verify($this))->run();
|
return (new Verify($this))->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function disconnect()
|
||||||
|
{
|
||||||
|
if(!$this->stripe_connect)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if(!strlen($this->company_gateway->getConfigField('account_id')) > 1 )
|
||||||
|
throw new StripeConnectFailure('Stripe Connect has not been configured');
|
||||||
|
|
||||||
|
Stripe::setApiKey(config('ninja.ninja_stripe_key'));
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
\Stripe\OAuth::deauthorize([
|
||||||
|
'client_id' => config('ninja.ninja_stripe_client_id'),
|
||||||
|
'stripe_user_id' => $this->company_gateway->getConfigField('account_id'),
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(\Exception $e){
|
||||||
|
throw new StripeConnectFailure('Unable to disconnect Stripe Connect');
|
||||||
|
}
|
||||||
|
|
||||||
|
return response()->json(['message' => 'success'], 200);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,13 @@ trait CleanLineItems
|
|||||||
//always cast the value!
|
//always cast the value!
|
||||||
$item[$key] = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $item[$key]);
|
$item[$key] = BaseSettings::castAttribute(InvoiceItem::$casts[$key], $item[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(array_key_exists('type_id', $item) && $item['type_id'] == '0')
|
||||||
|
$item['type_id'] = '1';
|
||||||
|
|
||||||
|
if(!array_key_exists('type_id', $item))
|
||||||
|
$item['type_id'] = '1';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (array_key_exists('id', $item)) {
|
if (array_key_exists('id', $item)) {
|
||||||
|
@ -158,6 +158,7 @@ class CompanyLedgerTest extends TestCase
|
|||||||
$item = [];
|
$item = [];
|
||||||
$item['quantity'] = 1;
|
$item['quantity'] = 1;
|
||||||
$item['cost'] = 10;
|
$item['cost'] = 10;
|
||||||
|
$item['type_id'] = "1";
|
||||||
|
|
||||||
$line_items[] = $item;
|
$line_items[] = $item;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user