Background: I have a Gravity Form using the Stripe Add-on and an embedded Stripe Elements payment field. This is connected to two Stripe feeds (one for single donations, one for monthly donations) and both successfully take payments & set up Stripe subscriptions respectively.
Problem: I now need to attach specific nested metadata to these Stripe payments. The intention is to trigger certain Salesforce functionality; our Stripe setup already sends certain events (e.g. payment intent) onwards to Salesforce but the desired functionality won’t trigger unless it receives metadata in a specific form from Stripe.
The Stripe feed settings allow me to pass custom keys and values within the “metadata” object. However, I don’t think I can nest objects within “metadata”, nor can I establish a new object that doesn’t have “metadata” as a parent. I am trying to determine the best way to accomplish this.
What I’ve Tried:
- I can see that gform_stripe_webhook exists but I’m not sure if this is appropriate, since I want this information to be passed to Stripe in the very first instance (rather than as a separate event after something happens on Stripe’s end).
- I can also see that Gravity Forms has a “Webhooks” add-on/feed. However, again, I’m not sure that contacting the Stripe API through a separate call would attach this metadata to the payment intent (as I desire). Additionally, while the webhook feed has space for authorization headers etc., it feels a little clunky to re-authenticate with Stripe (as this is already being done through the Stripe feeds) and have my credentials sitting in multiple places in Gravity Forms settings.
I’m happy to add to functions.php or whatever is needed, but I’d like some guidance on best practice here with maintainability and security in mind.
More context: The fields that our Salesforce developer has asked us to append to the request to Stripe are as follows (with example data):
{
"metadata": {
"npsp_plus_campaign": {
"Name": "25/26 Adopter Conversion"
}
},
"npsp_plus_contact": {
"MailingCountry": "AU",
"MailingPostalCode": "4300",
"MailingState": "QLD",
"MailingCity": "Springfield Lakes",
"MailingStreet": "16 Tea Trees Avenue",
"npe01__PreferredPhone__c": "Mobile",
"MobilePhone": "0123456789",
"Email": "test@gmail.com.invalid",
"LastName": "TestLastName",
"FirstName": "TestFirstName"
}
}
You can see above that the “metadata” object requires nesting, while we’re also looking for an entirely separate “npsp_plus_contact” object to be created from form data.