{"id":2519,"date":"2019-10-19T06:59:54","date_gmt":"2019-10-19T13:59:54","guid":{"rendered":"https:\/\/dbenca.org\/wordpress\/?page_id=2519"},"modified":"2021-10-29T17:48:25","modified_gmt":"2021-10-29T21:48:25","slug":"donate","status":"publish","type":"page","link":"https:\/\/dbenca.org\/wordpress\/donate\/","title":{"rendered":"DONATE\/PAY"},"content":{"rendered":"\n<div id=\"smart-button-container\">\n    <div style=\"text-align: center\"><label for=\"description\">Donation or Payment? <\/label><input type=\"text\" name=\"descriptionInput\" id=\"description\" maxlength=\"127\" value=\"\"><\/div>\n      <p id=\"descriptionError\" style=\"visibility: hidden; color:red; text-align: center;\">Please enter a description<\/p>\n    <div style=\"text-align: center\"><label for=\"amount\">Currency <\/label><input name=\"amountInput\" type=\"number\" id=\"amount\" value=\"\"><span> USD<\/span><\/div>\n      <p id=\"priceLabelError\" style=\"visibility: hidden; color:red; text-align: center;\">Please enter a price<\/p>\n    <div id=\"invoiceidDiv\" style=\"text-align: center; display: none;\"><label for=\"invoiceid\"> <\/label><input name=\"invoiceid\" maxlength=\"127\" type=\"text\" id=\"invoiceid\" value=\"\"><\/div>\n      <p id=\"invoiceidError\" style=\"visibility: hidden; color:red; text-align: center;\">Please enter an Invoice ID<\/p>\n    <div style=\"text-align: center; margin-top: 0.625rem;\" id=\"paypal-button-container\"><\/div>\n  <\/div>\n  <script src=\"https:\/\/www.paypal.com\/sdk\/js?client-id=sb&amp;enable-funding=venmo&amp;currency=USD\" data-sdk-integration-source=\"button-factory\"><\/script>\n  <script>\n  function initPayPalButton() {\n    var description = document.querySelector('#smart-button-container #description');\n    var amount = document.querySelector('#smart-button-container #amount');\n    var descriptionError = document.querySelector('#smart-button-container #descriptionError');\n    var priceError = document.querySelector('#smart-button-container #priceLabelError');\n    var invoiceid = document.querySelector('#smart-button-container #invoiceid');\n    var invoiceidError = document.querySelector('#smart-button-container #invoiceidError');\n    var invoiceidDiv = document.querySelector('#smart-button-container #invoiceidDiv');\n\n    var elArr = [description, amount];\n\n    if (invoiceidDiv.firstChild.innerHTML.length > 1) {\n      invoiceidDiv.style.display = \"block\";\n    }\n\n    var purchase_units = [];\n    purchase_units[0] = {};\n    purchase_units[0].amount = {};\n\n    function validate(event) {\n      return event.value.length > 0;\n    }\n\n    paypal.Buttons({\n      style: {\n        color: 'gold',\n        shape: 'pill',\n        label: 'paypal',\n        layout: 'vertical',\n        \n      },\n\n      onInit: function (data, actions) {\n        actions.disable();\n\n        if(invoiceidDiv.style.display === \"block\") {\n          elArr.push(invoiceid);\n        }\n\n        elArr.forEach(function (item) {\n          item.addEventListener('keyup', function (event) {\n            var result = elArr.every(validate);\n            if (result) {\n              actions.enable();\n            } else {\n              actions.disable();\n            }\n          });\n        });\n      },\n\n      onClick: function () {\n        if (description.value.length < 1) {\n          descriptionError.style.visibility = \"visible\";\n        } else {\n          descriptionError.style.visibility = \"hidden\";\n        }\n\n        if (amount.value.length < 1) {\n          priceError.style.visibility = \"visible\";\n        } else {\n          priceError.style.visibility = \"hidden\";\n        }\n\n        if (invoiceid.value.length < 1 && invoiceidDiv.style.display === \"block\") {\n          invoiceidError.style.visibility = \"visible\";\n        } else {\n          invoiceidError.style.visibility = \"hidden\";\n        }\n\n        purchase_units[0].description = description.value;\n        purchase_units[0].amount.value = amount.value;\n\n        if(invoiceid.value !== '') {\n          purchase_units[0].invoice_id = invoiceid.value;\n        }\n      },\n\n      createOrder: function (data, actions) {\n        return actions.order.create({\n          purchase_units: purchase_units,\n        });\n      },\n\n      onApprove: function (data, actions) {\n        return actions.order.capture().then(function (orderData) {\n\n          \/\/ Full available details\n          console.log('Capture result', orderData, JSON.stringify(orderData, null, 2));\n\n          \/\/ Show a success message within this page, e.g.\n          const element = document.getElementById('paypal-button-container');\n          element.innerHTML = '';\n          element.innerHTML = '<h3>Thank you for your payment!<\/h3>';\n\n          \/\/ Or go to another URL:  actions.redirect('thank_you.html');\n          \n        });\n      },\n\n      onError: function (err) {\n        console.log(err);\n      }\n    }).render('#paypal-button-container');\n  }\n  initPayPalButton();\n  <\/script>\n\n\n[do_widget id=links-3]\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Donation or Payment? Please enter a description Currency USD Please enter a price Please enter an Invoice ID<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-fullwidth.php","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"class_list":["post-2519","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/pages\/2519","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2519"}],"version-history":[{"count":16,"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/pages\/2519\/revisions"}],"predecessor-version":[{"id":2916,"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/pages\/2519\/revisions\/2916"}],"wp:attachment":[{"href":"https:\/\/dbenca.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2519"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}