Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass metadata for stripe payments in ColdFusion cfpayment library?

Tags:

coldfusion

I'm using the ColdFusion CFPayment Library for processing Stripe payments. The payments are working fine, but now I want to pass metadata values to along with the transaction.

I went into the stripe.cfc file in the library and passed the static metadata values, but in the stripe logs it's showing a request like this:

{
  "firstname2": "test",
  "source": "tok_1**************",
  "currency": "usd",
  "description": "test",
  "amount": "3300"
}

The value firstname2 was supposed to be in metadata, but it's automatically putting this value in the main array / json.

Added later

TransactionData = {
    "description" = "test",
    "metadata[test]" = "1",
    "metadata[FirstName]" = "Abdur",
    "metadata[LastName]" = "Rehman",
    "description" = "Online Donation"
 };

gw_response = gw.purchase(money=money, account=account, options=TransactionData);

I modified my code according to your example but TransactionData items are not being displayed in the request.

like image 526
Abdur Rehman Avatar asked Nov 21 '25 20:11

Abdur Rehman


1 Answers

I've been successfully using metadata w/Stripe using CFPayment. When authorizing, you need to pass an object as the third parameter and name your keys something like this.:

TransactionData = {
  "statement_descriptor" = "Descriptor Override (5-22 chars)",
  "metadata[test]" = "1",
  "metadata[donorid]" = DonorID,
  "metadata[accountid]" = AccountID,
  "description" = "Online Donation"
};

authResponse = gateway.authorize(money, cardAccount, TransactionData);

"description" and "statement-descriptor" are not required, but I like to include them so I can override the Stripe account defaults.

like image 68
James Moberg Avatar answered Nov 25 '25 00:11

James Moberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!