diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index 1eeb7b5cabaf..b513b5e3c412 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -99,10 +99,13 @@ class AuthorizeCreditCard 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']; if($response != null && $response->getMessages()->getResultCode() == "Ok") diff --git a/app/PaymentDrivers/AuthorizePaymentDriver.php b/app/PaymentDrivers/AuthorizePaymentDriver.php index 69a704c8e37a..da502665b6f6 100644 --- a/app/PaymentDrivers/AuthorizePaymentDriver.php +++ b/app/PaymentDrivers/AuthorizePaymentDriver.php @@ -17,6 +17,7 @@ use App\Models\GatewayType; use App\Models\Payment; use App\PaymentDrivers\Authorize\AuthorizeCreditCard; use App\PaymentDrivers\Authorize\AuthorizePaymentMethod; +use App\PaymentDrivers\Authorize\ChargePaymentProfile; use App\PaymentDrivers\Authorize\RefundTransaction; use net\authorize\api\constants\ANetEnvironment; use net\authorize\api\contract\v1\CreateTransactionRequest; @@ -137,6 +138,11 @@ class AuthorizePaymentDriver extends BaseDriver ->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); + } } diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index bfd11084a628..5f80c8385e8f 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -123,9 +123,10 @@ class BaseDriver extends AbstractPaymentDriver /** * Process an unattended payment * - * @param ClientGatewayToken $cgt the client gateway token object - * @param float $amount the amount to bill - * @return Response The payment response + * @param ClientGatewayToken $cgt The client gateway token object + * @param float $amount The amount to bill + * @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) {} } diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 0c9b2ed77748..578c8f8b4943 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -52,7 +52,7 @@ class AutoBillInvoice extends AbstractService if($fee > 0) $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 } @@ -99,7 +99,7 @@ class AutoBillInvoice extends AbstractService $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(); } - + return $this; } diff --git a/app/Transformers/ActivityTransformer.php b/app/Transformers/ActivityTransformer.php index dd919f03be0b..e07161f0e9fc 100644 --- a/app/Transformers/ActivityTransformer.php +++ b/app/Transformers/ActivityTransformer.php @@ -48,6 +48,7 @@ class ActivityTransformer extends EntityTransformer 'is_system' => (bool) $activity->is_system, 'contact_id' => $activity->contact_id ? (string) $this->encodePrimaryKey($activity->contact_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 : '', 'ip' => (string) $activity->ip, diff --git a/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php b/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php new file mode 100644 index 000000000000..b2e87940799b --- /dev/null +++ b/database/migrations/2020_07_08_065301_add_token_id_to_activity_table.php @@ -0,0 +1,30 @@ +unsignedInteger('token_id')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + + } +}