zh Kooboo Logo Documents



Providing a convenient method to establish user payment options.
Payments usually require certain configuration information, such as App keys, which can be found in system settings.
The main method is "charge", which returns different objects for different payment methods. Some display HTML, while others redirect.
Here is a complete example of WeChat Pay:
<script env="server">

var charge = {}; 
charge.total = 1.50;  
charge.name = "green tea order"; 

charge.description = "The best tea from Xiamen";   
var res = k.payment.wechat.charge(charge); 

<div k-content="res.html"></div> 
<div id="paymentRefId" style="display:none;" k-content="res.requestId"></div> 

function checkStatus() 
{ var url = "/_api/payment/CheckStatus?id="+ document.getElementById("paymentRefId").innerText; 

$.ajax({url: url }).done(function(res) { 
if (res.model.paid) 
{ alert('pay successfully.'); clearInterval(timerid);  } }); }  
var timerid = setInterval(checkStatus, 1000);
The following code automatically submits the form to make a payment through PayPal:
<script env="server"> 
var charge = {}; 
charge.total = 1.50;  
charge.name = 'Tea from Xiamen';  
var resForm = k.payment.paypalForm.charge(charge);  

<div k-content='resForm.html'></div>