开发者

Is there anyway to check if an Apple Inapp purchase product identifier is valid from the content server?

I am creating the backend for an iOSapp that has inapp purchase products in them. The backend does the content serving stuff and validations of receipts and what not.

What bothers me is that there is no way to be sure that the product identifier entered in the backend is a valid one.

I know there is an API that can be开发者_Go百科 called from the iOS to get a list of product identifiers for a specific app(was it company?), is there anyway to obtain this information from the backend so true validation of the entered identifier can be done?

Thanks in advance.


Once a user makes a valid purchase, you receive an encoded purchase receipt. To check if the purchase is valid, you need to send this receipt to Apple's validation servers. You'll receive a response indicating if the purchase was valid, and if it's valid - details about the purchase (purchase time, product ID, transaction ID, etc...).

I used the example code here and it was pretty easy and straight forward. Use the sandbox url as an endpoint while testing (including with TestFlight), and the production URL once the app is in the app store.

BTW, I would recommend generating a shared secret for your IAP (you can do it in iTunes Connect), and including it in your validation requests under a field called password:

private function encodeRequest() {
    return json_encode(array(
    'receipt-data' => $this->getReceipt(),
    'password' => $sharedSecret));
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