Файловый менеджер - Редактировать - /var/www/readzy/app/www/assets/js/purchase.js
Назад
var purchase = { active : 'false', init : () => { if(!window.cordova){ return; } if(localStorage.getItem('pro_owned')){ purchase.active = localStorage.getItem('pro_owned'); } store.autoFinishTransactions = true; // Register subscriptions store.register({ id: 'com.readzy.month', alias: '1 Month Subscription', type: store.PAID_SUBSCRIPTION }); store.register({ id: 'com.readzy.trial', alias: 'Trial Subscription', type: store.PAID_SUBSCRIPTION }); store.when("product").updated(function (p) { if(p.id == 'com.readzy.month'){ //$('.purchase #subscribe span').html(p.price+' per month'); $('.purchase #subscribe span').html('Only <b>'+p.price+'</b> per month'); $('.purchase .pricing_monthly').html(p.price); } if(p.id == 'com.readzy.trial'){ $('.purchase #trial span').html('3 Days then <b>'+p.price+'</b> per week'); $('.purchase .pricing_weekly').html(p.price); } }); store.error(function(error) { app.alert('Subscription', error.message, 'Close', () => { purchase.expired(); }); }); store.ready(function(){ // Update product info when loaded }); store.validator = function(product, callback) { //alert('Validate'); //alert(JSON.stringify(product)); //alert(JSON.stringify(product.transaction.appStoreReceipt)); if(!product){ callback(false); return; } if(!product.transaction){ callback(false); return; } if(!product.transaction.appStoreReceipt){ callback(false); return; } //if(product.transaction.appStoreReceipt){ api.post('purchase/validate',{receipt:product.transaction.appStoreReceipt}, (j) => { if(j.active){ callback(true); }else{ purchase.expired(); callback(false, { code: store.PURCHASE_EXPIRED, error: { message: "Please renew your subscription to continue premium access." } }); } }); //}else{ // callback(false); //} //callback(true); // success! // OR /*callback(false, { code: store.PURCHASE_EXPIRED, error: { message: "XYZ" } });*/ // OR //callback(false, "Impossible to proceed with validation"); }; purchase.set('1 Month Subscription'); purchase.set('Trial Subscription'); store.refresh(); }, show : () => { $('.purchase').css('display','flex'); app.tap('.purchase .close', () => { $('.purchase').css('display','none'); }); app.tap('.purchase .button', (ele) => { var id = $(ele).attr('data-id'); if(id == 'restore'){ store.refresh(); }else{ app.load.show(); store.order(id); } }); }, hide : () => { $('.purchase').css('display','none'); }, set : (alias) => { store.when(alias).updated(function(product) { if (product.owned) { purchase.owned(); } }); store.when(alias).approved(function(product) { //alert('approved'); //alert(JSON.stringify(product)); product.verify(); }); store.when(alias).verified(function(product) { //alert('verified'); //alert(JSON.stringify(product)); product.finish(); }); store.when(alias).owned(function(product) { //alert('owend'); //app.alert('Owned', JSON.stringify(product), 'Close', () => { //}); if (product.owned) { //alert(JSON.stringify(product)); purchase.owned(); //product.finish(); }else{ purchase.expired(); } }); store.when(alias).cancelled(function(product) { //alert('cancelled'); if (product.owned) { //alert(JSON.stringify(product)); purchase.owned(); }else{ purchase.expired(); } }); store.when(alias).refunded(function(product) { //alert('refunded'); if (product.owned) { //alert(JSON.stringify(product)); purchase.owned(); }else{ purchase.expired(); } }); store.when(alias).expired(function(product) { //alert('expired'); if (product.owned) { //alert(JSON.stringify(product)); purchase.owned(); }else{ purchase.expired(); } }); }, owned : () => { localStorage.setItem('pro_owned','true'); purchase.active = 'true'; purchase.hide(); app.load.hide(); }, expired : () => { purchase.active = 'false'; localStorage.setItem('pro_owned','false'); app.load.hide(); }, }
| ver. 1.4 |
Github
|
.
| PHP 7.0.33-0ubuntu0.16.04.16 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка