目录

Payment

Restrictions

Applicable Device

Mobile phones and tablets

Applicable Region

Global

Definition

API

Description

HwFastappObject.isEnvReady(Object object)

Checks whether the country/region to which the current HUAWEI ID belongs supports Huawei IAP.

HwFastappObject.onIsEnvReadyResult(Object object)

Obtains the result indicating whether Huawei IAP is supported.

HwFastappObject.isSandboxActivated(Object object)

Checks whether the current HUAWEI ID and the quick game RPK version meet the sandbox testing requirements.

HwFastappObject.onIsSandboxActivatedResult(Object object)

Obtains the result indicating whether the sandbox testing requirements are met.

HwFastappObject.obtainOwnedPurchases(Object object)

Queries the details of a user's purchased products, including consumables and non-consumables.

HwFastappObject.onObtainOwnedPurchasesResult(Object object)

Obtains the details of a user's purchased products.

HwFastappObject.obtainProductInfo(Object object)

Queries the details of a product configured in AppGallery Connect.

HwFastappObject.onObtainProductInfoResult(Object object)

Obtains the details of a product configured in AppGallery Connect.

HwFastappObject.createPurchaseIntent(Object object)

Creates orders for purchasing products (consumables and non-consumables) configured in AppGallery Connect.

HwFastappObject.onCreatePurchaseIntentResult(Object object)

Obtains the order details of a purchased product.

HwFastappObject.consumeOwnedPurchase(Object object)

Consumes a consumable that has been successfully purchased.

HwFastappObject.onConsumeOwnedPurchaseResult(Object object)

Obtains the result of consuming a consumable.

[h2]HwFastappObject.isEnvReady(Object object)

[h2]HwFastappObject.onIsEnvReadyResult(Object object)

[h2]HwFastappObject.isSandboxActivated(Object object)

[h2]HwFastappObject.onIsSandboxActivatedResult(Object object)

[h2]HwFastappObject.obtainOwnedPurchases(Object object)

[h2]HwFastappObject.onObtainOwnedPurchasesResult(Object object)

[h2]HwFastappObject.obtainProductInfo(Object object)

[h2]HwFastappObject.onObtainProductInfoResult(Object object)

[h2]HwFastappObject.createPurchaseIntent(Object object)

[h2]HwFastappObject.onCreatePurchaseIntentResult(Object object)

[h2]HwFastappObject.consumeOwnedPurchase(Object object)

[h2]HwFastappObject.onConsumeOwnedPurchaseResult(Object object)

Sample Code

[h2]Purchasing Consumables

