当我使用沙箱测试应用内购买时,对沙箱网址的发布请求https://sandbox.itunes.apple.com/verifyReceipt返回
data: { environment: 'Sandbox', status: 21003 }
21003状态码表示收据无法验证。 https://developer.apple.com/documentation/appstorereceipts/status?language=objc
这是预期的吗?我假设我的测试收据将被视为对沙盒环境有效并返回状态 0。
您报告说,当您将
appStoreReceipt
发送到 verifyReceipt
端点时,您看到的状态结果为 21003。此状态表明 appStoreReceipt
格式错误、不完整或编码错误。您能否捕获 Base64 编码的 appStoreReceipt
并将内容作为文本文件发送给我,以便我手动验证内容。如果您的应用进程销售自动续订订阅项目,请包含应用程序的共享密钥。我使用以下curl命令行工具来验证appStoreReceipts
。
对于沙盒收据:
curl -d '{ "exclude-old-transactions": true "password":"yyyy" "receipt-data": "xxxx"}' https://sandbox.itunes.apple.com/verifyReceipt
对于生产收据:
curl -d '{ "exclude-old-transactions": true "password":"yyyy" "receipt-data": "xxxx"}' https://buy.itunes.apple.com/verifyReceipt
其中
exclude-old-transactions
用于将 latest_receipt_info
的内容限制为仅最新条目,并且
“password”是请求密钥,指示内容为自动续订订阅时所需的共享秘密。
yyyy - 是共享秘密并且
xxxx - 是
appStoreReceipt
的 Base64 编码内容。
不,这不是预期的。即使应用内购买不是自动续订订阅,我也需要在密码字段中提供有效的代码。
也许有人需要我为此编写的 bash 脚本。
#!/bin/bash
clear
green='\033[0;32m'
cyan='\033[0;36m'
noColor='\033[0m' # No Color
sig=$1
mode=$2
if [ -z "$mode" ];
then
PS3="Please select a mode: "
options=("Sandbox" "Production")
select opt in "${options[@]}"
do
case $opt in
"Sandbox") break;;
"Production") break;;
*) echo -e ${red}"\ninvalid option" \"$REPLY\"${noColor};;
esac
done
else
opt=$mode
fi
if [[ "$opt" == "Production" ]]
then
echo -e ${green}"Production selected"${noColor}
commandToExecute="curl -d '{\"receipt-data\":\"$sig\"}' https://buy.itunes.apple.com/verifyReceipt"
else
echo -e ${cyan}"Sandbox selected"${noColor}
commandToExecute="curl -d '{\"receipt-data\":\"$sig\"}' https://sandbox.itunes.apple.com/verifyReceipt"
fi
eval $commandToExecute
将其称为 ./scriptNamesignatureToValidate
我也遇到了这个错误,就我而言,我使用的共享密钥是错误的。