mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Decorate stripe payment intents with payment hashes and gateway ids
This commit is contained in:
parent
cd1dbc1f56
commit
da7ac32703
@ -143,6 +143,10 @@ class ACSS
|
||||
'payment_method_types' => ['acss_debit'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::ACSS,
|
||||
],
|
||||
'payment_method_options' => [
|
||||
'acss_debit' => [
|
||||
'mandate_options' => [
|
||||
|
@ -48,6 +48,10 @@ class ApplePay
|
||||
$data['intent'] = \Stripe\PaymentIntent::create([
|
||||
'amount' => $data['stripe_amount'],
|
||||
'currency' => $this->stripe_driver->client->getCurrencyCode(),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe_driver->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::APPLE_PAY,
|
||||
],
|
||||
], $this->stripe_driver->stripe_connect_auth);
|
||||
|
||||
$this->stripe_driver->payment_hash->data = array_merge((array) $this->stripe_driver->payment_hash->data, ['stripe_amount' => $data['stripe_amount']]);
|
||||
|
@ -56,7 +56,10 @@ class BECS
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BECS,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -52,6 +52,10 @@ class Bancontact
|
||||
'payment_method_types' => ['bancontact'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::BANCONTACT,
|
||||
],
|
||||
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
|
@ -71,6 +71,10 @@ class BrowserPay implements MethodInterface
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::APPLE_PAY,
|
||||
],
|
||||
];
|
||||
|
||||
$data['gateway'] = $this->stripe;
|
||||
|
@ -78,6 +78,10 @@ class Charge
|
||||
'customer' => $cgt->gateway_customer_reference,
|
||||
'confirm' => true,
|
||||
'description' => $description,
|
||||
'metadata' => [
|
||||
'payment_hash' => $payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
||||
],
|
||||
];
|
||||
|
||||
$response = $this->stripe->createPaymentIntent($data, $this->stripe->stripe_connect_auth);
|
||||
|
@ -63,10 +63,13 @@ class CreditCard
|
||||
'currency' => $this->stripe->client->getCurrencyCode(),
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::CREDIT_CARD,
|
||||
],
|
||||
'setup_future_usage' => 'off_session',
|
||||
];
|
||||
|
||||
$payment_intent_data['setup_future_usage'] = 'off_session';
|
||||
|
||||
$data['intent'] = $this->stripe->createPaymentIntent($payment_intent_data);
|
||||
$data['gateway'] = $this->stripe;
|
||||
|
||||
|
@ -52,7 +52,10 @@ class EPS
|
||||
'payment_method_types' => ['eps'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::EPS,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -53,7 +53,10 @@ class FPX
|
||||
'payment_method_types' => ['fpx'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::FPX,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -52,7 +52,10 @@ class GIROPAY
|
||||
'payment_method_types' => ['giropay'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::GIROPAY,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -52,7 +52,10 @@ class PRZELEWY24
|
||||
'payment_method_types' => ['p24'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::PRZELEWY24,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -54,6 +54,10 @@ class SEPA
|
||||
'setup_future_usage' => 'off_session',
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SEPA,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -52,7 +52,10 @@ class SOFORT
|
||||
'payment_method_types' => ['sofort'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::SOFORT,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -52,7 +52,10 @@ class iDeal
|
||||
'payment_method_types' => ['ideal'],
|
||||
'customer' => $this->stripe->findOrCreateCustomer(),
|
||||
'description' => $this->stripe->decodeUnicodeString(ctrans('texts.invoices') . ': ' . collect($data['invoices'])->pluck('invoice_number')),
|
||||
|
||||
'metadata' => [
|
||||
'payment_hash' => $this->stripe->payment_hash->hash,
|
||||
'gateway_type_id' => GatewayType::IDEAL,
|
||||
],
|
||||
], $this->stripe->stripe_connect_auth);
|
||||
|
||||
$data['pi_client_secret'] = $intent->client_secret;
|
||||
|
@ -25,25 +25,26 @@ use App\Models\PaymentHash;
|
||||
use App\Models\PaymentType;
|
||||
use App\Models\SystemLog;
|
||||
use App\PaymentDrivers\Stripe\ACH;
|
||||
use App\PaymentDrivers\Stripe\ACSS;
|
||||
use App\PaymentDrivers\Stripe\Alipay;
|
||||
use App\PaymentDrivers\Stripe\ApplePay;
|
||||
use App\PaymentDrivers\Stripe\BECS;
|
||||
use App\PaymentDrivers\Stripe\Bancontact;
|
||||
use App\PaymentDrivers\Stripe\BrowserPay;
|
||||
use App\PaymentDrivers\Stripe\Charge;
|
||||
use App\PaymentDrivers\Stripe\Connect\Verify;
|
||||
use App\PaymentDrivers\Stripe\CreditCard;
|
||||
use App\PaymentDrivers\Stripe\ImportCustomers;
|
||||
use App\PaymentDrivers\Stripe\SOFORT;
|
||||
use App\PaymentDrivers\Stripe\SEPA;
|
||||
use App\PaymentDrivers\Stripe\PRZELEWY24;
|
||||
use App\PaymentDrivers\Stripe\GIROPAY;
|
||||
use App\PaymentDrivers\Stripe\iDeal;
|
||||
use App\PaymentDrivers\Stripe\EPS;
|
||||
use App\PaymentDrivers\Stripe\Bancontact;
|
||||
use App\PaymentDrivers\Stripe\BECS;
|
||||
use App\PaymentDrivers\Stripe\ACSS;
|
||||
use App\PaymentDrivers\Stripe\BrowserPay;
|
||||
use App\PaymentDrivers\Stripe\FPX;
|
||||
use App\PaymentDrivers\Stripe\GIROPAY;
|
||||
use App\PaymentDrivers\Stripe\ImportCustomers;
|
||||
use App\PaymentDrivers\Stripe\Jobs\PaymentIntentWebhook;
|
||||
use App\PaymentDrivers\Stripe\PRZELEWY24;
|
||||
use App\PaymentDrivers\Stripe\SEPA;
|
||||
use App\PaymentDrivers\Stripe\SOFORT;
|
||||
use App\PaymentDrivers\Stripe\UpdatePaymentMethods;
|
||||
use App\PaymentDrivers\Stripe\Utilities;
|
||||
use App\PaymentDrivers\Stripe\iDeal;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
use Exception;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@ -472,10 +473,7 @@ class StripePaymentDriver extends BaseDriver
|
||||
$response = null;
|
||||
|
||||
try {
|
||||
// $response = $this->stripe
|
||||
// ->refunds
|
||||
// ->create(['charge' => $payment->transaction_reference, 'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision, $this->client->currency())], $meta);
|
||||
|
||||
|
||||
$response = \Stripe\Refund::create([
|
||||
'charge' => $payment->transaction_reference,
|
||||
'amount' => $this->convertToStripeAmount($amount, $this->client->currency()->precision, $this->client->currency())
|
||||
@ -532,6 +530,13 @@ class StripePaymentDriver extends BaseDriver
|
||||
// Allow app to catch up with webhook request.
|
||||
sleep(2);
|
||||
|
||||
//payment_intent.succeeded - this will confirm or cancel the payment
|
||||
if($request->type === 'payment_intent.succeeded'){
|
||||
PaymentIntentWebhook::dispatch($request->all(), $request->company_key, $this->company_gateway->id)->delay(10);
|
||||
// PaymentIntentWebhook::dispatch($request->all(), $request->company_key, $this->company_gateway->id);
|
||||
return response()->json([], 200);
|
||||
}
|
||||
|
||||
if ($request->type === 'charge.succeeded' || $request->type === 'payment_intent.succeeded') {
|
||||
|
||||
foreach ($request->data as $transaction) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user