使用XMLHTTP 组件连接到 Swish API 服务器。构建适当的 JSON 请求并将响应流式传输到客户端。
此示例使用 JScript 作为脚本语言。
<%@ codepage=65001 language="jscript" %>
<%
var payee = Request.QueryString('payee');
var amount = Request.QueryString('amount');
var message = Request.QueryString('message');
var format = 'png'; // Can also be 'jpg' or 'svg'
var size = 400; // Between 300 and 2000
var border = 2; // Between 0 and 4 (measured in blocks, not pixels)
var transparent = 'true'; // Must be 'false' for 'jpg'
var json = '{'
+ '"payee":{"value":"' + payee + '","editable":false},'
+ '"amount":{"value":' + amount + ',"editable":false},'
+ '"message":{"value":"' + message + '","editable":false},'
+ '"format":"' + format + '",'
+ '"size":' + size + ','
+ '"border":' + border + ','
+ '"transparent":' + transparent
+ '}';
var http = new ActiveXObject('MSXML2.Serverhttp');
http.open('POST', 'https://mpc.getswish.net/qrg-swish/api/v1/prefilled', false);
http.setRequestHeader('content-type', 'application/json');
http.send(json);
if (http.status != 200) {
Response.ContentType = 'text/plain';
Response.Write('HTTP ' + http.status + '\n' + http.statusText + '\n' + http.responseText);
} else {
Response.ContentType = 'image/png';
Response.BinaryWrite(http.responseBody);
Response.End();
}
%>