@shifoodew Use Stripe\Charge::create(). I used to create invoices, but had instances where people were re-attempting orders if their payment failed, but Stripe would then re-process those failed invoices at a later date, leaving customers being charged multiple times.
When you create a charge using the Stripe SDK, the charge details are returned to you for you to use:
$charge = \Stripe\Charge::create([
'amount' => 1000,
// Any other parameters
]);
$id = $charge['id'];
$cardLastFour = $charge['source']['last4'];
You can see what parameters you need to send, and what response you’ll get back for a charge, on Stripe’s documentation website: https://stripe.com/docs/api#create_charge
@martinbean I mean in what scenario should I used Stripe\Charge::create()?
1.) should I used Stripe\Charge::create() for one-time payment only like buying products online?
2.)is it advisable to use \Stripe\InvoiceItem::create() for purchasing item (when to used)?
what is the advantage if I used Stripe\Charge::create() over \Stripe\InvoiceItem::create() for checking out an item?
for now, I'm using Stripe\Charge::create() for purchasing a product. I don't know if I'm on the right path.
@shifoodew Yes, you should create a charge for one-time payments like buying products online. I gave you an example of why you should create a charge over creating an invoice item.