<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title id="title">Consumables</title>
	<script type="text/javascript">
		var success = -1;
		var inAppPurchaseData = ""
		var purchaseState = ""

		function callandroid() {
			console.log("GX showFloatWindow ");
			var params = { "appid": "100798021" }
			HwFastappObject.showFloatWindow(JSON.stringify(params));
		}
		function callandroid1() {
			console.log("GX hideFloatWindow ");
			var params = { "appid": "100798021" }
			HwFastappObject.hideFloatWindow(JSON.stringify(params));
		}
		function GamesignIn() {
			var params = { "appid": "100798021", "forceLogin": 1 }
			HwFastappObject.gameLogin(JSON.stringify(params));
		}

		HwFastappObject.onGameLoginResult = function onGameLoginResult(str) {
			if (str.code == 0) {
				success = 0;
				console.log("GX game login success" + JSON.stringify(str))
			}
			var text = document.getElementById("text");
			//text.innerHTML = JSON.stringify(str);
			//text.innerHTML = JSON.stringify(str);

			//alert("onGameLoginResult"+JSON.stringify(str))
		}
		function isEnvReady() {
			var params = { isEnvReadyReq: { "applicationID": "100798021" } }
			HwFastappObject.isEnvReady(JSON.stringify(params));
		}

		HwFastappObject.onIsEnvReadyResult = function onIsEnvReadyResult(str) {

			//var text = document.getElementById("text");
			//text.innerHTML = JSON.stringify(str);
			//text.innerHTML = str;
			console.log("GX", "onIsEnvReadyResult =" + JSON.stringify(str));
			//alert("onIsEnvReadyResult:"+JSON.stringify(str));

		}





		function isSandboxActivated() {
			var params = { isSandboxActivatedReq: { "applicationID": "100798021", } }
			HwFastappObject.isSandboxActivated(JSON.stringify(params));
		}

		HwFastappObject.onIsSandboxActivatedResult = function onIsSandboxActivatedResult(str) {
			//alert("onIsSandboxActivatedResult:"+JSON.stringify(str));
			//var text = document.getElementById("text");
			//text.innerHTML = JSON.stringify(str);
			//text.innerHTML = JSON.stringify(str);
			console.log("GX", "onIsSandboxActivatedResult =" + JSON.stringify(str));
		}
		//
		function obtainOwnedPurchases() {
			var priceType = document.getElementById("priceType")
			var params = {
				ownedPurchasesReq: {
					"priceType": 0, "applicationID": "100798021",
					"publicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="
				}
			}
			HwFastappObject.obtainOwnedPurchases(JSON.stringify(params));
		}
		HwFastappObject.onObtainOwnedPurchasesResult = function onObtainOwnedPurchasesResult(str) {
			//alert("onObtainOwnedPurchasesResult:"+JSON.stringify(str));
			console.log(JSON.stringify(str))
			//The purchaseState field needs to be parsed from the string of InAppPurchaseData, 
			//and when purchaseState is 0, the transaction is successful
			var appData = JSON.parse(str.data)
			inAppPurchaseData = appData.inAppPurchaseDataList   //array	
			let purseDataSignArray = appData.inAppSignature;
			let publicKey = "XXX"
			if (inAppPurchaseData) {
				for (j = 0, len = inAppPurchaseData.length; j < len; j++) {
					var purchaseState = JSON.parse(inAppPurchaseData[j]).purchaseState
					//console.log(purchaseState)
					//Verify the signature of product details before the delivery.
					//You can send a verification request to the Huawei IAP server to further verify the order.	
					doCheckSign(purchaseState, inAppPurchaseData[j], purseDataSignArray[j], publicKey);
				}
			}
		}
		function doCheckSign(purchaseState, inAppPurchaseData, inAppSignature, publicKey) {
			//	to do your quick game's server,Set this result to true for convenience here
			let result = true;

			if (result) {
				doCheckPurchaseState(purchaseState);
			}
		}
		function doCheckPurchaseState(purchaseState) {
			//pay success
			if (purchaseState === 0) {

				console.log("Consumeables have been successfully paid without having to purchase them again.")
				consumeOwnedPurchase();
				return
			}
			//pay fail
			if (purchaseState === 1 || purchaseState === 2) {
				console.log("The transaction has been cancelled or refunded")
				return
			}
		}

		function obtainProductInfo() {
			var priceType = document.getElementById("priceType")
			var productId = document.getElementById("productId")

			var params = { productInfoReq: { "priceType": 0, "productIds": "Product1", "applicationID": "100798021", } }
			HwFastappObject.obtainProductInfo(JSON.stringify(params));
		}

		HwFastappObject.onObtainProductInfoResult = function onObtainProductInfoResult(str) {
			//alert("onObtainProductInfoResult:"+JSON.stringify(str));
			//var text = document.getElementById("text");
			//text.innerHTML = JSON.stringify(str);
			//text.innerHTML = str;
			console.log("GX", "onObtainProductInfoResult =" + JSON.stringify(str));
		}
		function createPurchaseIntent() {
			var params = {
				purchaseIntentReq: {
					"applicationID": "100798021", "productId": "Product1", "priceType": 0, "developerPayload": "testPurchase",
					"publicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="
				}
			}
			HwFastappObject.createPurchaseIntent(JSON.stringify(params));
		}
		function createPurchaseIntent1() {
			var params = {
				purchaseIntentReq: {
					"applicationID": "100798021", "productId": "Product4", "priceType": 0, "developerPayload": "testPurchase",
					"publicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="
				}
			}
			HwFastappObject.createPurchaseIntent(JSON.stringify(params));
		}
		HwFastappObject.onCreatePurchaseIntentResult = function onCreatePurchaseIntentResult(str) {
			// var text = document.getElementById("text");
			// text.innerHTML = JSON.stringify(str);			
			console.log("GX", "onCreatePurchaseIntentResult =" + JSON.stringify(str));

			if (str.code === 0) {
				console.log("GX pay success")

				obtainOwnedPurchases();
			}

			if (str.code === 60051 || str.code === -1) {

				obtainOwnedPurchases();
			}
		}

		function consumeOwnedPurchase() {

			console.log(inAppPurchaseData)
			if (inAppPurchaseData) {
				for (j = 0, len = inAppPurchaseData.length; j < len; j++) {
					var purchaseToken = JSON.parse(inAppPurchaseData[j]).purchaseToken
					var params = {
						consumeOwnedPurchaseReq: {
							"applicationID": "100798021", "developerPayload": "testPurchase", "purchaseToken": purchaseToken,
							"publicKey": "MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="
						}
					}
					HwFastappObject.consumeOwnedPurchase(JSON.stringify(params));
				}
			}

		}
		HwFastappObject.onConsumeOwnedPurchaseResult = function onConsumeOwnedPurchaseResult(str) {

			console.log("GX", "onConsumeOwnedPurchaseResult =" + JSON.stringify(str));
			if (str.code === 0) {
				console.log("Consume success")
				return
			}
			if (str.code === 60053) {
				console.log("Goods have been consumed and cannot be consumed again")
			} else {
				console.log("Consume fail")
			}
		}
		function formateTime(time) {
			if (time) {
				let unixTimestamp = new Date(time);
				return unixTimestamp.toLocaleString();
			}
		}
		function Back() {
			window.location.href = "index.html";
		}

	</script>
