Модуль ipsp.js позволяет использовать сервис приема платежей FONDY посредством интеграции Java Script на вашей странице.
Для подключения актуальной версии модуля используйте следующий код:
<script src="https://pay.fondy.eu/static_common/v1/checkout/ipsp.js"></script>
Для вызова платежной страницы через JavaScript API, необходимо сначала отправить запрос server-to-server на адрес https://pay.fondy.eu/api/checkout/url/ и в ответ получить url платежной страницы:
Пример запроса
{
"request": {
"response_url": "https://api.fondy.eu/responsepage/",
"order_id": "test8037875286",
"order_desc": "Test payment",
"currency": "UAH",
"amount": "100",
"signature": "07bc309047a56275f8d89ae222e2af0ceb94fe79",
"merchant_id": "1"
}
}
Пример ответа
{
"response":{
"response_status":"success",
"checkout_url":"https://api.fondy.eu/checkout?token=afcb21aef707b1fea2565b66bac7dc41d7833390"
}
}
Более детальную документацию по server-to-server API см. Формирование запроса
Полученный в ответе url вида
https://pay.fondy.eu/checkout?token=afcb21aef707b1fea2565b66bac7dc41d7833390
необходимо подставить в код JavaScript в следующей строке:
// load checkout url received from server-server api this.loadUrl(url);
см. пример ниже.
$ipsp.get('checkout').config({
'wrapper': '#frameholder' ,
'ismodal': false ,
'styles' : {
'body':{'overflow':'hidden'},
'.page-section-shopinfo':{display:'none'},
'.page-section-footer':{display:'none'}
}
}).scope(function(){
// set checkout element target
this.setCheckoutWrapper('#frameholder');
// set checkout modal state
this.setModal(false);
// set checkout size? use only with setModal(false)
this.setCheckoutWidth(480);
this.setCheckoutHeight(450);
// apply custom styles to checkout page
this.setCssStyle({
'body':{'overflow':'hidden'},
'.page-section-shopinfo':{display:'none'},
'.page-section-footer':{display:'none'}
});
// add action handlers
this.action('decline',function(data,type){
console.log(data);
});
this.action('message',function(data,type){
console.log(data);
});
this.action('show',function(){
console.log('show checkout');
});
this.action('hide',function(){
console.log('hide checkout');
});
// add resize handler that triggers
// when checkout page change size
this.action('resize',function(data,type){
this.setCheckoutHeight(data.height);
});
// load checkout url received from server-server api
// or from Button Module `$ipsp('button').getUrl()`
this.loadUrl(checkout_url);
// bind multiple html elements to open checkout
this.setElementAttr('data-url');
this.setClickElement('.product-list .pay-button');
// handle success response from checkout
this.unbind('callback').action('callback',function(){
...code
});
// handle decline response from checkout
this.action('decline',function(){
...code
});
// handle all response from checkout api
this.addCallback(__DEFAULTCALLBACK__);
});
$ipsp.get('checkout').config({
'wrapper':'body',
'ismodal':true,
'styles' : {
'body':{'overflow':'hidden'},
'.page-section-shopinfo':{display:'none'},
'.page-section-footer':{display:'none'}
}
}).scope(function(){
this.action('decline',function(data,type){
console.log(data);
});
this.action('message',function(data,type){
console.log(data);
});
this.loadUrl(url);
});
$ipsp.get('checkout').config({
'wrapper': '#frameholder' ,
'styles' : {
'body':{'overflow':'hidden'},
'.page-section-shopinfo':{display:'none'},
'.page-section-footer':{display:'none'}
}
}).scope(function(){
this.width(480);
this.height(480);
this.action('decline',function(data,type){
console.log(data);
});
this.action('message',function(data,type){
console.log(data);
});
this.loadUrl(url);
});
$ipsp.get('checkout').config({
'wrapper':'#frameholder',
'styles' : {},
}).scope(function(){
this.width(480);
this.height(480);
this.addCallback(__DEFAULTCALLBACK__);
this.loadUrl(url);
});
Для работы с Apple Pay нужно дополнительно добавить в JS код конфигурации платежной страницы:
$ipsp('checkout').config({
'mobilepay':{
'container':'#fondyApplePay'
}).scope
и div в страницу вставить
<div id="fondyApplePay"> </div>