I have implemented Stripe in my Flutter app, but I would like to add some information to the payment done in order to recognize the payment inside the payments list inside the Stripe dashboard panel.
This is the response from Stripe when generating a payment:
// 1. Create a payment intent on the server
final response = await http.post(
Uri.parse(
'https://...stripePaymentIntentRequest'),
body: {
'email': email,
'amount': amount.toString(),
'description': widget.codigo_pedido ,
});
final jsonResponse = jsonDecode(response.body);
print("respuests stripe: ${jsonResponse.toString()}");
respuests stripe: {paymentIntent: pi_3M6dBTCcyi0G23rG0FoA7fEl_secret_h6dewQiWveMe5HsPg5MxCduTB, ephemeralKey: ek_test_YWNjdF8xR3NQRm5DY3lpMEcyM3JHLHFiV3ZQRkpBM3VHNHNFOFM3RHJvemxiYlpyaTRSazA_00HIJiGkLl, customer: cus_MqJLygEutMbF4X, success: true}
Is there a way to add some extra information inside the payment intent?
CodePudding user response:
To store additional information on the Payment Intent object, you can add a metadata. Metadata is a key-value pairs that can be attached to an object. To learn more, you review this document.
Your server side code should look something like this:
$stripe->paymentIntents->create(
[
'amount' => 1099,
'currency' => 'usd',
'metadata' => ['order_id' => '6735'],
]
);