How to charge and order for specific products using stripe?

682 views Asked by At

Suppose I have a product prod_1. What are the steps to create an order for prod_1 and charge it?

I'm thinking the order would be

1 create order
2 get source token
3 pay order

Where do I tell it how much to charge? I need to create a charge but not sure I can pass that to the order.

How to I assign this order to a product?

note: I don't want to get a customer involved in this transaction. That's the reason I'm getting a 'source token'

Any ideas?

1

There are 1 answers

3
Dai On BEST ANSWER

Stripe has no concept of "products" - all it's concerned with is a Charge, which sets the amount of money you want to extract from your visitor's wallets.

And the amount charged is set on the Charge entity. In PHP, like so:

$charge = \Stripe\Charge::create(array(
    'amount'   => $amountYouWantToChargeInIntegralUsdCents,
    'currency' => 'usd'
));

In the Stripe.com web-application there is a heading "Relay" with the options "Products" and "Orders", however this refers to "Stripe Relay" which is meant for creating mini-marketplaces within smartphone apps, it is irrelevant to normal Stripe payments.