1// Settings 2 3const DATA_URL = 'https://secure.xsolla.com/paystation2/api/pay2play/init'; 4const WIDGET_OPTIONS = { 5 height: '650px', 6 spinner: 'round' 7} 8 9 10// Add digital content to access_data 11function getAccessData(digitalContent, projectId) { 12 let accessData = { 13 settings: { 14 project_id: projectId 15 } 16 }; 17 accessData.purchase = { 18 pin_codes: { 19 codes: [ 20 { 21 digital_content: digitalContent 22 } 23 ] 24 } 25 }, 26 accessData.user = { 27 country: { 28 allow_modify: false 29 } 30 31 } 32 ; 33 return accessData; 34} 35 36// view button 37function viewWidget(digitalContent, data, projectId) { 38 let price = data.digital_content.drm[0]; 39 let $el = $('[data-sku='+digitalContent+']'); 40 let currency = currencies[price.currency].symbol; 41 42 let formattedPrice = currency.template.replace('1', price.amount).replace('$', currency.grapheme); 43 $el.find('.xsolla-data').text(formattedPrice); 44 45 46 $el.click(() => { 47 48 let accessData = getAccessData(data.digital_content.sku, projectId); 49 XPayStationWidget.init({ 50 lightbox: WIDGET_OPTIONS, 51 access_data: accessData 52 }); 53 XPayStationWidget.open(); 54 }); 55} 56 57// Get Data by Digital Content 58function getVirtualItems(digitalContent, projectId) { 59 var accessData = getAccessData(digitalContent, projectId); 60 $.ajax({
61 url: DATA_URL, 62 data: { 63 access_data: JSON.stringify(accessData) 64 }, 65 method: 'post', 66 dataType: 'json', 67 beforeSend: function () { 68 69 }, 70 success: function (data) { 71 viewWidget(digitalContent, data, projectId); 72 } 73 }); 74}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.