company_key); $company = Company::where('company_key', $this->company_key)->first(); foreach ($this->stripe_request as $transaction) { $payment_intent = false; if (array_key_exists('payment_intent', $transaction)) { $payment_intent = $transaction['payment_intent']; } else { $payment_intent = $transaction['id']; } if (!$payment_intent) { nlog("payment intent not found"); nlog($transaction); return; } $payment = Payment::query() ->where('company_id', $company->id) ->where('transaction_reference', $payment_intent) ->first(); if (!$payment) { nlog("paymentintent found but no payment"); } $company_gateway = CompanyGateway::find($this->company_gateway_id); $stripe_driver = $company_gateway->driver()->init(); $hash = isset($transaction['metadata']['payment_hash']) ? $transaction['metadata']['payment_hash'] : false; if (!$hash) { nlog("no hash found"); return; } $payment_hash = PaymentHash::where('hash', $hash)->first(); if (!$payment_hash) { nlog("no payment hash found"); return; } $stripe_driver->client = $payment_hash->fee_invoice->client; $pi = \Stripe\PaymentIntent::retrieve($payment_intent, $stripe_driver->stripe_connect_auth); $amount = $stripe_driver->convertFromStripeAmount($pi->amount, $stripe_driver->client->currency()->precision, $stripe_driver->client->currency()->precision); $amount_received = $stripe_driver->convertFromStripeAmount($pi->amount_received, $stripe_driver->client->currency()->precision, $stripe_driver->client->currency()->precision); //at this point we just send notification emails to the client and advise of over/under payments. } } }