cancel
Showing results for 
Search instead for 
Did you mean: 

DMP - can't capture response results vars

Hi all,

I am trying to set up DPM with php from the PDF docs - DirectPost_guide.pdf. I have 3 pages:

checkout_form.php
relay_response.php
order_receipt.php


Basically it works - but on the order_receipt.php page the only result param vars that seems to show up are the response_code and transaction_id.

I can display them:

echo $_GET['response_code'];
echo $_GET['transaction_id'];

But I want to capture other vars like

x_card_type
x_first_name
x_last_name

etc…….

Since they are not in the url query string on order_receipt.php I would think I can capture them in my database on this page = relay_response.php

BTW: when I use this = https://developer.authorize.net/tools/paramdump/index.php

I see lots of fields and data
===================

x_response_code 1
x_response_reason_code 1
x_response_reason_text This transaction has been approved.
x_avs_code Y
x_auth_code 302EGP

x_first_name John
x_last_name Doe

etc…

but I can't seem to add them to the mysql database from relay_response.php


Q: HOW AND WHERE can I capture these fields? PLEASE KEEP IT SIMPLE for this newbie...

 

coolcat
Contributor
5 REPLIES 5

here's the code for the = relay_response.php page...

 

---------- the only field that gets in the database = $response->transaction_id - the others are blank!

 

BTW: i DO get an email from AN WITH ALL THE CUSTOMER FIELDS ETC.....

 

Q: SO HOW DO I CAPTURE THEM IN MY DATABASE? 

 

 

 

 

<?php
if(!session_id()) session_start();

require_once 'anet_php_sdk/AuthorizeNet.php'; // The SDK

$redirect_url = "http://www.mysite.com/store/cart/order_receipt.php";
$api_login_id = 'xxx';
$md5_setting = "xxx"; // Your MD5 Setting
$response = new AuthorizeNetSIM($api_login_id, $md5_setting);
if ($response->isAuthorizeNet())
{
if ($response->approved)
{

// Do your processing here.

require_once('connector.php');

$look = 'test'.$response->transaction_id.'-'.$response->x_first_name.'-'.$response->x_last_name.'-'.$response->x_amount;

$pdo = new PDO("mysql:host=$hostname_weblink;dbname=$database_weblink", $username_weblink, $password_weblink);

$sql = "UPDATE invtest
SET info1=?
WHERE id=?";
$q = $pdo->prepare($sql);
$q->execute(array($look,'1001'));

// end database capture

$redirect_url .= '?response_code=1&transaction_id=' .
$response->transaction_id;
}
else
{
$redirect_url .= '?response_code='.$response->response_code .
'&response_reason_text=' . $response->response_reason_text;
}
// Send the Javascript back to AuthorizeNet, which will redirect user back to your site.
echo AuthorizeNetDPM::getRelayResponseSnippet($redirect_url);
}
else
{
echo "Error. Check your MD5 Setting.";
}?>

coolcat
Contributor

Hi all,

 

ok - when I try

print_r($response, true);

i get nothing back - but when I use

print_r($response);

 

then I get lots!!!! (see below)

 

so maybe this newbie does not know how to display the fields correctly via php? if I want to echo transaction_id I write:

 

echo $response->transaction_id;

and it show on the page but this

echo  $response->x_first_name;

DOES NOT SHOW "John" just empty like many others

 

Q: How can I write this so it will display "John" on the page? something different from echo  $response->x_first_name; ????

 

 

 

-----------------------

 

 

 