</head>

<body>
	<p>Consumables</p>
	<style>
		#text {
			border: 1px solid #00F;
			width: 200px;
			word-wrap: break-word
		}

		input {
			font-size: 40px;
			width: 800px;
			height: 60px;
			text-align: center;
			background: #5255fc;
			color: #FFF;
			line-height: 60px;
			margin-left: auto;
			margin-right: auto
		}

		p {
			font-size: 80px;
			width: 1080px;
			height: 100px;
			text-align: center
		}

		.container {
			text-align: center;
			margin-left: auto;
		}
	</style>
	<div class="container">

		<input type="button" id="button3" value="Buy Some" onclick="createPurchaseIntent()" /></br></br>
		<input type="button" id="button3" value="Buy More" onclick="createPurchaseIntent1()" /></br></br>

		
		<input type="button" value="Back" onclick="Back()" /> </br></br>
	</div>
	<li id="li" style="list-style-type:none"></li>


	</div>
</body>

</html>

[h2]Purchasing Non-Consumables

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title id="title">NonConsumables</title>
    <script type="text/javascript">
        var success = -1;
		var inAppPurchaseData = ""
		var purchaseState= ""

			function callandroid(){
                console.log("GX showFloatWindow ");
                var params = {"appid":"100798021"}
				HwFastappObject.showFloatWindow(JSON.stringify(params));
	}
            function callandroid1(){
                console.log("GX hideFloatWindow ");
				var params = {"appid":"100798021"}
                HwFastappObject.hideFloatWindow(JSON.stringify(params));
            }
            function GamesignIn(){
		    var params = {"appid":"100798021","forceLogin":1}
	        HwFastappObject.gameLogin(JSON.stringify(params));
	        }

	        HwFastappObject.onGameLoginResult = function onGameLoginResult(str){
		        if (str.code == 0) {
		             success = 0;
		             console.log("GX game login success"+JSON.stringify(str))
				}
				var text = document.getElementById("text");
				//text.innerHTML = JSON.stringify(str);
				//text.innerHTML = JSON.stringify(str);
			
				//alert("onGameLoginResult"+JSON.stringify(str))
	        }
			function isEnvReady (){
			    var params = {isEnvReadyReq: {"applicationID": "100798021"}}
				HwFastappObject.isEnvReady(JSON.stringify(params));
	        }

	        HwFastappObject.onIsEnvReadyResult  = function onIsEnvReadyResult (str){
			
				//var text = document.getElementById("text");
				//text.innerHTML = JSON.stringify(str);
				//text.innerHTML = str;
				console.log("GX","onIsEnvReadyResult ="+JSON.stringify(str));
				//alert("onIsEnvReadyResult:"+JSON.stringify(str));
		
	        }
			
			
			function isSandboxActivated (){
			    var params = {isSandboxActivatedReq: {"applicationID": "100798021",}}
				HwFastappObject.isSandboxActivated(JSON.stringify(params));
	        }

	        HwFastappObject.onIsSandboxActivatedResult  = function onIsSandboxActivatedResult (str){
			    //alert("onIsSandboxActivatedResult:"+JSON.stringify(str));
				//var text = document.getElementById("text");
				//text.innerHTML = JSON.stringify(str);
				//text.innerHTML = JSON.stringify(str);
			    console.log("GX","onIsSandboxActivatedResult ="+JSON.stringify(str));
	        }
			//
			function obtainOwnedPurchases (){
			var priceType = document.getElementById("priceType")
			    var params = { ownedPurchasesReq: {"priceType": 1,"applicationID": "100798021",
				"publicKey":"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="}}
				HwFastappObject.obtainOwnedPurchases(JSON.stringify(params));
	        }
	        HwFastappObject.onObtainOwnedPurchasesResult  = function onObtainOwnedPurchasesResult (str){
				//alert("onObtainOwnedPurchasesResult:"+JSON.stringify(str));
				console.log(JSON.stringify(str))
				// Parse the purchaseState field from the InAppPurchaseData string. If the value of purchaseState is 0, the transaction is successful.
				var appData  = JSON.parse(str.data)				
				inAppPurchaseData = appData.inAppPurchaseDataList   //array	
				let purseDataSignArray = appData.inAppSignature;    
				let publicKey="XXX"		
				
				//text.innerHTML = str1;
				console.log("GX","onObtainOwnedPurchasesResult =inAppPurchaseDataList"+JSON.stringify(inAppPurchaseData));
				var strdata=""
				if(inAppPurchaseData){
					for(j = 0,len=inAppPurchaseData.length; j < len; j++) {
					var purchaseState=JSON.parse(inAppPurchaseData[j]).purchaseState
					doCheckSign(inAppPurchaseData[j], purseDataSignArray[j], publicKey);
					doCheckPurchaseState(purchaseState);
					console.log("OrderId"+JSON.parse(inAppPurchaseData[j]).orderId)
					console.log("PurchaseTime"+formateTime(JSON.parse(inAppPurchaseData[j]).purchaseTime))
				
					console.log("ProductId"+JSON.parse(inAppPurchaseData[j]).productId)
					console.log("ProductName"+JSON.parse(inAppPurchaseData[j]).productName)
					console.log("Price"+JSON.parse(inAppPurchaseData[j]).price/100)
					console.log("PurchaseState"+JSON.parse(inAppPurchaseData[j]).purchaseState)
					if(purchaseState===0){
						console.log("Purchased")
					}else{
						console.log("Purchase Failure")
						}
					var a = JSON.parse(inAppPurchaseData[j]).orderId;
					var b = formateTime(JSON.parse(inAppPurchaseData[j]).purchaseTime);
					var c = JSON.parse(inAppPurchaseData[j]).productId;
					var d = JSON.parse(inAppPurchaseData[j]).productName;
					var e = JSON.parse(inAppPurchaseData[j]).price/100;
					var f= JSON.parse(inAppPurchaseData[j]).purchaseState;
					var g
					if(f===0){
						g="Purchased"
					}else{
						g="Purchase Failure"
						}
					strdata+='<li style="font-size:40px;text-align:left;background:#5255fc;color: #FFFFFF;line-height:60px;margin-left:auto; margin-right:auto">'+"Order ID: "+a+'</br>'+"Purchase time: "+b+'</br>'+"Product ID: "+c+'</br>'+"Product name:"+d+'</br>'+"Product price: "+e+"RMB"+'</br>'+"Purchase status: "+g+'</br>'+'</li>'+'</br>'+'</br>'+'</br>'
					
					}		
				
				}
				document.getElementById('li').innerHTML = strdata										
			}
			function doCheckPurchaseState(purchaseState){			
				//alert(purchaseState)
				
				if(purchaseState===0){
					
						console.log("Subscription goods have been successfully paid without having to purchase them again.")
						//consumeOwnedPurchase();
						return
					}
				if(purchaseState===1||purchaseState===2){
						console.log("The transaction has been cancelled or refunded")
						return
					}
			}
			
			function  doCheckSign(inAppPurchaseData, inAppSignature, publicKey) { 
							
			}
			
			function obtainProductInfo (){
			var priceType = document.getElementById("priceType")
			var productId = document.getElementById("productId")
		
			    var params = { productInfoReq: {"priceType": 1,"productIds": "Product2","applicationID": "100798021",}}
				HwFastappObject.obtainProductInfo(JSON.stringify(params));
	        }

	        HwFastappObject.onObtainProductInfoResult  = function onObtainProductInfoResult (str){
			    //alert("onObtainProductInfoResult:"+JSON.stringify(str));
				//var text = document.getElementById("text");
				//text.innerHTML = JSON.stringify(str);
				//text.innerHTML = str;
			    console.log("GX","onObtainProductInfoResult ="+JSON.stringify(str));
	        }
			function createPurchaseIntent (){		
			    var params = { purchaseIntentReq: {"applicationID": "100798021","productId": "Product2","priceType": 1,"developerPayload": "testPurchase1",
				"publicKey":"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="}}
				HwFastappObject.createPurchaseIntent(JSON.stringify(params));
			}
			function createPurchaseIntent1 (){		
			    var params = { purchaseIntentReq: {"applicationID": "100798021","productId": "Product5","priceType": 1,"developerPayload": "testPurchase1",
				"publicKey":"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="}}
				HwFastappObject.createPurchaseIntent(JSON.stringify(params));
	        }
	        HwFastappObject.onCreatePurchaseIntentResult  = function onCreatePurchaseIntentResult (str){
				// var text = document.getElementById("text");
				// text.innerHTML = JSON.stringify(str);			
				console.log("GX","onCreatePurchaseIntentResult ="+JSON.stringify(str));
				
				if (str.code ===0){
					console.log("Pay success")
					
					
				}
			
				if(str.code===60051||str.code===-1){
					alert("You have purchased it and can use it permanently. You do not need to purchase it again.")
					
					
														
				}				
			}
			
			function consumeOwnedPurchase (){
				
				
				//alert("purchaseToken"+JSON.parse(inAppPurchaseData).purchaseToken)			
				var purchaseToken=JSON.parse(inAppPurchaseData).purchaseToken		
			    var params = { consumeOwnedPurchaseReq: {"applicationID": "100798021","developerPayload":"testPurchase","purchaseToken":purchaseToken,
		"publicKey":"MIIBojANBgkqhkiG9w0BAQEFAAOCAY8AMIIBigKCAYEAkDhrGKHUDGDqGfKTcfHmpiPdPuZocwF7tl0UAuBsHSqdStm8OQX5bYkxrpTqF64gLn8dON60WRjAqbz1t/vO0jbvLWX/n3rvONIfbk4J4skgXBVPoe69XXgaOzT02/wnAE6aINgMz4ez9PZ3ValbtIAdvJ9qS2fb18B+OEw8kfWt5H4vWbBCdTIj0OlkAA4BsTNo6jY7gVfacCDD2y+MbPagFcR7pspQW53pBZCQ+cov1bQFEnf1ay5SFN7PRCruf8Wuqd6PJci4Zsz5YzRWi7eWn+M+uRyg+8NjiBPKL1xhK1yUtu+vg9W0jy4GdX4fzyVxAa31utMNpqL9M/tiVlnegY70GW46U6d1+c0aIuq5kSfN6smhgDx+UxDeCgAxF6mgIneSb5q9gQf0feFqcMx1nNAL1JkXSt51+f8C2OjRioOmyR566ahQvZLjGRY7F2F1XACAIhg/WPqNBMtrzHh3mOvNHOgz9MQBB4wbZQWveHY0ePClRherT7LYuiA7AgMBAAE="}}
				HwFastappObject.consumeOwnedPurchase(JSON.stringify(params));
	        }
	        HwFastappObject.onConsumeOwnedPurchaseResult  = function onConsumeOwnedPurchaseResult (str){
			    // alert("onConsumeOwnedPurchaseResult :"+JSON.stringify(str));
				// var text = document.getElementById("text");
				// text.innerHTML = JSON.stringify(str);
				console.log("GX","onConsumeOwnedPurchaseResult ="+JSON.stringify(str));
				if(str.code ===0){
					console.log("Consume success")
					return
				}
				if(str.code ===60053){
					console.log("Goods have been consumed and cannot be consumed again")				
				}
			}
			function formateTime(time) {
			if (time) {
			let unixTimestamp = new Date(time);
			return unixTimestamp.toLocaleString();
			}
		}
			function Back(){
				window.location.href="index.html";
			}
	
    </script>
</head>
<body>
<p>NonConsumables</p>
<style>
#text{ border:1px solid #00F; width:200px;word-wrap:break-word} 
input {font-size:40px;width:800px;height:60px;text-align:center;background:#5255fc;color: #FFF;line-height:60px;margin-left:auto; margin-right:auto}
p{font-size:80px;width:1080px;height:100px;text-align:center}
.container{text-align:center;margin-left: auto;}

</style>
<div class="container">
       <input type="button" id="button3" value="Permanent VIP Purchase"  onclick="createPurchaseIntent()"/></br></br>
       <input type="button" id="button3" value="Permanent Skin Purchase"  onclick="createPurchaseIntent1()"/></br></br>
       <input type="button" id="button3" value="PurchaseRecord"  onclick="obtainOwnedPurchases()"/></br></br>
       <input type="button" value="Back"  onclick="Back()" /> </br></br>
</div>
<li id="li" style="list-style-type:none"></li>
<!-- <div type="text" id="text" style="font-size:40px;width:1080px;height:1660px">test</div> -->
</div>
</body>
</html>

Result Codes

For more result codes, please refer to Result Codes.

Result Code

Description

200

Common error.

202

The input parameter is incorrect.

1002

Failed to authenticate the app.

1001

Failed to verify the public key.