본문으로 건너뛰기

iOS 영수증 검증

iOS 인앱결제에 따른 영수증 정보를 검증한다.

호출 정보

IAP.IOS(string receipt, string productId, string currency, double price, PlayNANOODelegate callback) {}
IAP.IOS(string receipt, string productId, string currency, double price, bool duplicateAllow, PlayNANOODelegate callback) {}

호출 상세 정보

파라미터설명타입
receipt영수증 정보string
productId결제 상품 아이디string
currency화폐 코드 (KRW, JPY, USD, CNY...).string
price결제 금액double
duplicateAllow영수증 중복 검증 허용 여부boolean
callback통신 결과PlayNANOODelegate

예제

유니티 IAP 서비스를 사용하는 경우

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();
}

// Unity IAP Service
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
plugin.IAP.IOS(args.purchasedProduct.receipt, "PRODUCT_ID", "CURRENCY", 100, (status, errorMessage, jsonString, values) => {
if (status.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(values["UserID"]);
Debug.Log(values["PackageName"]);
Debug.Log(values["OrderID"]);
Debug.Log(values["ProductID"]);
Debug.Log(values["Currency"]);
Debug.Log(values["Quantity"]);
Debug.Log(values["Price"]);
}
else
{
Debug.Log("Fail");
}
});
}
}

유니티 IAP 서비스를 사용하지 않는 경우

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();

plugin.IAP.IOS("RECEIPT", "PRODUCT_ID", "CURRENCY", 100, (status, errorMessage, jsonString, values) => {
if (status.Equals(Configure.PN_API_STATE_SUCCESS))
{
Debug.Log(values["UserID"]);
Debug.Log(values["PackageName"]);
Debug.Log(values["OrderID"]);
Debug.Log(values["ProductID"]);
Debug.Log(values["Currency"]);
Debug.Log(values["Quantity"]);
Debug.Log(values["Price"]);
}
else
{
Debug.Log("Fail");
}
});
}
}

통신 결과

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"UserID" : "String",
"PackageName" : "String",
"OrderID" : "String",
"ProductID" : "String",
"Currency" : "String",
"Price" : "String"
}

통신 결과 상세 정보

데이터키설명타입
UserID사용자 식별 아이디string
PackageName앱 패키지명string
ProductID결제 상품 아이디string
OrderID주문 아이디string
Currency결제 화폐 코드string
Quantity구매 수량integer
Price결제 상품 금액integer

에러 정보

영수증 검증에 실패한 경우 ErrorCode : 20000
ErrorMessage : ValidationFailException

어플리케이션 패키지명이 일치하지 않는 경우 ErrorCode : 20002
ErrorMessage : NotMatchPackageNameException

이미 사용된 영수증인 경우 ErrorCode : 20005
ErrorMessage : ExistsReceiptException