I'm currently working on implementing Stripe, and utilizing metadata in the process.
Everything works smoothly until I come across a scenario where I need to update a value in the metadata to determine if a specific uuid has been used before.
payment_intent_data: {
metadata: {
uuid: usedUuid,
isUsed: "false",
},
Here's an example of the function I'm using to verify the validity of the UUID, and I'm unsure about how to update the metadata for the invalidate function:
async function isValidUuid(uuid: string): Promise<boolean> {
// TODO: check if uuid has been used before and its valid
var isValid = uuid4.valid(uuid);
const charges = await stripe.charges.search({
query: `metadata[\'uuid\']:${uuid} AND metadata[\'isUsed\']:\'false\'`,
});
return isValid && charges.data.length > 0;
}
Can someone provide guidance on updating the isUsed field?
Thanks in advance