Working on refactor

This commit is contained in:
David Bomba 2020-11-26 15:43:53 +11:00
parent 4888a7dc4f
commit 72bbf24c69

View File

@ -100,18 +100,27 @@ class AuthorizeCreditCard
$data = (new ChargePaymentProfile($this->authorize))->chargeCustomerProfile($cgt->gateway_customer_reference, $cgt->token, $amount);
/*Refactor and push to BaseDriver*/
if ($data['response'] != null && $data['response']->getMessages()->getResultCode() == 'Ok') {
$payment = $this->createPaymentRecord($data, $amount);
$payment->meta = $cgt->meta;
$payment->save();
$payment_record = [];
$payment_record['amount'] = $amount;
$payment_record['payment_type'] = PaymentType::CREDIT_CARD_OTHER;;
$payment_record['transaction_reference'] = $data['response']->getTransactionResponse()->getTransId();
$this->authorize->createPayment($payment_record);
$payment_hash->payment_id = $payment->id;
$payment_hash->save();
// $payment = $this->createPaymentRecord($data, $amount);
// $payment->meta = $cgt->meta;
// $payment->save();
// $payment_hash->payment_id = $payment->id;
// $payment_hash->save();
$this->authorize->attachInvoices($payment, $payment_hash);
$payment->service()->updateInvoicePayment($payment_hash);
// $this->authorize->attachInvoices($payment, $payment_hash);
// $payment->service()->updateInvoicePayment($payment_hash);
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
// event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
$vars = [
'hashed_ids' => $invoice->hashed_id,
@ -131,6 +140,37 @@ class AuthorizeCreditCard
}
}
private function handleResponse($data, $request)
{
$response = $data['response'];