statusUpdateNotifications - no data

Our iOS app supports auto-renewable subscriptions and we'd like to implement the handling of statusUpdateNotifications sent by the Apple servers.


So we put a URL in our app's metadata under "Subscription Status URL"


The good news is that this url *is* called by Apple, but we don't seem to be able to access any payload.


Our php script at the moment:


$jsonStr = file_get_contents('php://input');

file_put_contents( 'debugphpinput' . time() . '.log', $jsonStr);


But the files it creates when called by Apple's servers are empty.


Same if try to access $POST, no nothing...


We are aware that our server must support TLSv1.2, and this is the case, we checked that with nsurl as recommended by the documentation.


We spent quite a bit of time on this one, and ran out of ideas as to what might be wrong.


Any ideas anyone ? Thanks


Laurent Humbert


PS: We did contact DTS but they said it was a server-side problem and couldn't help.

Accepted Reply

Try just iterating through the data and saving it one variable at a time. At the end of all this, you could save it to database. Note the "latest_receipt_info" has it's own key / values to sift through. And this isn't a complete list of the data you can pull out....




$input = file_get_contents('php://input');
$data = json_decode($input);

$auto_renew_product_id = "";
$environment = "";
$unique_vendor_identifier = "";
$expires_date = 0;
$expires_date_formatted = "";
$expiration_intent = "none";
$original_purchase_date = "";
$purchase_date  = "";
$purchase_date_ms = 0;
$notification_type = "";



foreach($data as $key => $value)
{


  if ( $key == "auto_renew_product_id"){

       $auto_renew_product_id = $value;
  }
  else if ( $key == "environment"){

       $environment = $value;
  }
  else if ( $key == "notification_type"){

       $notification_type = $value;
  }
  else if ( $key == "latest_receipt_info"){

       $latest_receipt_info = $value;


  foreach($latest_receipt_info as $key => $value){


  if ( $key == "unique_vendor_identifier"){


       $unique_vendor_identifier = $value;
  }
  else if ( $key == "expires_date"){


       $expires_date = $value;
  }
  else if ( $key == "expires_date_formatted"){


       $expires_date_formatted = $value;
  }

  else if ( $key == "original_purchase_date"){


       $original_purchase_date = $value;
  }
  else if ( $key == "purchase_date"){


       $purchase_date = $value;
  }
  else if ( $key == "purchase_date_ms"){


       $purchase_date_ms = $value;
  }
  else if ( $key == "original_transaction_id"){


       $original_transaction_id = $value;
  }
  else if ( $key == "expiration_intent"){


  if ($value == 1){


       $expiration_intent = "Customer canceled their subscription";


  } else if ($value == 2){


       $expiration_intent = "Billing error";


  } else if ($value == 3){


       $expiration_intent = "Customer did not agree to a recent price increase";


  } else if ($value == 4){


       $expiration_intent = "Product was not available";


  } else if ($value == 5){


       $expiration_intent = "Unknown";


  }



  }



  }




  }






}


//do something with data

Replies

Try just iterating through the data and saving it one variable at a time. At the end of all this, you could save it to database. Note the "latest_receipt_info" has it's own key / values to sift through. And this isn't a complete list of the data you can pull out....




$input = file_get_contents('php://input');
$data = json_decode($input);

$auto_renew_product_id = "";
$environment = "";
$unique_vendor_identifier = "";
$expires_date = 0;
$expires_date_formatted = "";
$expiration_intent = "none";
$original_purchase_date = "";
$purchase_date  = "";
$purchase_date_ms = 0;
$notification_type = "";



foreach($data as $key => $value)
{


  if ( $key == "auto_renew_product_id"){

       $auto_renew_product_id = $value;
  }
  else if ( $key == "environment"){

       $environment = $value;
  }
  else if ( $key == "notification_type"){

       $notification_type = $value;
  }
  else if ( $key == "latest_receipt_info"){

       $latest_receipt_info = $value;


  foreach($latest_receipt_info as $key => $value){


  if ( $key == "unique_vendor_identifier"){


       $unique_vendor_identifier = $value;
  }
  else if ( $key == "expires_date"){


       $expires_date = $value;
  }
  else if ( $key == "expires_date_formatted"){


       $expires_date_formatted = $value;
  }

  else if ( $key == "original_purchase_date"){


       $original_purchase_date = $value;
  }
  else if ( $key == "purchase_date"){


       $purchase_date = $value;
  }
  else if ( $key == "purchase_date_ms"){


       $purchase_date_ms = $value;
  }
  else if ( $key == "original_transaction_id"){


       $original_transaction_id = $value;
  }
  else if ( $key == "expiration_intent"){


  if ($value == 1){


       $expiration_intent = "Customer canceled their subscription";


  } else if ($value == 2){


       $expiration_intent = "Billing error";


  } else if ($value == 3){


       $expiration_intent = "Customer did not agree to a recent price increase";


  } else if ($value == 4){


       $expiration_intent = "Product was not available";


  } else if ($value == 5){


       $expiration_intent = "Unknown";


  }



  }



  }




  }






}


//do something with data

Thanks very much, it works. I would try to access the request data via $POST but file_get_contents('php://input') was the way to go.