{"id":54,"date":"2021-09-18T00:56:08","date_gmt":"2021-09-17T16:56:08","guid":{"rendered":"https:\/\/kacter.cc\/?page_id=54"},"modified":"2021-10-29T15:29:57","modified_gmt":"2021-10-29T07:29:57","slug":"donent","status":"publish","type":"page","link":"https:\/\/kacter.cc\/zh_tw\/donent\/","title":{"rendered":"\u8d0a\u52a9"},"content":{"rendered":"\n<h2 class=\"has-text-align-center wp-block-heading\"><strong>\u8d0a\u52a9<\/strong><\/h2>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div id=\"smart-button-container\">\n      <div style=\"text-align: center;\">\n        <div style=\"margin-bottom: 1.25rem;\">\n          <p>Donate<\/p>\n          <select id=\"item-options\"><option value=\"\" price=\"1\"> &#8211; 1 USD<\/option><option value=\"\" price=\"10\"> &#8211; 10 USD<\/option><option value=\"\" price=\"20\"> &#8211; 20 USD<\/option><option value=\"\" price=\"50\"> &#8211; 50 USD<\/option><option value=\"\" price=\"98\"> &#8211; 98 USD<\/option><\/select>\n          <select style=\"visibility: hidden\" id=\"quantitySelect\"><\/select>\n        <\/div>\n      <div id=\"paypal-button-container\"><\/div>\n      <\/div>\n    <\/div>\n    <script src=\"https:\/\/www.paypal.com\/sdk\/js?client-id=AX-E5RR7brzqcjob6JWdqgnE1LsoThC8GoUrvxEPr7xxrOT23wAhVJiwX9KBkLM5BJ9lJTSmv4sy9Jz1&#038;enable-funding=venmo&#038;currency=USD\" data-sdk-integration-source=\"button-factory\"><\/script>\n    <script>\n      function initPayPalButton() {\n        var shipping = 0;\n        var itemOptions = document.querySelector(\"#smart-button-container #item-options\");\n    var quantity = parseInt();\n    var quantitySelect = document.querySelector(\"#smart-button-container #quantitySelect\");\n    if (!isNaN(quantity)) {\n      quantitySelect.style.visibility = \"visible\";\n    }\n    var orderDescription = 'Donate';\n    if(orderDescription === '') {\n      orderDescription = 'Item';\n    }\n    paypal.Buttons({\n      style: {\n        shape: 'rect',\n        color: 'blue',\n        layout: 'vertical',\n        label: 'paypal',\n        \n      },\n      createOrder: function(data, actions) {\n        var selectedItemDescription = itemOptions.options[itemOptions.selectedIndex].value;\n        var selectedItemPrice = parseFloat(itemOptions.options[itemOptions.selectedIndex].getAttribute(\"price\"));\n        var tax = (0 === 0 || false) ? 0 : (selectedItemPrice * (parseFloat(0)\/100));\n        if(quantitySelect.options.length > 0) {\n          quantity = parseInt(quantitySelect.options[quantitySelect.selectedIndex].value);\n        } else {\n          quantity = 1;\n        }\n\n        tax *= quantity;\n        tax = Math.round(tax * 100) \/ 100;\n        var priceTotal = quantity * selectedItemPrice + parseFloat(shipping) + tax;\n        priceTotal = Math.round(priceTotal * 100) \/ 100;\n        var itemTotalValue = Math.round((selectedItemPrice * quantity) * 100) \/ 100;\n\n        return actions.order.create({\n          purchase_units: [{\n            description: orderDescription,\n            amount: {\n              currency_code: 'USD',\n              value: priceTotal,\n              breakdown: {\n                item_total: {\n                  currency_code: 'USD',\n                  value: itemTotalValue,\n                },\n                shipping: {\n                  currency_code: 'USD',\n                  value: shipping,\n                },\n                tax_total: {\n                  currency_code: 'USD',\n                  value: tax,\n                }\n              }\n            },\n            items: [{\n              name: selectedItemDescription,\n              unit_amount: {\n                currency_code: 'USD',\n                value: selectedItemPrice,\n              },\n              quantity: quantity\n            }]\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      onError: function(err) {\n        console.log(err);\n      },\n    }).render('#paypal-button-container');\n  }\n  initPayPalButton();\n    <\/script>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8d0a\u52a9 Donate &#8211; 1 USD &#8211; 10 USD &#8211; 20 USD &#038; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-54","page","type-page","status-publish","hentry"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"featured_image_urls_v2":{"full":"","thumbnail":"","medium":"","medium_large":"","large":"","1536x1536":"","2048x2048":"","trp-custom-language-flag":"","woocommerce_archive_thumbnail":"","woocommerce_thumbnail":"","woocommerce_single":"","woocommerce_gallery_thumbnail":""},"post_excerpt_stackable_v2":"<p>\u8d0a\u52a9 Donate &#8211; 1 USD &#8211; 10 USD &#8211; 20 USD &#8211; 50 USD &#8211; 98 USD<\/p>\n","category_list_v2":"","author_info_v2":{"name":"DotKacter","url":"https:\/\/kacter.cc\/zh_tw\/author\/kacter\/"},"comments_num_v2":"0 comments","aioseo_notices":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/pages\/54","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/comments?post=54"}],"version-history":[{"count":4,"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/pages\/54\/revisions"}],"predecessor-version":[{"id":197,"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/pages\/54\/revisions\/197"}],"wp:attachment":[{"href":"https:\/\/kacter.cc\/zh_tw\/wp-json\/wp\/v2\/media?parent=54"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}