#steven-invoice
1 messages · Page 1 of 1 (latest)
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
Yes, this step will confirm the PaymentIntent, meaning it will attempt to charge the card.
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
Yes, this is a correct flow.
ok but I'm not getting a client secret
do you mind sharing a snippet of your code please?
`$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']] );
any suggestions?
Please find the following flow:
- Capture payment method
- Create PaymentMethod object
- Attach this PaymentMethod to a Customer object
- Create an Invoice Item with this Customer id
- 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.