I'm migrating an e-commerce platform from using SagePay to Stripe.
The docs show using an amount
figure of 1099
and a currency of gbp
(https://stripe.com/docs/payments/accept-a-payment#web-create-payment-intent).
As far as I can tell this means £10.99 (not £1099). But this is extremely unclear in their docs - I am assuming this is the case.
If I try and send amount => 10.99
through their API, I get an error message in the response:
"error": {
"code": "parameter_invalid_integer",
"doc_url": "https://stripe.com/docs/error-codes/parameter-invalid-integer",
"message": "Invalid integer: 10.99",
"param": "amount",
"type": "invalid_request_error"
}
With SagePay you would actually send 10.99
as the amount.
So, with Stripe, do you have to convert all amounts to the single base unit of a currency (pence in the case of GBP), for example if the amount was £10.99 you'd do (10.99 * 100)
then send 1099
?
The docs don't actually make this clear. If you read up on Decimal Amounts (https://stripe.com/docs/billing/subscriptions/decimal-amounts) in their docs it says you can use a parameter called amount_decimal
but this will also give an error if sent through their API:
$intent = \Stripe\PaymentIntent::create([
'amount_decimal' => 10.99,
'currency' => 'gbp',
// Verify your integration in this guide by including this parameter
'metadata' => ['integration_check' => 'accept_a_payment'],
]);
Results in an error saying the parameter, amount_decimal
, is unknown (even though it's in their docs?):
"error": {
"code": "parameter_unknown",
"doc_url": "https://stripe.com/docs/error-codes/parameter-unknown",
"message": "Received unknown parameter: amount_decimal",
"param": "amount_decimal",
"type": "invalid_request_error"
}
My assumption is that this error is because this part of the documentation is referring to billing for "plans" as opposed to one-off Payments. I'm wanting to accept a card payment for one-off invoices so have used the Accept a Card Payment docs.
So my question is: Do you just send the amount in the smallest unit of the currency (e.g. 10.99 * 100
for £10.99), or is there some other method where it can be passed as a decimal (i.e. 10.99
)?