#joelbermudez

1 messages · Page 1 of 1 (latest)

burnt ravenBOT
feral rose
#

Not sure I understand exactly. Can't you just retrieve the payment intent and check its amount?

waxen sky
#

That's what I want to achieve. What would be the code.

Should I do like

$amountPaymentIntent = $retrieve->amount;
??

feral rose
#

That looks right

#

Have you tested it?

waxen sky
#

So I can do something like:

else {
  
    $paymentId = $_SESSION['paymentId'];
  
    $retrieve = $stripe->paymentIntents->retrieve(
      $paymentId,
      []
    );
  
    $amountPaymentIntent = $retrieve->amount;

    if ($amountPayment == $amountPaymentIntent) {
      $client_secret = $retrieve->client_secret;
    } else {


      $intent = $stripe->paymentIntents->create([
        'amount' => $amountPayment,
        'currency' => 'eur',
        'setup_future_usage' => 'off_session',
        'customer' => $customer_id,
        'payment_method_types' => ['sepa_debit'],
        'metadata' => ['integration_check' => 'sepa_debit_accept_a_payment'],
        'statement_descriptor' => 'Membership',
      ]);
    
      $client_secret = $intent->client_secret;
    
      $_SESSION['paymentId'] = $intent->id;


    }
  
  }

#

Is that correct?

#

I'm gonna test it now

feral rose
#

Not a php expert, but the logic looks right

#

Recommend you test it

waxen sky
#

Works as expected. Thanks

feral rose
#

No problem