var productId = 'test_product_id';
swingWebViewPlugin.app.inapp.buy(productId,
function(responseCode,data) {
console.log('responseCode : ' + responseCode + ', ret : ' + JSON.stringify(data));
if( responseCode == 1 ) // 성공
{
console.log('originalData : ' + data );
// 값 예시
// responseCode : 1, ret : "{\"transaction\":{\"transactionIdentifier\":\"2000000524327453\"},\"productId\":\"swbwregsubweek\",\"needsFinishTransaction\":false,\"originalTransaction\":{\"transactionIdentifier\":null},\"receipt\":\"=test=\",\"quantity\":1}"
data = JSON.parse(data);
var receipt = data.receipt;
var productId = data.productId;
var transactionIdentifier = data.transaction.transactionIdentifier;
// ajax 호출을 통해 서버에 transaction 정보를 확인해보세요.
// 유효한 구독 상품인지 확인을 위해 아래의 함수를 호출합니다.
// 구독 상태 정보 backend 구현은 아래의 API 를 참고하시면 됩니다.
// https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
console.log('receipt : ' + receipt );
console.log('transactionId : ' + transactionIdentifier );
console.log('productId : ' + productId );
}
else // 기타 에러
{
console.log('error code : ' + responseCode );
}
})
var productId = 'test_product_id';
swingWebViewPlugin.app.inapp.subscribe(productId,
function(responseCode,data) {
console.log('responseCode : ' + responseCode + ', ret : ' + JSON.stringify(data));
if( responseCode == 1 ) // 성공
{
console.log('originalData : ' + data );
// 값 예시
// responseCode : 1, ret : "{\"transaction\":{\"transactionIdentifier\":\"2000000524327453\"},\"productId\":\"swbwregsubweek\",\"needsFinishTransaction\":false,\"originalTransaction\":{\"transactionIdentifier\":null},\"receipt\":\"=test=\",\"quantity\":1}"
data = JSON.parse(data);
var receipt = data.receipt;
var productId = data.productId;
var transactionIdentifier = data.transaction.transactionIdentifier;
console.log('receipt : ' + receipt );
console.log('transactionId : ' + transactionIdentifier );
console.log('productId : ' + productId );
// ajax 호출을 통해 서버에 transaction 정보를 확인해보세요.
// 유효한 구독 상품인지 확인을 위해 아래의 함수를 호출합니다.
// 구독 상태 정보 backend 구현은 아래의 API 를 참고하시면 됩니다.
// https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses
}
else // 기타 에러
{
var errorCode = responseCode;
var errorMsg = data;
console.log('error msg : ' + errorMsg );
// errorCode list
// Unknown error. Please contact support = 0;
// Not allowed to make the payment = 1 or 3;
// The device is not allowed to make the payment = 4;
// The product is not available in the current storefront = 5;
// Access to cloud service information is not allowed = 6;
// Could not connect to the network = 7;
// User has revoked permission to use this cloud service = 8;
}
})