mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for Stripe Bank Transfer
This commit is contained in:
parent
275041b903
commit
29fff76a7f
158
_ide_helper.php
158
_ide_helper.php
@ -4193,7 +4193,7 @@
|
||||
*/
|
||||
public static function lock($name, $seconds = 0, $owner = null)
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->lock($name, $seconds, $owner);
|
||||
}
|
||||
/**
|
||||
@ -4206,7 +4206,7 @@
|
||||
*/
|
||||
public static function restoreLock($name, $owner)
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->restoreLock($name, $owner);
|
||||
}
|
||||
/**
|
||||
@ -4217,30 +4217,65 @@
|
||||
*/
|
||||
public static function flush()
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->flush();
|
||||
}
|
||||
/**
|
||||
* Get the Filesystem instance.
|
||||
* Get the Redis connection instance.
|
||||
*
|
||||
* @return \Illuminate\Filesystem\Filesystem
|
||||
* @return \Illuminate\Redis\Connections\Connection
|
||||
* @static
|
||||
*/
|
||||
public static function getFilesystem()
|
||||
public static function connection()
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
return $instance->getFilesystem();
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->connection();
|
||||
}
|
||||
/**
|
||||
* Get the working directory of the cache.
|
||||
* Get the Redis connection instance that should be used to manage locks.
|
||||
*
|
||||
* @return string
|
||||
* @return \Illuminate\Redis\Connections\Connection
|
||||
* @static
|
||||
*/
|
||||
public static function getDirectory()
|
||||
public static function lockConnection()
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
return $instance->getDirectory();
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->lockConnection();
|
||||
}
|
||||
/**
|
||||
* Specify the name of the connection that should be used to store data.
|
||||
*
|
||||
* @param string $connection
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
public static function setConnection($connection)
|
||||
{
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
$instance->setConnection($connection);
|
||||
}
|
||||
/**
|
||||
* Specify the name of the connection that should be used to manage locks.
|
||||
*
|
||||
* @param string $connection
|
||||
* @return \Illuminate\Cache\RedisStore
|
||||
* @static
|
||||
*/
|
||||
public static function setLockConnection($connection)
|
||||
{
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->setLockConnection($connection);
|
||||
}
|
||||
/**
|
||||
* Get the Redis database instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Redis\Factory
|
||||
* @static
|
||||
*/
|
||||
public static function getRedis()
|
||||
{
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->getRedis();
|
||||
}
|
||||
/**
|
||||
* Get the cache key prefix.
|
||||
@ -4250,8 +4285,20 @@
|
||||
*/
|
||||
public static function getPrefix()
|
||||
{
|
||||
/** @var \Illuminate\Cache\FileStore $instance */
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
return $instance->getPrefix();
|
||||
}
|
||||
/**
|
||||
* Set the cache key prefix.
|
||||
*
|
||||
* @param string $prefix
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
public static function setPrefix($prefix)
|
||||
{
|
||||
/** @var \Illuminate\Cache\RedisStore $instance */
|
||||
$instance->setPrefix($prefix);
|
||||
}
|
||||
|
||||
}
|
||||
@ -9854,45 +9901,44 @@
|
||||
return $instance->setConnectionName($name);
|
||||
}
|
||||
/**
|
||||
* Release a reserved job back onto the queue after (n) seconds.
|
||||
* Migrate the delayed jobs that are ready to the regular queue.
|
||||
*
|
||||
* @param string $queue
|
||||
* @param \Illuminate\Queue\Jobs\DatabaseJobRecord $job
|
||||
* @param int $delay
|
||||
* @return mixed
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @param int $limit
|
||||
* @return array
|
||||
* @static
|
||||
*/
|
||||
public static function release($queue, $job, $delay)
|
||||
public static function migrateExpiredJobs($from, $to)
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
return $instance->release($queue, $job, $delay);
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->migrateExpiredJobs($from, $to);
|
||||
}
|
||||
/**
|
||||
* Delete a reserved job from the queue.
|
||||
*
|
||||
* @param string $queue
|
||||
* @param string $id
|
||||
* @param \Illuminate\Queue\Jobs\RedisJob $job
|
||||
* @return void
|
||||
* @throws \Throwable
|
||||
* @static
|
||||
*/
|
||||
public static function deleteReserved($queue, $id)
|
||||
public static function deleteReserved($queue, $job)
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
$instance->deleteReserved($queue, $id);
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
$instance->deleteReserved($queue, $job);
|
||||
}
|
||||
/**
|
||||
* Delete a reserved job from the reserved queue and release it.
|
||||
*
|
||||
* @param string $queue
|
||||
* @param \Illuminate\Queue\Jobs\DatabaseJob $job
|
||||
* @param \Illuminate\Queue\Jobs\RedisJob $job
|
||||
* @param int $delay
|
||||
* @return void
|
||||
* @static
|
||||
*/
|
||||
public static function deleteAndRelease($queue, $job, $delay)
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
$instance->deleteAndRelease($queue, $job, $delay);
|
||||
}
|
||||
/**
|
||||
@ -9904,7 +9950,7 @@
|
||||
*/
|
||||
public static function clear($queue)
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->clear($queue);
|
||||
}
|
||||
/**
|
||||
@ -9916,19 +9962,30 @@
|
||||
*/
|
||||
public static function getQueue($queue)
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getQueue($queue);
|
||||
}
|
||||
/**
|
||||
* Get the underlying database instance.
|
||||
* Get the connection for the queue.
|
||||
*
|
||||
* @return \Illuminate\Database\Connection
|
||||
* @return \Illuminate\Redis\Connections\Connection
|
||||
* @static
|
||||
*/
|
||||
public static function getDatabase()
|
||||
public static function getConnection()
|
||||
{
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
return $instance->getDatabase();
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getConnection();
|
||||
}
|
||||
/**
|
||||
* Get the underlying Redis instance.
|
||||
*
|
||||
* @return \Illuminate\Contracts\Redis\Factory
|
||||
* @static
|
||||
*/
|
||||
public static function getRedis()
|
||||
{
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getRedis();
|
||||
}
|
||||
/**
|
||||
* Get the backoff for an object-based queue handler.
|
||||
@ -9939,7 +9996,7 @@
|
||||
*/
|
||||
public static function getJobBackoff($job)
|
||||
{ //Method inherited from \Illuminate\Queue\Queue
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getJobBackoff($job);
|
||||
}
|
||||
/**
|
||||
@ -9951,7 +10008,7 @@
|
||||
*/
|
||||
public static function getJobExpiration($job)
|
||||
{ //Method inherited from \Illuminate\Queue\Queue
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getJobExpiration($job);
|
||||
}
|
||||
/**
|
||||
@ -9963,7 +10020,7 @@
|
||||
*/
|
||||
public static function createPayloadUsing($callback)
|
||||
{ //Method inherited from \Illuminate\Queue\Queue
|
||||
\Illuminate\Queue\DatabaseQueue::createPayloadUsing($callback);
|
||||
\Illuminate\Queue\RedisQueue::createPayloadUsing($callback);
|
||||
}
|
||||
/**
|
||||
* Get the container instance being used by the connection.
|
||||
@ -9973,7 +10030,7 @@
|
||||
*/
|
||||
public static function getContainer()
|
||||
{ //Method inherited from \Illuminate\Queue\Queue
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
return $instance->getContainer();
|
||||
}
|
||||
/**
|
||||
@ -9985,7 +10042,7 @@
|
||||
*/
|
||||
public static function setContainer($container)
|
||||
{ //Method inherited from \Illuminate\Queue\Queue
|
||||
/** @var \Illuminate\Queue\DatabaseQueue $instance */
|
||||
/** @var \Illuminate\Queue\RedisQueue $instance */
|
||||
$instance->setContainer($container);
|
||||
}
|
||||
|
||||
@ -17797,25 +17854,6 @@
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @method static void createSubscription(array|string $channels, \Closure $callback, string $method = 'subscribe')
|
||||
* @method static \Illuminate\Redis\Limiters\ConcurrencyLimiterBuilder funnel(string $name)
|
||||
* @method static \Illuminate\Redis\Limiters\DurationLimiterBuilder throttle(string $name)
|
||||
* @method static mixed client()
|
||||
* @method static void subscribe(array|string $channels, \Closure $callback)
|
||||
* @method static void psubscribe(array|string $channels, \Closure $callback)
|
||||
* @method static mixed command(string $method, array $parameters = [])
|
||||
* @method static void listen(\Closure $callback)
|
||||
* @method static string|null getName()
|
||||
* @method static \Illuminate\Redis\Connections\Connection setName(string $name)
|
||||
* @method static \Illuminate\Contracts\Events\Dispatcher getEventDispatcher()
|
||||
* @method static void setEventDispatcher(\Illuminate\Contracts\Events\Dispatcher $events)
|
||||
* @method static void unsetEventDispatcher()
|
||||
* @method static void macro(string $name, object|callable $macro)
|
||||
* @method static void mixin(object $mixin, bool $replace = true)
|
||||
* @method static bool hasMacro(string $name)
|
||||
* @method static void flushMacros()
|
||||
* @method static mixed macroCall(string $method, array $parameters)
|
||||
* @see \Illuminate\Redis\RedisManager
|
||||
*/
|
||||
class Redis {
|
||||
/**
|
||||
|
@ -12,17 +12,17 @@
|
||||
|
||||
namespace App\PaymentDrivers\Stripe;
|
||||
|
||||
use App\Utils\Number;
|
||||
use App\Models\Payment;
|
||||
use App\Models\SystemLog;
|
||||
use Stripe\PaymentIntent;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\PaymentType;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use App\Exceptions\PaymentFailed;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest;
|
||||
use App\Jobs\Util\SystemLogger;
|
||||
use App\Models\GatewayType;
|
||||
use App\Models\Payment;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\StripePaymentDriver;
|
||||
use App\Utils\Number;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Stripe\PaymentIntent;
|
||||
|
||||
class BankTransfer
|
||||
{
|
||||
@ -80,14 +80,12 @@ class BankTransfer
|
||||
*/
|
||||
private function resolveBankType()
|
||||
{
|
||||
|
||||
return match($this->stripe->client->currency()->code){
|
||||
return match ($this->stripe->client->currency()->code) {
|
||||
'GBP' => ['type' => 'gb_bank_transfer'],
|
||||
'EUR' => ['type' => 'eu_bank_transfer', 'eu_bank_transfer' => ['country' => $this->stripe->client->country->iso_3166_2]],
|
||||
'JPY' => ['type' => 'jp_bank_transfer'],
|
||||
'MXN' => ['type' =>'mx_bank_transfer'],
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,16 +103,20 @@ class BankTransfer
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* paymentResponse
|
||||
*
|
||||
* @param mixed $request
|
||||
* @return void
|
||||
*/
|
||||
public function paymentResponse(PaymentResponseRequest $request)
|
||||
{
|
||||
|
||||
$this->stripe->init();
|
||||
|
||||
$this->stripe->setPaymentHash($request->getPaymentHash());
|
||||
$this->stripe->client = $this->stripe->payment_hash->fee_invoice->client;
|
||||
|
||||
if($request->payment_intent){
|
||||
|
||||
if ($request->payment_intent) {
|
||||
$pi = \Stripe\PaymentIntent::retrieve(
|
||||
$request->payment_intent,
|
||||
$this->stripe->stripe_connect_auth
|
||||
@ -126,9 +128,8 @@ class BankTransfer
|
||||
}
|
||||
|
||||
/* Create a pending payment */
|
||||
if($pi->status == 'requires_action' && $pi->next_action->type == 'display_bank_transfer_instructions') {
|
||||
|
||||
match($pi->next_action->display_bank_transfer_instructions->currency){
|
||||
if ($pi->status == 'requires_action' && $pi->next_action->type == 'display_bank_transfer_instructions') {
|
||||
match ($pi->next_action->display_bank_transfer_instructions->currency) {
|
||||
'mxn' => $data['bank_details'] = $this->formatDataforMx($pi),
|
||||
'gbp' => $data['bank_details'] = $this->formatDataforUk($pi),
|
||||
'eur' => $data['bank_details'] = $this->formatDataforEur($pi),
|
||||
@ -138,40 +139,20 @@ class BankTransfer
|
||||
$payment = $this->processSuccesfulRedirect($pi);
|
||||
|
||||
return render('gateways.stripe.bank_transfer.bank_details_container', $data);
|
||||
|
||||
// $data = [
|
||||
// 'payment_method' => $pi->payment_method,
|
||||
// 'payment_type' => PaymentType::DIRECT_DEBIT,
|
||||
// 'amount' => $this->stripe->convertFromStripeAmount($this->stripe->payment_hash->data->stripe_amount, $this->stripe->client->currency()->precision, $this->stripe->client->currency()),
|
||||
// 'transaction_reference' => $pi->id,
|
||||
// 'gateway_type_id' => GatewayType::DIRECT_DEBIT,
|
||||
|
||||
// ];
|
||||
|
||||
// $payment = $this->stripe->createPayment($data, Payment::STATUS_PENDING);
|
||||
|
||||
// SystemLogger::dispatch(
|
||||
// ['response' => $this->stripe->payment_hash->data, 'data' => $data],
|
||||
// SystemLog::CATEGORY_GATEWAY_RESPONSE,
|
||||
// SystemLog::EVENT_GATEWAY_SUCCESS,
|
||||
// SystemLog::TYPE_STRIPE,
|
||||
// $this->stripe->client,
|
||||
// $this->stripe->client->company,
|
||||
// );
|
||||
|
||||
// return redirect($pi->next_action->display_bank_transfer_instructions->hosted_instructions_url);
|
||||
|
||||
}
|
||||
|
||||
return $this->processUnsuccesfulRedirect();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* formatDataForUk
|
||||
*
|
||||
* @param PaymentIntent $pi
|
||||
* @return array
|
||||
*/
|
||||
public function formatDataForUk(PaymentIntent $pi): array
|
||||
{
|
||||
|
||||
return [
|
||||
'amount' => Number::formatMoney($this->stripe->convertFromStripeAmount($pi->next_action->display_bank_transfer_instructions->amount_remaining, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $this->stripe->client),
|
||||
'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->sort_code->account_holder_name,
|
||||
@ -183,12 +164,16 @@ class BankTransfer
|
||||
'currency' => $pi->next_action->display_bank_transfer_instructions->currency,
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* formatDataforMx
|
||||
*
|
||||
* @param PaymentIntent $pi
|
||||
* @return array
|
||||
*/
|
||||
public function formatDataforMx(PaymentIntent $pi): array
|
||||
{
|
||||
|
||||
return [
|
||||
'amount' => Number::formatMoney($this->stripe->convertFromStripeAmount($pi->next_action->display_bank_transfer_instructions->amount_remaining, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $this->stripe->client),
|
||||
'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->spei->bank_name,
|
||||
@ -200,14 +185,17 @@ class BankTransfer
|
||||
'currency' => $pi->next_action->display_bank_transfer_instructions->currency,
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* formatDataforEur
|
||||
*
|
||||
* @param mixed $pi
|
||||
* @return array
|
||||
*/
|
||||
public function formatDataforEur(PaymentIntent $pi): array
|
||||
{
|
||||
|
||||
return [
|
||||
'amount' => Number::formatMoney($this->stripe->convertFromStripeAmount($pi->next_action->display_bank_transfer_instructions->amount_remaining, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $this->stripe->client),
|
||||
'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->iban->account_holder_name,
|
||||
@ -219,8 +207,6 @@ class BankTransfer
|
||||
'currency' => $pi->next_action->display_bank_transfer_instructions->currency,
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,7 +216,6 @@ class BankTransfer
|
||||
*/
|
||||
public function formatDataforJp(PaymentIntent $pi): array
|
||||
{
|
||||
|
||||
return [
|
||||
'amount' => Number::formatMoney($this->stripe->convertFromStripeAmount($pi->next_action->display_bank_transfer_instructions->amount_remaining, $this->stripe->client->currency()->precision, $this->stripe->client->currency()), $this->stripe->client),
|
||||
'account_holder_name' => $pi->next_action->display_bank_transfer_instructions->financial_addresses[0]->zengin->account_holder_name,
|
||||
@ -246,12 +231,16 @@ class BankTransfer
|
||||
'currency' => $pi->next_action->display_bank_transfer_instructions->currency,
|
||||
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function processSuccesfulRedirect($payment_intent)
|
||||
/**
|
||||
* processSuccesfulRedirect
|
||||
*
|
||||
* @param PaymentIntent $payment_intent
|
||||
* @return Payment
|
||||
*/
|
||||
public function processSuccesfulRedirect(PaymentIntent $payment_intent): Payment
|
||||
{
|
||||
$this->stripe->init();
|
||||
|
||||
@ -278,6 +267,11 @@ class BankTransfer
|
||||
return $payment;
|
||||
}
|
||||
|
||||
/**
|
||||
* processUnsuccesfulRedirect
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function processUnsuccesfulRedirect()
|
||||
{
|
||||
$server_response = $this->stripe->payment_hash->data;
|
||||
@ -300,6 +294,4 @@ class BankTransfer
|
||||
|
||||
throw new PaymentFailed('Failed to process the payment.', 500);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user