{"id":1463,"date":"2022-04-24T22:03:35","date_gmt":"2022-04-24T22:03:35","guid":{"rendered":"https:\/\/www.tutavo.com\/Kachina\/?p=1463"},"modified":"2023-10-19T04:10:31","modified_gmt":"2023-10-19T04:10:31","slug":"jack","status":"publish","type":"post","link":"https:\/\/www.tutavo.com\/Kachina\/jack\/","title":{"rendered":"Jack Evans Purchase Page"},"content":{"rendered":"<div id=\"smart-button-container\">\n<div style=\"text-align: center;\"><label for=\"description\">Purchase Cost <\/label><input id=\"description\" maxlength=\"127\" name=\"descriptionInput\" type=\"text\" 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\">Put amount here: <\/label><input id=\"amount\" name=\"amountInput\" type=\"number\" value=\"\" \/> USD<\/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\">PurchCost <\/label><input id=\"invoiceid\" maxlength=\"127\" name=\"invoiceid\" type=\"text\" value=\"\" \/><\/div>\n<p id=\"invoiceidError\" style=\"visibility: hidden; color: red; text-align: center;\">Please enter an Invoice ID<\/p>\n<div id=\"paypal-button-container\" style=\"text-align: center; margin-top: 0.625rem;\"><\/div>\n<\/div>\n<p><script src=\"https:\/\/www.paypal.com\/sdk\/js?client-id=sb&#038;enable-funding=venmo&#038;currency=USD\" data-sdk-integration-source=\"button-factory\"><\/script><br \/>\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');<\/p>\n<p>    var elArr = [description, amount];<\/p>\n<p>    if (invoiceidDiv.firstChild.innerHTML.length > 1) {\n      invoiceidDiv.style.display = \"block\";\n    }<\/p>\n<p>    var purchase_units = [];\n    purchase_units[0] = {};\n    purchase_units[0].amount = {};<\/p>\n<p>    function validate(event) {\n      return event.value.length > 0;\n    }<\/p>\n<p>    paypal.Buttons({\n      style: {\n        color: 'gold',\n        shape: 'rect',\n        label: 'paypal',\n        layout: 'vertical',<\/p>\n<p>      },<\/p>\n<p>      onInit: function (data, actions) {\n        actions.disable();<\/p>\n<p>        if(invoiceidDiv.style.display === \"block\") {\n          elArr.push(invoiceid);\n        }<\/p>\n<p>        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      },<\/p>\n<p>      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 &#038;&#038; 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 = '<\/p>\n<h3>Thank you for your payment!<\/h3>\n<p>';<\/p>\n<p>          \/\/ Or go to another URL:  actions.redirect('thank_you.html');<\/p>\n<p>        });\n      },<\/p>\n<p>      onError: function (err) {\n        console.log(err);\n      }\n    }).render('#paypal-button-container');\n  }\n  initPayPalButton();\n  <\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Purchase Cost Please enter a description Put amount here: USD Please enter a price PurchCost Please enter an Invoice ID<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1463","post","type-post","status-publish","format-standard","hentry","category-family-and-friends"],"_links":{"self":[{"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/posts\/1463","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/comments?post=1463"}],"version-history":[{"count":5,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/posts\/1463\/revisions"}],"predecessor-version":[{"id":1618,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/posts\/1463\/revisions\/1618"}],"wp:attachment":[{"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/media?parent=1463"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/categories?post=1463"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tutavo.com\/Kachina\/wp-json\/wp\/v2\/tags?post=1463"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}