#steven-invoice

1 messages · Page 1 of 1 (latest)

narrow plover
#

Hi there! Please give me a moment to catch up in your previous thread.

sage spruce
#

644pm from Rubeus

#

does stripe.confirmCardPayment actually charge the card?

narrow plover
#

Is there a request id I could look at please?

#

For your information, if the payment has not been successful, the PaymentIntent object will return null

narrow plover
sage spruce
#

ok so he told me to create a card element without client secret. then once they enter data, do createPaymentMethod so I Can get a paymentMethodID
then create an invoice with the invoiceItems and it will return a payment Intent client secret

#

then pass those 2 values to confirmCardPayment

narrow plover
#

Yes, this is a correct flow.

sage spruce
#

ok but I'm not getting a client secret

narrow plover
#

do you mind sharing a snippet of your code please?

sage spruce
#

`$stripe->invoiceItems->create([
'customer' => $_REQUEST['customerId'],
'price' => $price->id,
]);

$invoice = $stripe->invoices->create([
  'customer' => $_REQUEST['customerId'],
  'auto_advance' => false,
]);`
#

thats how I create the invoice

#

all variables are already defines

#

even without client secret, can I take the paymentMethodID from createPaymentMethod and pass it and the generated invoiceID to $stripe->invoices->pay?

#

$stripe->invoices->pay( 'in_1KeUl0AvXb0N1jioIh7hHDKB', [payment_method => $_REQUEST['paymentMethodID']] );

sage spruce
#

any suggestions?

narrow plover
#

Please find the following flow:

  1. Capture payment method
  2. Create PaymentMethod object
  3. Attach this PaymentMethod to a Customer object
  4. Create an Invoice Item with this Customer id
  5. Create an Invoice with this Customer id

The resulting Invoice will contain the payment_intent object.

#

At first, this PaymentIntent is null, as there is no payment yet.

After the invoice is finalized, depending on how you have defined to pay the invoice, i.e. send_invoice or charge_automatically.

Either the invoice will be sent to customer to complete payment, or it will charge the default payment method defined above.

#

After the invoice has been paid, then the Invoice object will contain a PaymentIntent object with the payment details.