Skip to content

Commit

Permalink
fix: retourner l'objet session au complet plutot que seulement l'id, …
Browse files Browse the repository at this point in the history
…c'est plus efficace pour le reutiliser ensuite si besoin
  • Loading branch information
Cerdic committed Jan 22, 2024
1 parent bb816bf commit b1ded59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions presta/stripe/call/autoresponse.php
Expand Up @@ -448,7 +448,7 @@ function stripe_webhook_payment_intent_payment_failed_dist($config, $event){
$payment_intent_id = $payment_intent->id;

if ($res = stripe_retrouve_transaction_par_payment_et_customer($config, $customer_id, $payment_intent_id, $date_payment)) {
[$transaction, $checkout_session_id] = $res;
[$transaction, $checkout_session] = $res;
// enregistrer l'echec du paiement sur la transaction
$response = [
'payment_id' => $payment_intent_id,
Expand Down Expand Up @@ -493,7 +493,7 @@ function stripe_webhook_payment_intent_requires_action_dist($config, $event){
$payment_intent_id = $payment_intent->id;

if ($res = stripe_retrouve_transaction_par_payment_et_customer($config, $customer_id, $payment_intent_id, $date_payment)) {
[$transaction, $checkout_session_id] = $res;
[$transaction, $checkout_session] = $res;
$id_transaction = $transaction['id_transaction'];
spip_log("stripe_webhook_payment_requires_action_dist: payment_intent.requires_action sur transaction #$id_transaction", $mode . _LOG_DEBUG);
// doit on faire quelque chose ? a priori non, c'est purement informatif
Expand Down
8 changes: 4 additions & 4 deletions presta/stripe/inc/stripe.php
Expand Up @@ -218,10 +218,10 @@ function stripe_retrouve_transaction_par_payment_et_customer($config, $customer_
foreach ($transactions as $transaction) {
if (!empty($transaction['token']) and $tokens = json_decode($transaction['token'], true)) {
foreach ($tokens as $checkout_session_id) {
if ($session = \Stripe\Checkout\Session::retrieve($checkout_session_id)) {
if (!empty($session->payment_intent)
and $session->payment_intent === $payment_intent_id) {
return [$transaction, $checkout_session_id];
if ($checkout_session = \Stripe\Checkout\Session::retrieve($checkout_session_id)) {
if (!empty($checkout_session->payment_intent)
and $checkout_session->payment_intent === $payment_intent_id) {
return [$transaction, $checkout_session];
}
}
}
Expand Down

0 comments on commit b1ded59

Please sign in to comment.