Advertisement
chrishajer

Modify transaction data sent to authorize.net

Feb 6th, 2013
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.15 KB | None | 0 0
  1. // Originally from here http://pastebin.com/XceGeuBF
  2. // Reference: http://www.gravityhelp.com/forums/topic/sending-additional-information-to-authorizenet-via-namevalue-pairs?replies=5#post-143109
  3. /**
  4.  * E-COMM -- Authorize.net API for GravityForms
  5.  *
  6.  * Modify the transaction data sent to Authorize.net
  7.  * Ref: plugins/gravityformsauthorizenet/authorizenet.php
  8.  */
  9.  
  10. add_filter('gform_authorizenet_before_single_payment','my_anet_custom_fields', 10, 2);
  11. function my_anet_custom_fields($transaction, $form_data) {
  12.  
  13.     # GET DATA FROM FORM INPUT
  14.     $form_data["my_invoice"] = rgpost("input_7"); // different for each form!
  15.     $form_data["customer_id"] = rgpost("input_8"); // different for each form!
  16.     $form_data["custom_data"] = rgpost("input_9"); // different for each form!
  17.  
  18.     # ADD DATA TO TRANSACTION OBJECT
  19.     $transaction->invoice_num   = $form_data["my_invoice"];
  20.     $transaction->cust_id       = $form_data["customer_id"];
  21.     $transaction->description   = 'My Custom Data: ' . $form_data["custom_data"];
  22.  
  23.     # CUSTOM FIELDS: based on the AuthNet AIM api, this should work but it does NOT.
  24.     //$transaction->setCustomField("Color", "Blue");   
  25.    
  26.     return $transaction;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement