I'm using recurly webhooks to update contacts, but the XML is always empty, here's what I've tried:
$xmlString = file_get_contents('php://input');
$dom = new DomDocument();
$dom->loadXML($xmlString);
however when I look into the file, it is always empty:
$rsn = $dom->getElementsByTagName('successful_payment_notification');
if($rsn->length != 0){
//.. do something
}
but I've noticed that the $dom is always empty, here's what the XML recurly sends:
<?xml version="1.0" encoding="UTF-8"?>
<successful_payment_notification>
<account>
<account_code>89728427a3caa0b21b2ds31223c0fad6f443b82</account_code>
<first_name>Michael</first_name>
<last_name>Scott</last_name>
<company_name nil="true"></company_name>
<phone nil="true"></phone>
</account>
<transaction>
<id>467fc116288ab89c8d7c954bbca565a8</id>
<invoice_id>467fc11613dcd438d4410c4ca0bc03e8</invoice_id>
<invoice_number_prefix></invoice_number_prefix>
<invoice_number type="integer">1379</invoice_number>
<test type="boolean">false</test>
<voidable type="boolean">false</voidable>
<refundable type="boolean">true</refundable>
</transaction>
</successful_payment_notification>
allow_url_fopen is On, not sure what could be causing this, I'm using AWS Lightsail and Bitnami.
I've found the answer, I changed it to this:
$xml = new SimpleXMLElement(file_get_contents('php://input'));
$data = json_decode(json_encode($xml), true);
switch ($xml->getName()) {
case "renewed_subscription_notification":
sendEmail("renewed_subscription_notification");
break;
}