diff --git a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php index ffaee62e700e..4c2997ae6bd2 100644 --- a/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php +++ b/app/PaymentDrivers/Authorize/AuthorizeCreditCard.php @@ -18,6 +18,7 @@ use App\Jobs\Util\SystemLogger; use App\Models\ClientGatewayToken; use App\Models\GatewayType; use App\Models\Payment; +use App\Models\PaymentHash; use App\Models\PaymentType; use App\Models\SystemLog; use App\PaymentDrivers\AuthorizePaymentDriver; @@ -71,14 +72,14 @@ class AuthorizeCreditCard $gateway_customer_reference = $authorise_create_customer->create($data); - info($gateway_customer_reference); + //info($gateway_customer_reference); $authorise_payment_method = new AuthorizePaymentMethod($this->authorize); $payment_profile = $authorise_payment_method->addPaymentMethodToClient($gateway_customer_reference, $data); $payment_profile_id = $payment_profile->getPaymentProfile()->getCustomerPaymentProfileId(); - info($request->input('store_card')); + //info($request->input('store_card')); if($request->has('store_card') && $request->input('store_card') === 'true'){ $authorise_payment_method->payment_method = GatewayType::CREDIT_CARD; @@ -162,8 +163,17 @@ class AuthorizeCreditCard private function processSuccessfulResponse($data, $request) { + $payment_hash = PaymentHash::whereRaw("BINARY `hash`= ?", [$request->input('payment_hash')])->firstOrFail(); + + + + + $payment = $this->createPaymentRecord($data, $request->input('amount_with_fee')); + + + $this->authorize->attachInvoices($payment, $request->hashed_ids); $payment->service()->updateInvoicePayment(); diff --git a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php index 96d072994941..c6dc4ef9ca3c 100644 --- a/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php +++ b/app/PaymentDrivers/Authorize/AuthorizePaymentMethod.php @@ -122,7 +122,7 @@ class AuthorizePaymentMethod public function createClientGatewayToken($payment_profile, $gateway_customer_reference) { - info(print_r($payment_profile,1)); + // info(print_r($payment_profile,1)); $client_gateway_token = new ClientGatewayToken(); $client_gateway_token->company_id = $this->authorize->client->company_id; diff --git a/app/PaymentDrivers/Stripe/CreditCard.php b/app/PaymentDrivers/Stripe/CreditCard.php index 48ae2cc50797..d726dcf1b774 100644 --- a/app/PaymentDrivers/Stripe/CreditCard.php +++ b/app/PaymentDrivers/Stripe/CreditCard.php @@ -126,6 +126,7 @@ class CreditCard 'payment_hash' => $payment_hash, ]; + /*Hydrate the invoices from the payment hash*/ $invoices = Invoice::whereIn('id', $this->stripe->transformKeys(array_column($payment_hash->invoices(), 'invoice_id'))) ->whereClientId($this->stripe->client->id) ->get(); diff --git a/database/seeds/RandomDataSeeder.php b/database/seeds/RandomDataSeeder.php index c6ec55d476a2..79affea2bba8 100644 --- a/database/seeds/RandomDataSeeder.php +++ b/database/seeds/RandomDataSeeder.php @@ -19,6 +19,7 @@ use App\Models\GatewayType; use App\Models\GroupSetting; use App\Models\Invoice; use App\Models\Payment; +use App\Models\PaymentHash; use App\Models\PaymentType; use App\Models\Quote; use App\Models\User; @@ -30,6 +31,7 @@ use App\Utils\Ninja; use Illuminate\Database\Seeder; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Schema; +use Illuminate\Support\Str; class RandomDataSeeder extends Seeder { @@ -213,9 +215,16 @@ class RandomDataSeeder extends Seeder $payment->invoices()->save($invoice); + $payment_hash = new PaymentHash; + $payment_hash->hash = Str::random(128); + $payment_hash->data = [['invoice_id' => $invoice->hashed_id, 'amount' => $invoice->balance]]; + $payment_hash->fee_total = 0; + $payment_hash->fee_invoice_id = $invoice->id; + $payment_hash->save(); + event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars())); - $payment->service()->updateInvoicePayment(); + $payment->service()->updateInvoicePayment($payment_hash); // UpdateInvoicePayment::dispatchNow($payment, $payment->company); }