// source --> https://oldschooltattoomachines.com.br/wp-content/plugins/woocommerce-pagseguro-oficial/assets/js/direct-payment.js?ver=5.4.11 var WS = { 'Ajax' : { 'Direct' : { 'Boleto': { 'Payment' : function (base_url, order_id, hash, document, error) { jQuery.ajax({ url: ajax_object.ajax_url+"?wc-pagseguro-ajax=true", data: { order_id: order_id, sender_hash : hash, sender_document : document, checkout_type : 'boleto' }, type: 'POST' }).success(function (response) { response = JSON.parse(response); var link = response.payload.data.payment_link; var redirect = response.payload.data.url + '?order_id=' + response.payload.data.order_id + '&link_boleto=' + link; window.open(link, '_blank'); window.setTimeout(function () { window.location = redirect; }, 3000); }).error(function(){ //@todo show error message and redirect to shop }); } }, 'OnlineDebit': { 'Payment' : function (base_url, order_id, hash, document, bank, error) { jQuery.ajax({ url: ajax_object.ajax_url+"?wc-pagseguro-ajax=true", data: { order_id: order_id, sender_hash : hash, sender_document : document, bank_name:bank, checkout_type : 'debit' }, type: 'POST' }).success(function (response) { response = JSON.parse(response); var link = response.payload.data.payment_link; var redirect = response.payload.data.url + '?order_id=' + response.payload.data.order_id + '&link_debit=' + link; window.open(link, '_blank'); window.setTimeout(function () { window.location = redirect; }, 3000); }).error(function(){ //@todo show error message and redirect to shop }); } }, 'CreditCard': { 'Installments' : function (url, id, brand, isInternational) { jQuery.ajax({ url: ajax_object.ajax_url+"?wc-pagseguro-ajax=true", data: { order_id: id, credit_card_brand : brand, credit_card_international : isInternational, checkout_type : 'installments' }, type: 'POST' }).success(function (response) { response = JSON.parse(response); if (response.success) { //remove if already exists installment options jQuery('#card_installments option').each(function () { if (!jQuery(this).val() === false) { jQuery(this).remove(); } }); //add installments options jQuery.each(response.payload.data, function (i, item) { jQuery('#card_installments').append(jQuery('