Add token_id to activity table

This commit is contained in:
David Bomba 2020-07-08 16:54:16 +10:00
parent 2e03b1e6d2
commit a476034bd0
6 changed files with 51 additions and 10 deletions

View File

@ -99,10 +99,13 @@ class AuthorizeCreditCard
return $this->handleResponse($data, $request); return $this->handleResponse($data, $request);
} }
private function handleResponse($data, $request) private function tokenBilling($cgt, $amount, $invoice)
{ {
//info(print_r( $response->getTransactionResponse()->getMessages(),1));
}
private function handleResponse($data, $request)
{
$response = $data['response']; $response = $data['response'];
if($response != null && $response->getMessages()->getResultCode() == "Ok") if($response != null && $response->getMessages()->getResultCode() == "Ok")

View File

@ -17,6 +17,7 @@ use App\Models\GatewayType;
use App\Models\Payment; use App\Models\Payment;
use App\PaymentDrivers\Authorize\AuthorizeCreditCard; use App\PaymentDrivers\Authorize\AuthorizeCreditCard;
use App\PaymentDrivers\Authorize\AuthorizePaymentMethod; use App\PaymentDrivers\Authorize\AuthorizePaymentMethod;
use App\PaymentDrivers\Authorize\ChargePaymentProfile;
use App\PaymentDrivers\Authorize\RefundTransaction; use App\PaymentDrivers\Authorize\RefundTransaction;
use net\authorize\api\constants\ANetEnvironment; use net\authorize\api\constants\ANetEnvironment;
use net\authorize\api\contract\v1\CreateTransactionRequest; use net\authorize\api\contract\v1\CreateTransactionRequest;
@ -137,6 +138,11 @@ class AuthorizePaymentDriver extends BaseDriver
->first(); ->first();
} }
public function tokenBilling(ClientGatewayToken $cgt, float $amount) {} public function tokenBilling(ClientGatewayToken $cgt, float $amount, ?Invoice $invoice = null)
{
$this->setPaymentMethod($cgt->gateway_type_id);
$this->payment_method->tokenBilling($cgt, $amount, $invoice);
}
} }

View File

@ -123,9 +123,10 @@ class BaseDriver extends AbstractPaymentDriver
/** /**
* Process an unattended payment * Process an unattended payment
* *
* @param ClientGatewayToken $cgt the client gateway token object * @param ClientGatewayToken $cgt The client gateway token object
* @param float $amount the amount to bill * @param float $amount The amount to bill
* @return Response The payment response * @param Invoice $invoice Optional Invoice object being paid
* @return Response The payment response
*/ */
public function tokenBilling(ClientGatewayToken $cgt, float $amount) {} public function tokenBilling(ClientGatewayToken $cgt, float $amount, ?Invoice $invoice = null) {}
} }

View File

@ -52,7 +52,7 @@ class AutoBillInvoice extends AbstractService
if($fee > 0) if($fee > 0)
$this->purgeStaleGatewayFees()->addFeeToInvoice($fee); $this->purgeStaleGatewayFees()->addFeeToInvoice($fee);
$response = $gateway_token->gateway->driver($this->client)->tokenBilling($gateway_token, $amount); $response = $gateway_token->gateway->driver($this->client)->tokenBilling($gateway_token, $amount, $this->invoice);
//if response was successful, toggle the fee type_id to paid //if response was successful, toggle the fee type_id to paid
} }
@ -99,7 +99,7 @@ class AutoBillInvoice extends AbstractService
$this->invoice->client->service()->updateBalance($this->invoice->amount - $starting_amount)->save(); $this->invoice->client->service()->updateBalance($this->invoice->amount - $starting_amount)->save();
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount - $starting_amount, 'Invoice balance updated after stale gateway fee removed')->save(); $this->invoice->ledger()->updateInvoiceBalance($this->invoice->amount - $starting_amount, 'Invoice balance updated after stale gateway fee removed')->save();
} }
return $this; return $this;
} }

View File

@ -48,6 +48,7 @@ class ActivityTransformer extends EntityTransformer
'is_system' => (bool) $activity->is_system, 'is_system' => (bool) $activity->is_system,
'contact_id' => $activity->contact_id ? (string) $this->encodePrimaryKey($activity->contact_id) : '', 'contact_id' => $activity->contact_id ? (string) $this->encodePrimaryKey($activity->contact_id) : '',
'task_id' => $activity->task_id ? (string) $this->encodePrimaryKey($activity->task_id) : '', 'task_id' => $activity->task_id ? (string) $this->encodePrimaryKey($activity->task_id) : '',
'token_id' => $activity->token_id ? (string) $this->encodePrimaryKey($activity->token_id) : '',
'notes' => $activity->notes ? (string) $activity->notes : '', 'notes' => $activity->notes ? (string) $activity->notes : '',
'ip' => (string) $activity->ip, 'ip' => (string) $activity->ip,

View File

@ -0,0 +1,30 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddTokenIdToActivityTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('activities', function (Blueprint $table) {
$table->unsignedInteger('token_id')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
}
}