Reputation: 9191
I'm working with SOAP to communicate with a payment platform, I'm nearly there, the only problem remaining is that i can't seem to translate the answer from the server into an action
i've tried using method_exists as follows
if(property_exists($response, 'payment')){
echo 'PAYMENT EXISTS';
} else {
echo 'PAYMENT doesnt exist';
}
but it's always returning payment doesn't exist, Am i doing something wrong to check that? Thanks!
Here's a print_r of the $response object
stdClass Object
(
[statusSuccess] => stdClass Object
(
[success] => stdClass Object
(
[_] => Operation successful.
[code] => SUCCESS
)
[report] => stdClass Object
(
[approximateTotals] => stdClass Object
(
[totalRegistered] => 1500
[totalShopperPending] => 0
[totalAcquirerPending] => 0
[totalAcquirerApproved] => 1500
[totalCaptured] => 0
[totalRefunded] => 0
[totalChargedback] => 0
[exchangedTo] => EUR
[exchangeRateDate] => 2014-04-01 13:02:30
)
[payment] => stdClass Object
(
[id] => 4906949180
[paymentMethod] => MASTERCARD
[authorization] => stdClass Object
(
[status] => AUTHORIZED
[amount] => stdClass Object
(
[_] => 1500
[currency] => EUR
)
[confidenceLevel] => ACQUIRER_APPROVED
[capture] => stdClass Object
(
[status] => NEW
[amount] => stdClass Object
(
[_] => 1500
[currency] => EUR
)
)
)
)
)
)
)
Upvotes: 1
Views: 840
Reputation: 157947
Try this:
if (
property_exists($response, 'statusSuccess')
&& property_exists($response->statusSuccess, 'report')
&& property_exists($response->statusSuccess->report, 'payment')
) {
echo 'payment method exists';
}
Upvotes: 1