AuthorizeNetSIM Object ( [subscription_id] => [subscription_paynum] => [approved] => 1 [declined] => [error] => [held] => [response_code] => 1 [response_subcode] => [response_reason_code] => 1 [response_reason_text] => This transaction has been approved. [authorization_code] => DBBLWT [avs_response] => Y [transaction_id] => 2195410177 [invoice_number] => [description] => [amount] => 1.01 [method] => CC [transaction_type] => [customer_id] => [first_name] => John [last_name] => Doe [company] => [address] => 123 Main Street [city] => Boston [state] => MA [zip_code] => [country] => US [phone] => [fax] => [email_address] => [ship_to_first_name] => [ship_to_last_name] => [ship_to_company] => [ship_to_address] => [ship_to_city] => [ship_to_state] => [ship_to_zip_code] => [ship_to_country] => [tax] => 0.00 [duty] => 0.00 [freight] => 0.00 [tax_exempt] => FALSE [purchase_order_number] => [md5_hash] => E0B767AB8FEB72C97A8591E6E533A2B4 [card_code_response] => P [cavv_response] => 2 [account_number] => XXXX0012 [card_type] => Discover [split_tender_id] => [requested_amount] => [balance_on_card] => [response] => Array ( [x_response_code] => 1 [x_response_reason_code] => 1 [x_response_reason_text] => This transaction has been approved. [x_avs_code] => Y [x_auth_code] => DBBLWT [x_trans_id] => 2195410177 [x_method] => CC [x_card_type] => Discover [x_account_number] => XXXX0012 [x_first_name] => John [x_last_name] => Doe [x_company] => [x_address] => 123 Main Street [x_city] => Boston [x_state] => MA [x_zip] => 02142 [x_country] => US [x_phone] => [x_fax] => [x_email] => [x_invoice_num] => [x_description] => [x_type] => auth_capture [x_cust_id] => [x_ship_to_first_name] => [x_ship_to_last_name] => [x_ship_to_company] => [x_ship_to_address] => [x_ship_to_city] => [x_ship_to_state] => [x_ship_to_zip] => [x_ship_to_country] => [x_amount] => 1.01 [x_tax] => 0.00 [x_duty] => 0.00 [x_freight] => 0.00 [x_tax_exempt] => FALSE [x_po_num] => [x_MD5_Hash] => E0B767AB8FEB72C97A8591E6E533A2B4 [x_cvv2_resp_code] => P [x_cavv_response] => 2 [x_test_request] => false [x_invidtest3] => 33 [x_amount999] => 1.02 [x_invidtest1] => 61 [x_invidtest2] => 199 ) [api_login_id] => 734BRxs69p [md5_setting] => 1234554321 [avs_code] => Y [auth_code] => DBBLWT [trans_id] => 2195410177 [zip] => 02142 [email] => [invoice_num] => [type] => auth_capture [cust_id] => [ship_to_zip] => [po_num] => [MD5_Hash] => E0B767AB8FEB72C97A8591E6E533A2B4 [cvv2_resp_code] => P [test_request] => false [invidtest3] => 33 [amount999] => 1.02 [invidtest1] => 61 [invidtest2] => 199 )

Well I learned this...

 

echo $response->x_first_name; //does not work

but

echo $response->first_name;  //does work

 

I see that inside the entire  AuthorizeNetSIM Object is an array - but need help figuring how to work and display both?

 

[first_name] => John

in array....

[x_first_name] => John

 

Q: why are there dupes of these and how do I diaplay both of them?

AuthorizeNetSIM contain both the request and response

 

in anet_php_sdk-1.1.8.zip\anet_php_sdk\lib\AuthorizeNetSIM.php

class AuthorizeNetSIM extends AuthorizeNetResponse

 

$response on the other hand only contain response

anet_php_sdk-1.1.8.zip\anet_php_sdk\lib\shared\AuthorizeNetResponse.php

 

print_r($response, TRUE) returns a string representation of $response. If you do not assign it to a variable, it goes nowhere. If you are trying to log to a file, you want to do something like file_put_contents($file_path, print_r($response, TRUE)); Since this is a relay response page, print_r() without the TRUE won't do anything particularly useful.

 

http://php.net/manual/en/function.print-r.php

http://php.net/manual/en/function.file-put-contents.php