PurchaseVerificationRequest_TestTool_v2.html 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <html>
  2. <head>
  3. <!-- jquery is included for form reset to work in Firefox -->
  4. <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
  5. </head>
  6. <body>
  7. <h1>Purchase Ticket Verification Test Tool</h2>
  8. <hr/>
  9. <h3>
  10. Click Here To Reset Forms after Payment Request Verification Submission
  11. </h3>
  12. <form id="form">
  13. <p>
  14. <input type="submit" value="Reset" />
  15. </p>
  16. </form>
  17. <hr/>
  18. <!---
  19. Right after the form HTML has been rendered, set a timeout
  20. for the form reset. A slight timeout is needed for this
  21. code to work in Internet Explorer.
  22. --->
  23. <script type="text/javascript">
  24. setTimeout(function(){document.getElementById( "form" ).reset();},5);
  25. </script>
  26. <h3>Request Purchase Ticket Verification</h3>
  27. Payment Verification Request URL: <input size="150" type="text" name="purchaseUrl" id="purchaseUrl"/>
  28. <br>
  29. Transaction ID: <input size="150" type="text" name="transactionId" id="transactionId"/>
  30. <br>
  31. Transaction Time: <input size="150" type="text" name="transactionTime" id="transactionTime"/>
  32. <br>
  33. Product Id: <input size="150" type="text" name="productId" id="productId"/>
  34. <br>
  35. Application Id: <input size="150" type="text" name="applicationId" id="applicationId"/>
  36. <br>
  37. Account Id: <input size="150" type="text" name="accountId" id="accountId"/>
  38. <br>
  39. imei: <input size="150" type="text" name="imei" id="imei"/>
  40. <br>
  41. imsi: <input size="150" type="text" name="imsi" id="imsi"/>
  42. <br>
  43. Signature: <input size="150" type="text" name="signature" id="signature"/>
  44. <br>
  45. <br/>
  46. <button type="button" onclick="getPurchaseTicketVerification()">Request Payment Ticket Verification</button>
  47. Payment Request URL (auto-generated): <br/><textarea rows="3" cols="100" name="xmlResponse" id="xmlResponse" readonly=true> </textarea>
  48. <br/>
  49. Payment Response Body (auto-generated):<br/>
  50. <form name="authForm" id="authForm" method="post" target="ifr" action=""> </form>
  51. <iframe name="ifr" id="ifr" width="700" height="100"> </iframe>
  52. <hr/>
  53. <h3>Request Binary Purchase Ticket Verification</h3>
  54. Binary Payment Verification Request URL: <input size="150" type="text" name="binaryPurchaseUrl" id="binaryPurchaseUrl"/>
  55. <br>
  56. Binary Purchase Ticket: <input size="150" type="text" name="binaryPurchaseTicketId" id="binaryPurchaseTicketId"/>
  57. <br>
  58. <br/>
  59. <button type="button" onclick="getBinaryPurchaseTicketVerification()">Request Binary Payment Ticket Verification</button>
  60. Payment Request URL (auto-generated): <br/><textarea rows="3" cols="50" name="xmlResponseBinary" id="xmlResponseBinary" readonly=true> </textarea>
  61. <br/>
  62. Payment Response Body (auto-generated):<br/>
  63. <form name="authForm2" id="authForm2" method="post" target="ifr2" action=""> </form>
  64. <iframe name="ifr2" id="ifr2" width="700" height="100"> </iframe>
  65. <hr/>
  66. <script type="text/javascript">
  67. function initEnv(){
  68. var serverURL_prefix = "https://payment.ovi.com";
  69. document.getElementById("purchaseUrl").value = serverURL_prefix + '/iap/1.0/purchases/verify?method=GET';
  70. document.getElementById("transactionId").value = '';
  71. document.getElementById("transactionTime").value = '';
  72. document.getElementById("productId").value = '';
  73. document.getElementById("applicationId").value = '';
  74. document.getElementById("accountId").value = '';
  75. document.getElementById("imei").value = '';
  76. document.getElementById("imsi").value = '';
  77. document.getElementById("signature").value = '';
  78. document.getElementById("binaryPurchaseUrl").value = serverURL_prefix + '/iap/1.0/purchases/verify?method=GET';
  79. document.getElementById("binaryPurchaseTicketId").value = '';
  80. }
  81. initEnv();
  82. function getPurchaseTicketVerification() {
  83. var serverUrl = document.getElementById('purchaseUrl').value;
  84. var transactionId = document.getElementById('transactionId').value;
  85. var transactionTime = document.getElementById('transactionTime').value;
  86. var productId = document.getElementById('productId').value;
  87. var applicationId = document.getElementById('applicationId').value;
  88. var accountId = document.getElementById('accountId').value;
  89. var imei = document.getElementById('imei').value;
  90. var imsi = document.getElementById('imsi').value;
  91. var signature = document.getElementById('signature').value;
  92. var theTicket = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'
  93. +'<PurchaseVerificationRequest xmlns="http://payment.ovi.com/iap">'
  94. +'<PurchaseTicket transactionId="'
  95. +transactionId
  96. +'" transactionTime="'
  97. +transactionTime
  98. +'" productId="'
  99. +productId
  100. +'" applicationId="'
  101. +applicationId
  102. +'" accountId="'
  103. +accountId
  104. +'" imei="'
  105. +imei
  106. +'" imsi="'
  107. +imsi
  108. +'" signature="'
  109. +signature
  110. +'"/></PurchaseVerificationRequest>';
  111. post_to_url_Form1(serverUrl, {'content' : theTicket} );
  112. document.getElementById('xmlResponse').value = serverUrl;
  113. }
  114. function getBinaryPurchaseTicketVerification() {
  115. var serverUrl = document.getElementById('binaryPurchaseUrl').value;
  116. var binaryPurchaseTicketId = document.getElementById('binaryPurchaseTicketId').value;
  117. var theTicket = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><PurchaseVerificationRequest xmlns="http://payment.ovi.com/iap"><Binary>'
  118. + binaryPurchaseTicketId
  119. + '</Binary></PurchaseVerificationRequest>';
  120. post_to_url_Form2(serverUrl, {'content' : theTicket} );
  121. document.getElementById('xmlResponseBinary').value = serverUrl;
  122. }
  123. function post_to_url_Form1(path, params, method) {
  124. method = method || "post"; // Set method to post by default, if not specified.
  125. var form = document.authForm;
  126. form.setAttribute("method", method);
  127. form.setAttribute("action", path);
  128. for(var key in params) {
  129. var hiddenField = document.createElement("input");
  130. hiddenField.setAttribute("type", "hidden");
  131. hiddenField.setAttribute("name", key);
  132. hiddenField.setAttribute("value", params[key]);
  133. form.appendChild(hiddenField);
  134. }
  135. document.body.appendChild(form);
  136. form.submit();
  137. }
  138. function post_to_url_Form2(path, params, method) {
  139. method = method || "post"; // Set method to post by default, if not specified.
  140. var form = document.authForm2;
  141. form.setAttribute("method", method);
  142. form.setAttribute("action", path);
  143. for(var key in params) {
  144. var hiddenField = document.createElement("input");
  145. hiddenField.setAttribute("type", "hidden");
  146. hiddenField.setAttribute("name", key);
  147. hiddenField.setAttribute("value", params[key]);
  148. form.appendChild(hiddenField);
  149. }
  150. document.body.appendChild(form);
  151. form.submit();
  152. }
  153. function getNonce(length)
  154. {
  155. var nonceChars = "0123456789abcdefghijklmnopqrstuvwxyz";
  156. var nonce = "";
  157. for (var i = 0; i < length; i++)
  158. {
  159. nonce += nonceChars.charAt(Math.floor(Math.random() * nonceChars.length));
  160. }
  161. return nonce;}
  162. function getTimestamp() {
  163. return '' + Math.floor(new Date().getTime() / 1000);
  164. }
  165. </script>
  166. </body>
  167. </html>