Can you please help with the Regex syntax to extract the “message” section of the below raw stripe error. In this case, the message I am trying to extract is “Your card was declined.” - however, I would like to use a generic approach that will work on all similar Stripe error messages please.
Raw error from Stripe.js Plus - Update a customer's details: {
"error": {
"message": "Your card was declined.",
"type": "card_error",
"param": "",
"code": "card_declined",
"decline_code": "generic_decline"
}
}
I am open to other ideas too on how to accomplish the same result without Regex. Essentially, I am trying to populate a generic alert with the correct stripped-down error message from Stripe. Thanks for the help!
@philip - thanks. However, I am actually in the Charge portion of the workflow, rather than the Create Stripetoken portion of the workflow, so I don’t think that the This Stripetoken error provides the Stripe charge-related errors.
@CoBubble - any suggestions please?
Also, for everyone else, please send your Regex ideas as mentioned below (@NigelG@romanmg ?) Thanks!
…then further modify this by truncating the beginning 12 characters and truncating the 1 ending character. You may not need /ig depending on how Bubble parses this. I am sure there are improvements that can be made to this regex (in order to prevent having to further truncate), anyone is welcome to chime in
Yes, that’s what I meant by needing truncate the beginning "message": " and ending ". You can do this within the Bubble editor. IMO the easiest route would be to save the resulting "message": "Your card was declined." as a custom state on your alert box, then on the alert box truncate this text you’re calling from the custom state itself.