I can't seem to find an answer for this online, but I think it's because I'm not too sure what to search for because I'm very new to xml and json.
If I have this xml
$postData = '<PaymentNotification Stage="false">
<MerchantReference>100004117</MerchantReference>
<TransactionType>PAYMENT</TransactionType>
<TransactionState>SUCCESSFUL</TransactionState>
<ResultCode>00</ResultCode>
<ResultMessage>Successful</ResultMessage>
<PayUReference>1167986976014</PayUReference>
<Basket>
<Description>Store Order Number:100004117</Description>
<AmountInCents>100</AmountInCents>
<CurrencyCode>ZAR</CurrencyCode>
<Products/>
</Basket>
<PaymentMethodsUsed>
<Eft BankName="ABSA" AmountInCents="100" Reference="CUMVSIUPFG" AccountNumber="4077920871" BranchNumber="632005" AccountType="Cheque" TimeLimit="168" Currency="ZAR"/>
</PaymentMethodsUsed>
<IpnExtraInfo>
<ResponseHash></ResponseHash>
</IpnExtraInfo>
</PaymentNotification>';
And then json decode it
$returnData = json_decode(json_encode(simplexml_load_string($postData)),true);
I can retrieve the objects eg.
$cost_amount = $returnData['Basket']['AmountInCents'];
But how do I get the attributes in Eft eg. BankName?
I have tried these with no success
$paid_amount = $returnData['PaymentMethodsUsed']['CreditCard']['@AmountInCents'];
and
$paid_amount = $returnData[0]->PaymentMethodsUsed[0]->CreditCard->AmountInCents;