TARKUS
TARKUS

Reputation: 2200

How to get First Data JSON response object properties?

I am using the VinceG\FirstDataApi in the First Data demo mode account fairly successfully. That is, I send a simulated credit card payment, and I receive a full JSON object, error=0, approved=1, etc.

Within this set is some of the information I want to use to construct the "thank you" page or the "Something went wrong" page:

[arrayResponse:protected] => stdClass Object
    (
        [transaction_error] => 0
        [transaction_approved] => 1
        [exact_resp_code] => 00
        [exact_message] => Transaction Normal
        [bank_resp_code] => 100
        [bank_message] => Approved
        [sequence_no] => 000008
        [cvv2] => I
        [retrieval_ref_no] => 4241673
        [merchant_name] => MY COMPANY NAME
        [merchant_address] => MY COMPANY ADDRESS
        [merchant_city] => MY COMPANY CITY
        [merchant_province] => MY COMPANY STATE
        [merchant_country] => United States
        [merchant_postal] => MY COMPANY ZIPCODE
        [merchant_url] => https:/my.website.com

I have tried to access the properties within the array:

echo "<pre>";
print_r($firstData->arrayResponse);

...and the output is "Cannot access protected property FirstData::$arrayResponse".

Upvotes: 0

Views: 469

Answers (1)

TARKUS
TARKUS

Reputation: 2200

Ok, this looks wierd to me, but the answer is:

echo "<pre>";
print_r($firstData->getarrayResponse());

...Appending the word get in front of the protected property arrayResponse to make getarrayResponse(). Looks like a horrible method invention, but there you have it.

Upvotes: 0

Related Questions