Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

shifoodew's avatar

stripe "When to use Charge::create and \Stripe\InvoiceItem::create " ?

Hi! good day I'm new to stripe and I just want to ask when to use \Stripe\InvoiceItem::create and Charge::create in stripe.

Should I use Charge::create for my checkout products or should I use \Stripe\InvoiceItem::create ?

Also, I want to store the details after the successful charged of an item. Note this one-time payment only.

hope you can guide me, guys! Thnx in advance.

0 likes
3 replies
martinbean's avatar

@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

shifoodew's avatar

@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.

martinbean's avatar

@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.

Please or to participate in this conversation.