diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c3017fb..3880ff9 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -custom: https://tip.depay.com/6KFBECVsokSt0UKOAug8CI +custom: https://link.depay.com/6KFBECVsokSt0UKOAug8CI diff --git a/.gitignore b/.gitignore index 07e6e47..d00f09d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,26 @@ -/node_modules +# ignore everything in the root except the "wp-content" directory. +!wp-content/ + +# ignore everything in the "wp-content" directory, except: +# "mu-plugins", "plugins", "themes" directory +wp-content/* +!wp-content/mu-plugins/ +!wp-content/plugins/ +!wp-content/themes/ + +# ignore these plugins +wp-content/plugins/hello.php + +# ignore specific themes +wp-content/themes/twenty*/ + +# ignore node dependency directories +node_modules/ + +# ignore log files and databases +*.log +*.sql +*.sqlite + +phpcs-report.txt +lint/vendor diff --git a/.wordpress-org/_icon-128x128.png b/.wordpress-org/_icon-128x128.png index ae0cff5..8eda2aa 100644 Binary files a/.wordpress-org/_icon-128x128.png and b/.wordpress-org/_icon-128x128.png differ diff --git a/.wordpress-org/_icon-256x256.png b/.wordpress-org/_icon-256x256.png index e23b5d6..34f69f6 100644 Binary files a/.wordpress-org/_icon-256x256.png and b/.wordpress-org/_icon-256x256.png differ diff --git a/.wordpress-org/banner-1544x500.jpg b/.wordpress-org/banner-1544x500.jpg index d5d10b6..97a268b 100644 Binary files a/.wordpress-org/banner-1544x500.jpg and b/.wordpress-org/banner-1544x500.jpg differ diff --git a/.wordpress-org/banner-772x250.jpg b/.wordpress-org/banner-772x250.jpg index 2324165..f513a48 100644 Binary files a/.wordpress-org/banner-772x250.jpg and b/.wordpress-org/banner-772x250.jpg differ diff --git a/.wordpress-org/icon-128x128.gif b/.wordpress-org/icon-128x128.gif index 4f27e5a..4151d2d 100644 Binary files a/.wordpress-org/icon-128x128.gif and b/.wordpress-org/icon-128x128.gif differ diff --git a/.wordpress-org/icon-256x256.gif b/.wordpress-org/icon-256x256.gif index f95c75b..c5e25c1 100644 Binary files a/.wordpress-org/icon-256x256.gif and b/.wordpress-org/icon-256x256.gif differ diff --git a/.wordpress-org/screenshot-1.gif b/.wordpress-org/screenshot-1.gif deleted file mode 100644 index 7c62fd1..0000000 Binary files a/.wordpress-org/screenshot-1.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-1.jpg b/.wordpress-org/screenshot-1.jpg new file mode 100644 index 0000000..4b2ac57 Binary files /dev/null and b/.wordpress-org/screenshot-1.jpg differ diff --git a/.wordpress-org/screenshot-2.gif b/.wordpress-org/screenshot-2.gif deleted file mode 100644 index f075542..0000000 Binary files a/.wordpress-org/screenshot-2.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-2.jpg b/.wordpress-org/screenshot-2.jpg new file mode 100644 index 0000000..632bf27 Binary files /dev/null and b/.wordpress-org/screenshot-2.jpg differ diff --git a/.wordpress-org/screenshot-3.gif b/.wordpress-org/screenshot-3.gif deleted file mode 100644 index 14efbce..0000000 Binary files a/.wordpress-org/screenshot-3.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-3.jpg b/.wordpress-org/screenshot-3.jpg new file mode 100644 index 0000000..36277ed Binary files /dev/null and b/.wordpress-org/screenshot-3.jpg differ diff --git a/.wordpress-org/screenshot-4.gif b/.wordpress-org/screenshot-4.gif deleted file mode 100644 index 2474337..0000000 Binary files a/.wordpress-org/screenshot-4.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-4.jpg b/.wordpress-org/screenshot-4.jpg new file mode 100644 index 0000000..0f530c9 Binary files /dev/null and b/.wordpress-org/screenshot-4.jpg differ diff --git a/.wordpress-org/screenshot-5.gif b/.wordpress-org/screenshot-5.gif deleted file mode 100644 index b7969b4..0000000 Binary files a/.wordpress-org/screenshot-5.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-6.gif b/.wordpress-org/screenshot-6.gif deleted file mode 100644 index d161a85..0000000 Binary files a/.wordpress-org/screenshot-6.gif and /dev/null differ diff --git a/.wordpress-org/screenshot-7.gif b/.wordpress-org/screenshot-7.gif deleted file mode 100644 index 2a2e10b..0000000 Binary files a/.wordpress-org/screenshot-7.gif and /dev/null differ diff --git a/README.md b/README.md index d6d5d46..69f590e 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,29 @@ -## DePay Payments +## DePay for Wordpress -The Wordpress Web3 Payments plugin allows you to accept cryptocurrency payments directly into your wallet. +The Wordpress Web3 Payments plugin allows you to accept web3 crypto payments directly into your wallet. -![Wordpress Web3 Payments](/.wordpress-org/screenshot-1.gif) +![Wordpress Web3 Payments](/.wordpress-org/screenshot-1.jpg) ### Demo -Visit our demo wordpress installation and scroll to the buttom to find the "Pay" button: - https://web3wordpress.xyz/ ### Installation -1. [Download the latest plugin](https://github.com/DePayFi/web3-wordpress-depay-payments/releases/latest/download/wp-depay-payments-plugin.zip) +1. [Download the latest plugin](https://github.com/DePayFi/web3-payments-depay/releases/latest/download/wp-depay-payments-plugin.zip) 2. Install the the plugin from within your wordpress admin section: "Plugins" -> "Upload Plugin" -> Choose the plugin zip you've downloaded in step 1 -### Release +## Development -In order to release the plugins simply push a git tag: +### Update Version ``` -git commit +yarn update:version ``` +### Release + ``` -git push -git tag v2.5.1 -git push origin v2.5.1 +yarn release ``` diff --git a/block.json b/block.json index d4d44b4..dbb62cd 100644 --- a/block.json +++ b/block.json @@ -2,11 +2,11 @@ "$schema": "https://schemas.wp.org/trunk/block.json", "apiVersion": 2, "name": "depay-payments/block", - "title": "DePay Payments", + "title": "DePay", "category": "widgets", - "description": "Accept Web3 Payments, supporting various cryptocurrency tokens and wallets: MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL...", - "keywords": [ "payments", "cryptocurrency", "web3", "DePay", "USDC" ], - "version": "2.5.1", + "description": "Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…", + "keywords": [ "payments", "crypto", "web3", "DePay", "USDC" ], + "version": "3.0.0", "textdomain": "depay-payments", "example": {}, "editorScript": "depay-payments-script", diff --git a/core/class-depay-payments.php b/core/class-depay-payments.php index 149710f..2e3ee91 100644 --- a/core/class-depay-payments.php +++ b/core/class-depay-payments.php @@ -51,7 +51,7 @@ final class DePay_Payments { * @return void */ public function __clone() { - _doing_it_wrong( __FUNCTION__, __( 'You are not allowed to clone this class.', 'depay-payments' ), '1.0.0' ); + _doing_it_wrong( __FUNCTION__, __( 'You are not allowed to clone this class.', 'depay-payments' ), DEPAYPAYMENTS_VERSION ); } /** @@ -62,7 +62,7 @@ public function __clone() { * @return void */ public function __wakeup() { - _doing_it_wrong( __FUNCTION__, __( 'You are not allowed to unserialize this class.', 'depay-payments' ), '1.0.0' ); + _doing_it_wrong( __FUNCTION__, __( 'You are not allowed to unserialize this class.', 'depay-payments' ), DEPAYPAYMENTS_VERSION ); } /** diff --git a/core/includes/assets/css/admin.css b/core/includes/assets/css/admin.css index c4635b1..f7d6d93 100644 --- a/core/includes/assets/css/admin.css +++ b/core/includes/assets/css/admin.css @@ -143,8 +143,8 @@ height: 48px; } .widget-example .DialogHeaderActionRight .Icon { -position: relative; -top: -2px; + position: relative; + top: 0; } .widget-example .DialogHeaderActionLeft { position: absolute; diff --git a/core/includes/assets/css/frontend.css b/core/includes/assets/css/frontend.css index 0329e77..a274440 100644 --- a/core/includes/assets/css/frontend.css +++ b/core/includes/assets/css/frontend.css @@ -14,7 +14,7 @@ float: left; } -.wp-block-depay-payments-block-settings { +.wp-block-depay-payments-block-settings-amount { position: absolute; top: -4px; right: -4px; @@ -25,3 +25,15 @@ color: white; font-size: 12px; } + +.wp-block-depay-payments-block-settings-label { + position: absolute; + top: -4px; + left: -4px; + background: black; + box-shadow: 0 0 8px rgba(0,0,0,0.2); + border-radius: 5px; + padding: 4px; + color: white; + font-size: 12px; +} diff --git a/core/includes/assets/js/admin.js b/core/includes/assets/js/admin.js index 89226fd..b78f15d 100644 --- a/core/includes/assets/js/admin.js +++ b/core/includes/assets/js/admin.js @@ -1 +1 @@ -!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="/Users/sebastian/Work/DePay/web3-wordpress-depay-payments/src/admin.js";function t(e){let t,l=e[0],a=1;for(;al.call(t,...e))),t=void 0)}return l}!function(l,a){const i=window.React.useEffect,s=window.React.useState,r=["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XCD","XDR","XOF","XPF","YER","ZAR","ZMW","ZWL"],n=function(a){const[n,m]=s(!1),[_,o]=s(!1),[c,u]=s(),[N,f]=s(),[d,h]=s(),[y,b]=s(),[p,g]=s(),[E,v]=s(),[D,w]=s(),[P,C]=s(),[B,x]=s(),[R,S]=s(),[k,F]=s(),[T,A]=s(),[L,M]=s(),[I,K]=s([]),[U,W]=s(),[G,H]=s(),[O,V]=s(),[Z,Y]=s(),[q,X]=s(),[$,j]=s(),[z,J]=s(),[Q,ee]=s(),[te,le]=s(),ae=(e,t,l)=>{let a=[...I];if(e&&0!==e.length)try{e="solana"===l?new SolanaWeb3js.PublicKey(e).toString():ethers.ethers.utils.getAddress(e),a[t].error=void 0}catch(e){a[t].error="This address is invalid!"}else a[t].error="Please enter a receiver address!";a[t].receiver=e,K(a)};return i((()=>{A(`button {\n border-radius: ${d||2}px;\n color: ${p||"#FFFFFF"};\n background: ${y||"#32373c"};\n}`)}),[d,p,y]),i((()=>{M(`.ButtonPrimary { color: ${P||"#FFFFFF"}; border-radius: ${D}px;}`)}),[E,P,D,B,R]),i((()=>{wp.api.loadPromise.then((()=>{(new wp.api.models.Settings).fetch({cache:"no-cache"}).then((e=>{e.DePay_payments_accepted_payments&&(e.DePay_payments_accepted_payments.forEach((t=>{void 0===t.receiver&&e.DePay_payments_receiving_wallet_address&&(t.receiver=e.DePay_payments_receiving_wallet_address)})),K(e.DePay_payments_accepted_payments)),F(e.DePay_payments_button_label||"Pay"),A(e.DePay_payments_button_css||"button {\n border-radius: 2px;\n color: #FFFFFF;\n background: #32373c;\n}"),M(e.DePay_payments_widget_css||".ButtonPrimary {border-radius: 2px;}"),b(e.DePay_payments_button_background_color||"#32373c"),g(e.DePay_payments_button_text_color||"#FFFFFF"),h(e.DePay_payments_button_border_radius||"2"),v(e.DePay_payments_widget_color_primary||"#32373c"),w(e.DePay_payments_widget_button_border_radius||"2"),C(e.DePay_payments_widget_color_button_text||"#FFFFFF"),W(e.DePay_payments_widget_amount_type||"fix"),H(t([e,"access",e=>e.DePay_payments_widget_display_currency,"optionalAccess",e=>e.length])>2?e.DePay_payments_widget_display_currency:"local"),V(e.DePay_payments_widget_amount_free_start||1),Y(e.DePay_payments_widget_amount_free_min||1),X(e.DePay_payments_widget_amount_free_step||1),j(t([e,"access",e=>e.DePay_payments_widget_amount_currency,"optionalAccess",e=>e.length])>0?e.DePay_payments_widget_amount_currency:"USD"),J(e.DePay_payments_widget_fix_amount||1),x(),S(),o(!0)}))})).catch((()=>{}))}),[]),i((()=>{f(!(I&&I.length&&I.every((e=>e.receiver&&e.receiver.length>0&&void 0===e.error))))}),[I]),i((()=>{m(!1)}),[d,y,p,E,D,P,B,R,k,T,L,I,U,G,O,Z,q,$,z]),i((()=>{"fix"===U?(LocalCurrency.Currency.rate({from:$||"USD",to:"USD"}).then((e=>{ee((z/e).toFixed(2))})),LocalCurrency.Currency.rate({from:$||"USD",to:"local"===G?void 0:G}).then((e=>{le(new LocalCurrency.Currency({amount:z/e,code:"local"===G?void 0:G}).toString())}))):(le(new LocalCurrency.Currency({amount:O||1,code:"local"===G?void 0:G}).toString()),"local"===G||void 0===G||t([G,"optionalAccess",e=>e.length])<3?LocalCurrency.Currency.rate({from:new LocalCurrency.Currency({amount:0}).code,to:"USD"}).then((e=>{ee(((O||1)/e).toFixed(2))})):LocalCurrency.Currency.rate({from:"USD",to:t([G,"optionalAccess",e=>e.length])>=2?G:void 0}).then((e=>{ee(((O||1)*e).toFixed(2))})))}),[G,O,U,z,$]),_?l.createElement("div",{className:"wrap",__self:this,__source:{fileName:e,lineNumber:205}},l.createElement("h1",{className:"wp-heading-inline",__self:this,__source:{fileName:e,lineNumber:207}},"DePay Payments"),l.createElement("p",{__self:this,__source:{fileName:e,lineNumber:209}},"To view received payments, please open the ",l.createElement("a",{href:"https://app.depay.com/payments",target:"_blank",__self:this,__source:{fileName:e,lineNumber:209}},"DePay App"),"."),l.createElement("table",{className:"form-table",role:"presentation",__self:this,__source:{fileName:e,lineNumber:211}},l.createElement("tbody",{__self:this,__source:{fileName:e,lineNumber:212}},l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:213}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:214}},"Accepted Payments"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:217}},l.createElement("div",{style:{paddingBottom:"1rem"},__self:this,__source:{fileName:e,lineNumber:218}},"Select the tokens that you want to receive as payment:"),I&&I.map(((t,a)=>l.createElement("table",{key:`${a}-${t.blockchain}-${t.symbol}`,className:"wp-list-table widefat fixed striped table-view-list page",style:{maxWidth:"600px",marginBottom:"0.4rem"},__self:this,__source:{fileName:e,lineNumber:224}},l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:225}},l.createElement("td",{style:{padding:"1rem 1rem 0.4rem 1rem",display:"flex"},__self:this,__source:{fileName:e,lineNumber:226}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:227}},l.createElement("div",{style:{position:"relative",display:"block"},__self:this,__source:{fileName:e,lineNumber:228}},l.createElement("img",{src:t.logo,style:{background:"white",borderRadius:"99px",height:"3rem",width:"3rem"},__self:this,__source:{fileName:e,lineNumber:229}}),l.createElement("img",{src:Web3Blockchains[t.blockchain].logo,style:{position:"absolute",bottom:"2px",right:"0px",width:"20px",height:"20px",border:"1px solid white",borderRadius:"4px",backgroundColor:Web3Blockchains[t.blockchain].logoBackgroundColor},__self:this,__source:{fileName:e,lineNumber:230}}))),l.createElement("div",{style:{paddingLeft:"1rem",paddingBottom:"0.3rem",flex:1},__self:this,__source:{fileName:e,lineNumber:233}},l.createElement("div",{style:{display:"flex",justifyontent:"space-between",fontSize:"1rem"},__self:this,__source:{fileName:e,lineNumber:234}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:235}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:236}},t.symbol)," (",t.name,") on ",Web3Blockchains[t.blockchain].label),l.createElement("div",{className:"row-actions visible",style:{marginLeft:"auto"},__self:this,__source:{fileName:e,lineNumber:238}},l.createElement("span",{className:"delete",__self:this,__source:{fileName:e,lineNumber:239}},l.createElement("a",{href:"#",onClick:()=>(e=>{let t=I.slice();t.splice(e,1),K(t)})(a),__self:this,__source:{fileName:e,lineNumber:240}},"Remove")))),l.createElement("div",{style:{paddingTop:".5rem"},__self:this,__source:{fileName:e,lineNumber:244}},l.createElement("label",{style:{marginBottom:0},__self:this,__source:{fileName:e,lineNumber:245}},l.createElement("span",{className:"",style:{opacity:.7,paddingBottom:"1px",display:"block"},__self:this,__source:{fileName:e,lineNumber:246}},"Receiver"),l.createElement("div",{className:"components-base-control",__self:this,__source:{fileName:e,lineNumber:247}},l.createElement("input",{required:"required",style:{width:"100%"},id:"depay-woocommerce-payment-receiver-address",type:"text",value:t.receiver,onChange:e=>ae(e.target.value,a,t.blockchain),__self:this,__source:{fileName:e,lineNumber:248}})),t.error&&l.createElement("div",{className:"notice inline notice-warning notice-alt",style:{marginBottom:0},__self:this,__source:{fileName:e,lineNumber:258}},t.error))),l.createElement("div",{className:"row-actions visible",__self:this,__source:{fileName:e,lineNumber:264}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:265}},l.createElement("button",{style:{marginTop:"0.5rem"},type:"button",className:"button button-secondary",onClick:()=>(async(e,t)=>{let{account:l,accounts:a,wallet:i}=await window.DePayWidgets.Connect();ae(l,e,t)})(a,t.blockchain),__self:this,__source:{fileName:e,lineNumber:266}},"Connect Wallet"))))))))),l.createElement("div",{style:{paddingTop:"0.2rem"},__self:this,__source:{fileName:e,lineNumber:276}},l.createElement("button",{onClick:async()=>{let e=await DePayWidgets.Select({what:"token"});I instanceof Array&&I.find((t=>t.blockchain==e.blockchain&&t.address==e.address))||(e.error="Please enter a receiver address!",K(I instanceof Array?I.concat([e]):[e]))},style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-secondary",__self:this,__source:{fileName:e,lineNumber:277}},"Add Token")),l.createElement("div",{style:{paddingTop:"1.6rem",paddingBottom:"1.5rem"},__self:this,__source:{fileName:e,lineNumber:279}},l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:280}},"Each incoming payment will be converted on-the-fly into your selected tokens on the selected blockchains."),l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:283}},"Customers will be able to use any convertible token as means of payment."),l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:286}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:287}},"Payments are sent directly into your wallet."))))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:292}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:293}},"Button"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:296}},l.createElement("div",{style:{display:"inline-block"},__self:this,__source:{fileName:e,lineNumber:297}},l.createElement(DePayButtons.DePayButton,{css:T,label:k,widget:"Payment",configuration:{accept:I},__self:this,__source:{fileName:e,lineNumber:298}})),l.createElement("div",{style:{paddingTop:"1.4rem"},__self:this,__source:{fileName:e,lineNumber:305}},l.createElement("label",{style:{marginBottom:0},__self:this,__source:{fileName:e,lineNumber:306}},l.createElement("span",{className:"",style:{opacity:.7,paddingBottom:"0.8rem",display:"block"},__self:this,__source:{fileName:e,lineNumber:307}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:307}},"Label")),l.createElement("div",{className:"components-base-control",__self:this,__source:{fileName:e,lineNumber:308}},l.createElement("input",{required:"required",type:"text",value:k,onChange:e=>F(e.target.value),__self:this,__source:{fileName:e,lineNumber:309}})))),l.createElement("div",{style:{paddingTop:"1.4rem"},__self:this,__source:{fileName:e,lineNumber:318}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:319}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:319}},"Style")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:320}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:320}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:y,onChange:e=>{b(e.target.value)},__self:this,__source:{fileName:e,lineNumber:320}}),"Background")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:321}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:321}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:p,onChange:e=>{g(e.target.value)},__self:this,__source:{fileName:e,lineNumber:321}}),"Text")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:322}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:322}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"range",value:d,min:"0",max:"36",onChange:e=>{h(e.target.value)},__self:this,__source:{fileName:e,lineNumber:322}}),"Border"))),l.createElement("div",{style:{paddingTop:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:324}},l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:325}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:325}},"Usage"))),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:327}},l.createElement("p",{className:"description",style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:328}},"Search for the ",l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:328}},'"DePay Payments"')," block in the editor and drop the button into layouts, pages and posts.")),l.createElement("img",{style:{maxWidth:"600px",marginBottom:"2rem"},src:"/wp-content/plugins/depay-payments/core/includes/assets/img/button.gif",__self:this,__source:{fileName:e,lineNumber:330}}))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:333}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:334}},"Widget"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:337}},l.createElement("div",{className:"widget-example",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialog ReactDialogOpen",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogRow",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogCell",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogStack active forward",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogStackRow",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogStackCell",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"ReactDialogAnimation",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"Dialog",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"DialogHeader",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"DialogHeaderTitle",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"PaddingTopS PaddingLeftM PaddingRightM",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"FontSizeL TextLeft",__self:this,__source:{fileName:e,lineNumber:338}},"Payment"))),l.createElement("div",{className:"DialogHeaderActionRight PaddingTopS PaddingLeftS PaddingRightS",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("button",{className:"ButtonCircular",title:"Close dialog",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("svg",{className:"CloseIcon Icon",height:"24","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("line",{x1:"18",x2:"6",y1:"6",y2:"18",__self:this,__source:{fileName:e,lineNumber:338}}),l.createElement("line",{x1:"6",x2:"18",y1:"6",y2:"18",__self:this,__source:{fileName:e,lineNumber:338}}))))),l.createElement("div",{className:"DialogBody",__self:this,__source:{fileName:e,lineNumber:338}},l.createElement("div",{className:"PaddingLeftM PaddingRightM PaddingBottomXS",__self:this,__source:{fileName:e,lineNumber:338}},"free"===U&&l.createElement("div",{className:"Card",title:"Change amount",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("div",{className:"CardBody",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("div",{className:"CardBodyWrapper",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("div",{className:"CardTitle",__self:this,__source:{fileName:e,lineNumber:341}},"Amount"),l.createElement("div",{className:"CardText",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("div",{className:"TokenAmountRow",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("span",{className:"TokenAmountCell",__self:this,__source:{fileName:e,lineNumber:341}},te))))),l.createElement("div",{className:"CardAction",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("svg",{className:"ChevronRight Icon",height:"16",viewBox:"0 0 16 16",width:"16",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:341}},l.createElement("path",{d:"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z","fill-rule":"evenodd","stroke-width":"1",__self:this,__source:{fileName:e,lineNumber:341}})))),l.createElement("div",{className:"Card",title:"Change payment",__self:this,__source:{fileName:e,lineNumber:343}},l.createElement("div",{className:"CardImage",__self:this,__source:{fileName:e,lineNumber:343}},l.createElement("img",{className:"js-widget-payment-example-image",src:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",__self:this,__source:{fileName:e,lineNumber:343}})),l.createElement("div",{className:"CardBody",__self:this,__source:{fileName:e,lineNumber:343}},l.createElement("div",{className:"CardBodyWrapper",__self:this,__source:{fileName:e,lineNumber:343}},l.createElement("h2",{className:"CardText",__self:this,__source:{fileName:e,lineNumber:343}},l.createElement("div",{className:"TokenAmountRow",__self:this,__source:{fileName:e,lineNumber:345}},l.createElement("span",{className:"TokenSymbolCell js-widget-example-symbol",__self:this,__source:{fileName:e,lineNumber:345}},"USDT"),l.createElement("span",{className:"TokenAmountCell js-widget-example-amount",__self:this,__source:{fileName:e,lineNumber:345}},Q)),"fix"===U&&l.createElement("div",{class:"TokenAmountRow small grey",__self:this,__source:{fileName:e,lineNumber:348}},l.createElement("span",{class:"TokenSymbolCell",__self:this,__source:{fileName:e,lineNumber:348}},te))))),l.createElement("div",{className:"CardAction",__self:this,__source:{fileName:e,lineNumber:350}},l.createElement("svg",{className:"ChevronRight Icon",height:"16",viewBox:"0 0 16 16",width:"16",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:350}},l.createElement("path",{d:"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z","fill-rule":"evenodd","stroke-width":"1",__self:this,__source:{fileName:e,lineNumber:350}})))))),l.createElement("div",{className:"DialogFooter",__self:this,__source:{fileName:e,lineNumber:350}},l.createElement("div",{className:"PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM",__self:this,__source:{fileName:e,lineNumber:350}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:350}},l.createElement("button",{className:"ButtonPrimary",style:{color:P,backgroundColor:E,borderRadius:`${D}px`},__self:this,__source:{fileName:e,lineNumber:350}},"Pay"))))))))))))),l.createElement("div",{style:{paddingTop:"1.4rem"},__self:this,__source:{fileName:e,lineNumber:351}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:352}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:352}},"Amount")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:353}},l.createElement("select",{value:U,onChange:e=>W(e.target.value),__self:this,__source:{fileName:e,lineNumber:354}},l.createElement("option",{value:"free",__self:this,__source:{fileName:e,lineNumber:355}},"User's can select the amount"),l.createElement("option",{value:"fix",__self:this,__source:{fileName:e,lineNumber:356}},"I want to set a fix amount"))),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:359}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:360}},l.createElement("select",{style:{marginRight:"0.8rem"},value:G,onChange:e=>H(e.target.value),__self:this,__source:{fileName:e,lineNumber:361}},l.createElement("option",{value:"local",__self:this,__source:{fileName:e,lineNumber:362}},"User's local currency"),r.map((t=>l.createElement("option",{value:t,__self:this,__source:{fileName:e,lineNumber:364}},t)))),"Displayed Currency")),"free"===U&&l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:372}},l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:373}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:374}},l.createElement("input",{required:"required",placeholder:"Start Value",style:{marginRight:"0.8rem"},type:"number",value:O,onChange:e=>V(e.target.value),__self:this,__source:{fileName:e,lineNumber:375}}),"Start Value")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:379}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:380}},l.createElement("input",{required:"required",placeholder:"Min Value",style:{marginRight:"0.8rem"},type:"number",value:Z,onChange:e=>Y(e.target.value),__self:this,__source:{fileName:e,lineNumber:381}}),"Min Value")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:385}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:386}},l.createElement("input",{required:"required",placeholder:"Step Value",style:{marginRight:"0.8rem"},type:"number",value:q,onChange:e=>X(e.target.value),__self:this,__source:{fileName:e,lineNumber:387}}),"Step Value"))),"fix"===U&&l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:394}},l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:395}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:396}},l.createElement("select",{style:{marginRight:"0.8rem"},value:$,onChange:e=>j(e.target.value),__self:this,__source:{fileName:e,lineNumber:397}},r.map((t=>l.createElement("option",{value:t,__self:this,__source:{fileName:e,lineNumber:399}},t)))),"Amount Currency")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:406}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"number",value:z,onChange:e=>{J(parseFloat(e.target.value))},__self:this,__source:{fileName:e,lineNumber:408}}),"Fix Amount")))),l.createElement("div",{style:{paddingTop:"1.4rem"},__self:this,__source:{fileName:e,lineNumber:416}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:417}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:417}},"Style")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:418}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:418}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:E,onChange:e=>{v(e.target.value)},__self:this,__source:{fileName:e,lineNumber:418}}),"Primary")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:P,onChange:e=>{C(e.target.value)},__self:this,__source:{fileName:e,lineNumber:419}}),"Button Text")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:420}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:420}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"range",value:D,min:"0",max:"36",onChange:e=>{w(e.target.value)},__self:this,__source:{fileName:e,lineNumber:420}}),"Button Border"))))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:424}},l.createElement("th",{__self:this,__source:{fileName:e,lineNumber:425}}," "),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:426}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:427}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:428}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:429}},n&&l.createElement("button",{style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-secondary",onClick:()=>{},__self:this,__source:{fileName:e,lineNumber:431}},"✓ Settings Saved"),N&&l.createElement("div",{className:"notice inline notice-warning notice-alt",style:{marginBottom:0,maxWidth:"300px"},__self:this,__source:{fileName:e,lineNumber:439}},t([I,"optionalAccess",e=>e.length])>0&&l.createElement("span",{__self:this,__source:{fileName:e,lineNumber:440}},"Please fix all errors before saving!"),0==t([I,"optionalAccess",e=>e.length])&&l.createElement("span",{__self:this,__source:{fileName:e,lineNumber:441}},"Please add at least one token as accepted payment!")),!n&&l.createElement("button",{style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-primary",onClick:()=>(u(!0),void new window.wp.api.models.Settings({DePay_payments_accepted_payments:I,DePay_payments_button_css:T,DePay_payments_button_background_color:y,DePay_payments_button_text_color:p,DePay_payments_button_border_radius:d,DePay_payments_button_label:k,DePay_payments_widget_color_primary:E,DePay_payments_widget_button_border_radius:D,DePay_payments_widget_color_button_text:P,DePay_payments_widget_color_icons:void 0,DePay_payments_widget_color_text:void 0,DePay_payments_widget_css:L,DePay_payments_widget_amount_type:U,DePay_payments_widget_display_currency:G,DePay_payments_widget_amount_free_start:O,DePay_payments_widget_amount_free_min:Z,DePay_payments_widget_amount_free_step:q,DePay_payments_widget_amount_currency:$,DePay_payments_widget_fix_amount:z}).save().then((e=>{u(!1),m(!0)}))),disabled:c||N,__self:this,__source:{fileName:e,lineNumber:445}},"Save Settings"))))))))):null};document.addEventListener("DOMContentLoaded",(function(t){a.render(l.createElement(n,{__self:this,__source:{fileName:e,lineNumber:466}}),document.getElementById("depay-payments-admin"))}))}(window.React,window.ReactDOM)})); +!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="/Users/sebastian/Work/DePay/web3-wordpress-depay-payments/src/admin.js";function t(e){let t,l=e[0],a=1;for(;al.call(t,...e))),t=void 0)}return l}!function(l,a,s){const i=window.React.useEffect,r=window.React.useState,n=["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XCD","XDR","XOF","XPF","YER","ZAR","ZMW","ZWL"],m=function(a){const[s,m]=r(!1),[_,o]=r(!1),[c,u]=r(),[N,f]=r(),[d,h]=r(),[b,y]=r(),[p,g]=r(),[E,v]=r(),[w,D]=r(),[P,C]=r(),[B,x]=r(),[R,S]=r(),[k,T]=r(),[F,A]=r(),[L,M]=r(),[U,W]=r([]),[I,K]=r([]),[G,H]=r(),[O,Y]=r(),[Z,X]=r(),[$,z]=r(),[j,J]=r(),[V,Q]=r(),[q,ee]=r(),[te,le]=r(),[ae,se]=r(),ie=(e,t,l,a)=>{let s=[...U];if(e&&0!==e.length)try{e="solana"===l?new SolanaWeb3js.PublicKey(e).toString():ethers.ethers.utils.getAddress(e),s[t].error=void 0}catch(e){s[t].error="This address is invalid!"}else s[t].error="Please enter a receiver address!";if(a){let e=I.slice();e[t]=!0,K(e)}s[t].receiver=e,W(s)};i((()=>{if(I.length){let e=setTimeout((()=>{K([])}),2e3);return()=>{clearInterval(e)}}}),[I]);return i((()=>{A(`button {\n border-radius: ${d||2}px;\n color: ${p||"#FFFFFF"};\n background: ${b||"#32373c"};\n}`)}),[d,p,b]),i((()=>{M(`.ButtonPrimary { color: ${P||"#FFFFFF"}; border-radius: ${w}px;}`)}),[E,P,w,B,R]),i((()=>{wp.api.loadPromise.then((()=>{(new wp.api.models.Settings).fetch({cache:"no-cache"}).then((e=>{e.DePay_payments_accepted_payments&&W(e.DePay_payments_accepted_payments),T(e.DePay_payments_button_payment_label||"Pay"),A(e.DePay_payments_button_css||"button {\n border-radius: 2px;\n color: #FFFFFF;\n background: #32373c;\n}"),M(e.DePay_payments_widget_css||".ButtonPrimary {border-radius: 2px;}"),y(e.DePay_payments_button_background_color||"#32373c"),g(e.DePay_payments_button_text_color||"#FFFFFF"),h(e.DePay_payments_button_border_radius||"2"),v(e.DePay_payments_widget_color_primary||"#32373c"),D(e.DePay_payments_widget_button_border_radius||"2"),C(e.DePay_payments_widget_color_button_text||"#FFFFFF"),H(e.DePay_payments_widget_amount_type||"fix"),Y(t([e,"access",e=>e.DePay_payments_widget_display_currency,"optionalAccess",e=>e.length])>2?e.DePay_payments_widget_display_currency:"local"),X(e.DePay_payments_widget_amount_free_start||1),z(e.DePay_payments_widget_amount_free_min||1),J(e.DePay_payments_widget_amount_free_step||1),Q(t([e,"access",e=>e.DePay_payments_widget_amount_currency,"optionalAccess",e=>e.length])>0?e.DePay_payments_widget_amount_currency:"USD"),ee(e.DePay_payments_widget_fix_amount||100),x(),S(),o(!0)}))})).catch((()=>{}))}),[]),i((()=>{f(!(U&&U.length&&U.every((e=>e.receiver&&e.receiver.length>0&&void 0===e.error))))}),[U]),i((()=>{m(!1)}),[d,b,p,E,w,P,B,R,k,F,L,U,G,O,Z,$,j,V,q]),i((()=>{"fix"===G?(LocalCurrency.Currency.rate({from:V||"USD",to:"USD"}).then((e=>{le((q/e).toFixed(2))})),LocalCurrency.Currency.rate({from:V||"USD",to:"local"===O?void 0:O}).then((e=>{se(new LocalCurrency.Currency({amount:q/e,code:"local"===O?void 0:O}).toString())}))):(se(new LocalCurrency.Currency({amount:Z||1,code:"local"===O?void 0:O}).toString()),"local"===O||void 0===O||t([O,"optionalAccess",e=>e.length])<3?LocalCurrency.Currency.rate({from:new LocalCurrency.Currency({amount:0}).code,to:"USD"}).then((e=>{le(((Z||1)/e).toFixed(2))})):LocalCurrency.Currency.rate({from:"USD",to:t([O,"optionalAccess",e=>e.length])>=2?O:void 0}).then((e=>{le(((Z||1)*e).toFixed(2))})))}),[O,Z,G,q,V]),_?l.createElement("div",{className:"wrap",__self:this,__source:{fileName:e,lineNumber:219}},l.createElement("h1",{className:"wp-heading-inline",__self:this,__source:{fileName:e,lineNumber:221}},"DePay for Wordpress"),l.createElement("p",{__self:this,__source:{fileName:e,lineNumber:223}},"To view received payments, please open the ",l.createElement("a",{href:"https://app.depay.com/payments",target:"_blank",__self:this,__source:{fileName:e,lineNumber:223}},"DePay App"),"."),l.createElement("table",{className:"form-table",role:"presentation",__self:this,__source:{fileName:e,lineNumber:225}},l.createElement("tbody",{__self:this,__source:{fileName:e,lineNumber:226}},l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:227}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:228}},"Accepted"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:231}},l.createElement("div",{style:{paddingBottom:"1rem"},__self:this,__source:{fileName:e,lineNumber:232}},"Select the tokens that you want to receive:"),U&&U.map(((t,a)=>l.createElement("table",{key:`${a}-${t.blockchain}-${t.symbol}-${I[a]}`,className:"wp-list-table widefat fixed striped table-view-list page",style:{maxWidth:"600px",marginBottom:"0.4rem"},__self:this,__source:{fileName:e,lineNumber:238}},l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:239}},l.createElement("td",{style:{padding:"1rem 1rem 0.4rem 1rem",display:"flex"},__self:this,__source:{fileName:e,lineNumber:240}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:241}},l.createElement("div",{style:{position:"relative",display:"block"},__self:this,__source:{fileName:e,lineNumber:242}},l.createElement("img",{src:t.logo,style:{background:"white",borderRadius:"99px",height:"3rem",width:"3rem"},__self:this,__source:{fileName:e,lineNumber:243}}),l.createElement("img",{src:Web3Blockchains[t.blockchain].logo,style:{position:"absolute",bottom:"2px",right:"0px",width:"20px",height:"20px",border:"1px solid white",borderRadius:"4px",backgroundColor:Web3Blockchains[t.blockchain].logoBackgroundColor},__self:this,__source:{fileName:e,lineNumber:244}}))),l.createElement("div",{style:{paddingLeft:"1rem",paddingBottom:"0.3rem",flex:1},__self:this,__source:{fileName:e,lineNumber:247}},l.createElement("div",{style:{display:"flex",justifyontent:"space-between",fontSize:"1rem"},__self:this,__source:{fileName:e,lineNumber:248}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:249}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:250}},t.symbol)," (",t.name,") on ",Web3Blockchains[t.blockchain].label),l.createElement("div",{className:"row-actions visible",style:{marginLeft:"auto"},__self:this,__source:{fileName:e,lineNumber:252}},l.createElement("span",{className:"delete",__self:this,__source:{fileName:e,lineNumber:253}},l.createElement("a",{href:"#",onClick:()=>(e=>{let t=U.slice();t.splice(e,1),W(t)})(a),__self:this,__source:{fileName:e,lineNumber:254}},"Remove")))),l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:258}},l.createElement("a",{href:Web3Blockchains[t.blockchain].explorerUrlFor({token:t.address}),target:"_blank",__self:this,__source:{fileName:e,lineNumber:259}},((e,t=4)=>{if(void 0===e)return e;let l="";return l+=e.slice(0,e.match("0x")?t+2:t),l+="...",l+=e.slice(e.length-t,e.length),l})(t.address))),l.createElement("div",{style:{paddingTop:".5rem"},__self:this,__source:{fileName:e,lineNumber:261}},l.createElement("label",{style:{marginBottom:0},__self:this,__source:{fileName:e,lineNumber:262}},l.createElement("span",{className:"",style:{opacity:.7,paddingBottom:"1px",display:"block"},__self:this,__source:{fileName:e,lineNumber:263}},"Receiver"),l.createElement("div",{className:"components-base-control",__self:this,__source:{fileName:e,lineNumber:264}},l.createElement("input",{required:"required",style:{width:"100%"},id:"depay-woocommerce-payment-receiver-address",type:"text",value:t.receiver,onChange:e=>ie(e.target.value,a,t.blockchain),__self:this,__source:{fileName:e,lineNumber:265}})),t.error&&l.createElement("div",{className:"notice inline notice-warning notice-alt",style:{marginBottom:0},__self:this,__source:{fileName:e,lineNumber:275}},t.error))),l.createElement("div",{className:"row-actions visible",__self:this,__source:{fileName:e,lineNumber:281}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:282}},!I[a]&&l.createElement("button",{style:{marginTop:"0.5rem"},type:"button",className:"button button-secondary",onClick:()=>(async(e,t)=>{let{account:l,accounts:a,wallet:s}=await window.DePayWidgets.Connect();ie(l,e,t,!0)})(a,t.blockchain),__self:this,__source:{fileName:e,lineNumber:284}},"Connect Wallet"),I[a]&&l.createElement("button",{style:{marginTop:"0.5rem"},type:"button",className:"button button-primary",__self:this,__source:{fileName:e,lineNumber:287}},"✔ wallet connected"))))))))),l.createElement("div",{style:{paddingTop:"0.2rem"},__self:this,__source:{fileName:e,lineNumber:298}},l.createElement("button",{onClick:async()=>{let e=await DePayWidgets.Select({what:"token"});U instanceof Array&&U.find((t=>t.blockchain==e.blockchain&&t.address==e.address))||(e.error="Please enter a receiver address!",W(U instanceof Array?U.concat([e]):[e]))},style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-secondary",__self:this,__source:{fileName:e,lineNumber:299}},"Add Token")),l.createElement("div",{style:{paddingTop:"1.6rem",paddingBottom:"1.5rem"},__self:this,__source:{fileName:e,lineNumber:301}},l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:302}},"Each incoming payment will be converted on-the-fly into your selected tokens on the selected blockchains."),l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:305}},"Users will be able to use any convertible token as means of payment."),l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:308}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:309}},"Payments are sent directly into your wallet."))))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:314}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:315}},"Button"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:318}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:320}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:321}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:321}},"Style")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:322}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:322}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:b,onChange:e=>{y(e.target.value)},__self:this,__source:{fileName:e,lineNumber:322}}),"Background")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:323}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:323}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:p,onChange:e=>{g(e.target.value)},__self:this,__source:{fileName:e,lineNumber:323}}),"Text")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:324}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:324}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"range",value:d,min:"0",max:"36",onChange:e=>{h(e.target.value)},__self:this,__source:{fileName:e,lineNumber:324}}),"Border"))),l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:327}},l.createElement("div",{style:{paddingTop:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:328}},l.createElement("span",{className:"",style:{opacity:.7,paddingBottom:"0.8rem",display:"block"},__self:this,__source:{fileName:e,lineNumber:329}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:329}},"Preview")),l.createElement("div",{style:{display:"inline-block"},__self:this,__source:{fileName:e,lineNumber:330}},l.createElement(DePayButtons.DePayButton,{css:F,label:k,widget:"Payment",configuration:{accept:U},__self:this,__source:{fileName:e,lineNumber:331}}))),l.createElement("div",{style:{paddingTop:"1.4rem"},__self:this,__source:{fileName:e,lineNumber:339}},l.createElement("p",{className:"description",__self:this,__source:{fileName:e,lineNumber:340}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:340}},"Usage"))),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:342}},l.createElement("p",{className:"description",style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:343}},"Search for the ",l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:344}},'"DePay"')," block in the editor and drop the button into layouts, pages and posts.",l.createElement("br",{__self:this,__source:{fileName:e,lineNumber:345}}),"You can individually customize each block for more precise configuration.")),l.createElement("img",{style:{width:"100%",maxWidth:"600px",marginBottom:"2rem"},src:"/wp-content/plugins/depay-payments/core/includes/assets/img/button.gif",__self:this,__source:{fileName:e,lineNumber:349}})))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:354}},l.createElement("th",{scope:"row",__self:this,__source:{fileName:e,lineNumber:355}},"Widget"),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:358}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:359}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:360}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:360}},"Style")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:361}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:361}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:E,onChange:e=>{v(e.target.value)},__self:this,__source:{fileName:e,lineNumber:361}}),"Primary")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:362}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:362}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"color",value:P,onChange:e=>{C(e.target.value)},__self:this,__source:{fileName:e,lineNumber:362}}),"Button Text")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:363}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:363}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"range",value:w,min:"0",max:"36",onChange:e=>{D(e.target.value)},__self:this,__source:{fileName:e,lineNumber:363}}),"Button Border"))),l.createElement("div",{style:{paddingTop:"0.4rem"},__self:this,__source:{fileName:e,lineNumber:366}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:367}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:367}},"Amount Currency")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:368}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:369}},l.createElement("select",{style:{marginRight:"0.8rem"},value:V,onChange:e=>Q(e.target.value),__self:this,__source:{fileName:e,lineNumber:370}},n.map((t=>l.createElement("option",{value:t,__self:this,__source:{fileName:e,lineNumber:372}},t)))),"Currency used to set prices/amounts"))),l.createElement("div",{style:{paddingTop:"0.4rem"},__self:this,__source:{fileName:e,lineNumber:381}},l.createElement("p",{className:"description",style:{paddingBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:382}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:382}},"Display Currency")),l.createElement("div",{style:{marginBottom:"0.8rem"},__self:this,__source:{fileName:e,lineNumber:383}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:384}},l.createElement("select",{style:{marginRight:"0.8rem"},value:O,onChange:e=>Y(e.target.value),__self:this,__source:{fileName:e,lineNumber:385}},l.createElement("option",{value:"local",__self:this,__source:{fileName:e,lineNumber:386}},"User's local currency"),n.map((t=>l.createElement("option",{value:t,__self:this,__source:{fileName:e,lineNumber:388}},t)))),"Currency displayed to users after conversion"))),l.createElement("div",{style:{paddingBottom:"1.0rem"},__self:this,__source:{fileName:e,lineNumber:397}},l.createElement("span",{className:"",style:{opacity:.7,paddingTop:"0.8rem",paddingBottom:"0.4rem",display:"block"},__self:this,__source:{fileName:e,lineNumber:398}},l.createElement("strong",{__self:this,__source:{fileName:e,lineNumber:398}},"Preview")),l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:399}},l.createElement("div",{style:{marginBottom:"1.2rem"},__self:this,__source:{fileName:e,lineNumber:400}},l.createElement("label",{style:{display:"flex",alignItems:"center"},__self:this,__source:{fileName:e,lineNumber:401}},l.createElement("input",{style:{marginRight:"0.6rem"},type:"number",value:q,onChange:e=>{ee(parseFloat(e.target.value))},__self:this,__source:{fileName:e,lineNumber:402}}),"Amount (example)"))),l.createElement("div",{className:"widget-example",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialog ReactDialogOpen",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogRow",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogCell",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogStack active forward",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogStackRow",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogStackCell",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"ReactDialogAnimation",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"Dialog",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"DialogHeader",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"DialogHeaderTitle",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"PaddingTopS PaddingLeftM PaddingRightM",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"FontSizeL TextLeft",__self:this,__source:{fileName:e,lineNumber:407}},"Payment"))),l.createElement("div",{className:"DialogHeaderActionRight PaddingTopS PaddingLeftS PaddingRightS",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("button",{className:"ButtonCircular",title:"Close dialog",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("svg",{className:"CloseIcon Icon",height:"24","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("line",{x1:"18",x2:"6",y1:"6",y2:"18",__self:this,__source:{fileName:e,lineNumber:407}}),l.createElement("line",{x1:"6",x2:"18",y1:"6",y2:"18",__self:this,__source:{fileName:e,lineNumber:407}}))))),l.createElement("div",{className:"DialogBody",__self:this,__source:{fileName:e,lineNumber:407}},l.createElement("div",{className:"PaddingLeftM PaddingRightM PaddingBottomXS",__self:this,__source:{fileName:e,lineNumber:407}},"free"===G&&l.createElement("div",{className:"Card",title:"Change amount",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("div",{className:"CardBody",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("div",{className:"CardBodyWrapper",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("div",{className:"CardTitle",__self:this,__source:{fileName:e,lineNumber:410}},"Amount"),l.createElement("div",{className:"CardText",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("div",{className:"TokenAmountRow",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("span",{className:"TokenAmountCell",__self:this,__source:{fileName:e,lineNumber:410}},ae))))),l.createElement("div",{className:"CardAction",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("svg",{className:"ChevronRight Icon",height:"16",viewBox:"0 0 16 16",width:"16",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:410}},l.createElement("path",{d:"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z","fill-rule":"evenodd","stroke-width":"1",__self:this,__source:{fileName:e,lineNumber:410}})))),l.createElement("div",{className:"Card",title:"Change payment",__self:this,__source:{fileName:e,lineNumber:412}},l.createElement("div",{className:"CardImage",__self:this,__source:{fileName:e,lineNumber:412}},l.createElement("img",{className:"js-widget-payment-example-image",src:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",__self:this,__source:{fileName:e,lineNumber:412}})),l.createElement("div",{className:"CardBody",__self:this,__source:{fileName:e,lineNumber:412}},l.createElement("div",{className:"CardBodyWrapper",__self:this,__source:{fileName:e,lineNumber:412}},l.createElement("h2",{className:"CardText",__self:this,__source:{fileName:e,lineNumber:412}},l.createElement("div",{className:"TokenAmountRow",__self:this,__source:{fileName:e,lineNumber:414}},l.createElement("span",{className:"TokenSymbolCell js-widget-example-symbol",__self:this,__source:{fileName:e,lineNumber:414}},"USDT"),l.createElement("span",{className:"TokenAmountCell js-widget-example-amount",__self:this,__source:{fileName:e,lineNumber:414}},te)),"fix"===G&&l.createElement("div",{class:"TokenAmountRow small grey",__self:this,__source:{fileName:e,lineNumber:417}},l.createElement("span",{class:"TokenSymbolCell",__self:this,__source:{fileName:e,lineNumber:417}},ae))))),l.createElement("div",{className:"CardAction",__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("svg",{className:"ChevronRight Icon",height:"16",viewBox:"0 0 16 16",width:"16",xmlns:"http://www.w3.org/2000/svg",__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("path",{d:"M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z","fill-rule":"evenodd","stroke-width":"1",__self:this,__source:{fileName:e,lineNumber:419}})))))),l.createElement("div",{className:"DialogFooter",__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("div",{className:"PaddingTopXS PaddingRightM PaddingLeftM PaddingBottomM",__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:419}},l.createElement("button",{className:"ButtonPrimary",style:{color:P,backgroundColor:E,borderRadius:`${w}px`},__self:this,__source:{fileName:e,lineNumber:419}},"Pay")))))))))))))))),l.createElement("tr",{__self:this,__source:{fileName:e,lineNumber:423}},l.createElement("th",{__self:this,__source:{fileName:e,lineNumber:424}}," "),l.createElement("td",{__self:this,__source:{fileName:e,lineNumber:425}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:426}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:427}},l.createElement("div",{__self:this,__source:{fileName:e,lineNumber:428}},s&&l.createElement("button",{style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-secondary",onClick:()=>{},__self:this,__source:{fileName:e,lineNumber:430}},"✓ Settings Saved"),N&&l.createElement("div",{className:"notice inline notice-warning notice-alt",style:{marginBottom:0,maxWidth:"300px"},__self:this,__source:{fileName:e,lineNumber:438}},t([U,"optionalAccess",e=>e.length])>0&&l.createElement("span",{__self:this,__source:{fileName:e,lineNumber:439}},"Please fix all errors before saving!"),0==t([U,"optionalAccess",e=>e.length])&&l.createElement("span",{__self:this,__source:{fileName:e,lineNumber:440}},"Please add at least one token!")),!s&&l.createElement("button",{style:{fontSize:"1.1rem",padding:"0 1rem",marginTop:"0.5rem"},type:"button",className:"button button-primary",onClick:()=>(u(!0),void new window.wp.api.models.Settings({DePay_payments_accepted_payments:U,DePay_payments_button_css:F,DePay_payments_button_background_color:b,DePay_payments_button_text_color:p,DePay_payments_button_border_radius:d,DePay_payments_widget_color_primary:E,DePay_payments_widget_button_border_radius:w,DePay_payments_widget_color_button_text:P,DePay_payments_widget_color_icons:void 0,DePay_payments_widget_color_text:void 0,DePay_payments_widget_css:L,DePay_payments_widget_payment_amount_type:G,DePay_payments_widget_display_currency:O,DePay_payments_widget_amount_currency:V}).save().then((e=>{u(!1),m(!0)}))),disabled:c||N,__self:this,__source:{fileName:e,lineNumber:444}},"Save Settings"))))))))):null};document.addEventListener("DOMContentLoaded",(function(t){a.render(l.createElement(m,{__self:this,__source:{fileName:e,lineNumber:465}}),document.getElementById("depay-payments-admin"))}))}(window.React,window.ReactDOM,window.wp.components)})); diff --git a/core/includes/assets/js/block.js b/core/includes/assets/js/block.js index 1a2ab3b..b4f27a8 100644 --- a/core/includes/assets/js/block.js +++ b/core/includes/assets/js/block.js @@ -1,170 +1 @@ -( function (blocks, editor, components, i18n, element, data ) { - - const icon = props => React.createElement("svg", Object.assign({ - xmlns: "http://www.w3.org/2000/svg", - width: 20, - height: 20, - style: { - enableBackground: "new 0 0 20 20" - }, - xmlSpace: "preserve" - }, props), React.createElement("path", { - fill: "#1E1E1E", - d: "M17.4 13.2h-1.1c-.5.6-1 1.1-1.6 1.5H17v1.7H3v-1.7h2.3c-.6-.4-1.1-.9-1.6-1.5H2.6c-.6 0-1.1.5-1.1 1.1v2.5c0 .6.5 1.1 1.1 1.1h14.8c.6 0 1.1-.5 1.1-1.1v-2.5c0-.6-.5-1.1-1.1-1.1z" - }), React.createElement("path", { - fill: "#1E1E1E", - d: "M10 1.9a6.7 6.7 0 1 0 0 13.4 6.7 6.7 0 0 0 0-13.4z" - })); - - const el = wp.element.createElement - const registerBlockType = wp.blocks.registerBlockType - const { Fragment } = wp.element - const { serverSideRender: ServerSideRender } = wp - let isInitialized = false - - registerBlockType( 'depay-payments/block', { - title: 'DePay Payments', - description: 'Embed the DePay Payments button.', - supports: { - align: ["left", "right", "center"], - spacing: { - margin: true, - padding: true - } - }, - attributes: { - align: { - type: "string", - default: "center" - }, - paymentSettings: { - type: 'string', - default: '', - }, - paymentAmountType: { - type: 'string', - default: '', - }, - paymentAmount: { - type: 'string', - default: '', - }, - }, - icon, - keywords: [ "payments", "cryptocurrency", "web3", "DePay", "USDC" ], - category: 'widgets', - example: {}, - edit: function (props) { - console.log('props.attributes', props.attributes) - if(!DePay_payments_accepted_payments || DePay_payments_accepted_payments[0] == '' || !DePay_payments_receiving_wallet_address){ - return wp.element.createElement( - 'a', - { href: "/wp-admin/admin.php?page=depay-payments", target: '_blank' }, - '!!! Please finish your payment configuration !!!' - ); - } - - let accept = DePay_payments_accepted_payments.map((token)=>{ - return { - blockchain: token.blockchain, - token: token.address, - receiver: DePay_payments_receiving_wallet_address - } - }) - - let configuration = { - accept, - style: { - colors: { - primary: DePay_payments_widget_color_primary, - text: DePay_payments_widget_color_text, - buttonText: DePay_payments_widget_color_buttons, - icons: DePay_payments_widget_color_icons - }, - css: DePay_payments_widget_css - }, - } - - return wp.element.createElement( - wp.element.Fragment, - null, - wp.element.createElement( - wp.blockEditor.InspectorControls, - null, - wp.element.createElement( - wp.components.PanelBody, - { title: "Payment" }, - // Settings field (Dropdown) - wp.element.createElement(wp.components.SelectControl, { - label: "Settings", - value: props.attributes.paymentSettings, - options: [ - { label: "Global settings", value: "global" }, - { label: "Custom settings for this block", value: "local" } - ], - onChange: function (value) { - props.setAttributes({ paymentSettings: value, paymentAmountType: props.attributes.paymentAmountType ? props.attributes.paymentAmountType : 'fixed', paymentAmount: props.attributes.paymentAmount ? props.attributes.paymentAmount : '1' }); - } - }), - // Amount Type field (Dropdown) - Visible only if local settings is selected - props.attributes.paymentSettings === "local" && - wp.element.createElement(wp.components.SelectControl, { - label: "Type", - value: props.attributes.paymentAmountType, - options: [ - { label: "I want to set a fixed amount", value: "fixed" }, - { label: "Users can select the amount", value: "free" } - ], - onChange: function (value) { - props.setAttributes({ paymentAmountType: value }); - } - }), - // Payment Amount field - Visible only if "fixed" is selected - props.attributes.paymentSettings === "local" && props.attributes.paymentAmountType === "fixed" && - wp.element.createElement(wp.components.TextControl, { - label: "Amount (" + window?.DePay_payments_widget_amount_currency + ")", - value: props.attributes.paymentAmount, - onChange: function (value) { - props.setAttributes({ paymentAmount: value }); - }, - type: "number", - step: "1" - }) - ) - ), - // New div to display paymentAmountType and paymentAmount - props.attributes.paymentSettings == 'local' ? wp.element.createElement( - 'div', - { - className: 'wp-block-depay-payments-block-settings', - }, - [props.attributes.paymentAmountType == 'fixed' ? new LocalCurrency.Currency({amount: props.attributes.paymentAmount, code: window?.DePay_payments_widget_amount_currency}).toString() : 'Amount selectable'].filter(Boolean).join(' '), - ) : null, - // Payment Button (Placeholder - Pointer Events Disabled) - wp.element.createElement( - 'div', - { style: { pointerEvents: 'none' } }, - wp.element.createElement(DePayButtons.DePayButton, { - label: DePay_payments_button_label, - widget: 'Payment', - css: DePay_payments_button_css, - configuration - }) - ) - ); - - - }, - save: function (props) { - return null - } - }) - -})( - window.wp.blocks, - window.wp.editor, - window.wp.components, - window.wp.i18n, - window.wp.element, - window.wp.data -) +!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="/Users/sebastian/Work/DePay/web3-wordpress-depay-payments/src/block.js";function t(e){let t,n=e[0],a=1;for(;an.call(t,...e))),t=void 0)}return n}!function(n,a,l,o,s,i){wp.element.createElement;const c=wp.blocks.registerBlockType;wp.element,wp,c("depay-payments/block",{title:"DePay",description:"Embed DePay's button.",supports:{align:["left","right","center"],spacing:{margin:!0,padding:!0}},attributes:{align:{type:"string",default:"center"},buttonLabel:{type:"string",default:"Pay"},widgetTitle:{type:"string",default:"Payment"},paymentAmountType:{type:"string",default:"fixed"},paymentAmount:{type:"string",default:"100"},paymentAmountStart:{type:"string",default:"1"},paymentAmountMin:{type:"string",default:"1"},paymentAmountStep:{type:"string",default:"1"}},icon:e=>React.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",width:20,height:20,style:{enableBackground:"new 0 0 20 20"},xmlSpace:"preserve"},e),React.createElement("path",{fill:"#1E1E1E",d:"M17.4 13.2h-1.1c-.5.6-1 1.1-1.6 1.5H17v1.7H3v-1.7h2.3c-.6-.4-1.1-.9-1.6-1.5H2.6c-.6 0-1.1.5-1.1 1.1v2.5c0 .6.5 1.1 1.1 1.1h14.8c.6 0 1.1-.5 1.1-1.1v-2.5c0-.6-.5-1.1-1.1-1.1z"}),React.createElement("path",{fill:"#1E1E1E",d:"M10 1.9a6.7 6.7 0 1 0 0 13.4 6.7 6.7 0 0 0 0-13.4z"})),keywords:["web3","crypto","payments","DePay","USDC"],category:"widgets",example:{},edit:function(n){if(!DePay_payments_accepted_payments||""==DePay_payments_accepted_payments[0])return React.createElement("a",{href:"/wp-admin/admin.php?page=depay-payments",target:"_blank",__self:this,__source:{fileName:e,lineNumber:77}},"Please finish your DePay configuration!");let a=DePay_payments_accepted_payments.map((e=>({blockchain:e.blockchain,token:e.address,receiver:e.receiver}))),l={accept:a,style:{colors:{primary:DePay_payments_widget_color_primary,text:DePay_payments_widget_color_text,buttonText:DePay_payments_widget_color_buttons,icons:DePay_payments_widget_color_icons},css:DePay_payments_widget_css}};return React.createElement(wp.element.Fragment,{__self:this,__source:{fileName:e,lineNumber:105}},React.createElement("div",{className:"wp-block-depay-payments-block-settings-amount",__self:this,__source:{fileName:e,lineNumber:107}},["fixed"==n.attributes.paymentAmountType?new LocalCurrency.Currency({amount:n.attributes.paymentAmount,code:t([window,"optionalAccess",e=>e.DePay_payments_widget_amount_currency])}).toString():"Selectable amount"].filter(Boolean).join(" ")),React.createElement("div",{className:"wp-block-depay-payments-block-settings-label",__self:this,__source:{fileName:e,lineNumber:111}},n.attributes.widgetTitle),React.createElement("div",{style:{pointerEvents:"none"},__self:this,__source:{fileName:e,lineNumber:115}},React.createElement(DePayButtons.DePayButton,{widget:"Payment",label:n.attributes.buttonLabel,configuration:l,css:DePay_payments_button_css,__self:this,__source:{fileName:e,lineNumber:116}})),React.createElement(wp.blockEditor.InspectorControls,{__self:this,__source:{fileName:e,lineNumber:124}},React.createElement(wp.components.PanelBody,{title:"Payment",__self:this,__source:{fileName:e,lineNumber:125}},React.createElement(wp.components.TextControl,{label:"Button Label",value:n.attributes.buttonLabel,onChange:e=>{n.setAttributes({buttonLabel:e})},__self:this,__source:{fileName:e,lineNumber:127}}),React.createElement(wp.components.TextControl,{label:"Widget Title",value:n.attributes.widgetTitle,onChange:e=>{n.setAttributes({widgetTitle:e})},__self:this,__source:{fileName:e,lineNumber:133}}),React.createElement(wp.components.SelectControl,{label:"Amount Type",value:n.attributes.paymentAmountType,options:[{label:"Fixed amount",value:"fixed"},{label:"Users can select the amount",value:"free"}],onChange:e=>{n.setAttributes({paymentAmountType:e})},__self:this,__source:{fileName:e,lineNumber:139}}),"fixed"===n.attributes.paymentAmountType&&React.createElement(wp.components.TextControl,{label:`Amount (${t([window,"optionalAccess",e=>e.DePay_payments_widget_amount_currency])})`,value:n.attributes.paymentAmount,onChange:e=>{n.setAttributes({paymentAmount:e})},__self:this,__source:{fileName:e,lineNumber:151}}),"free"===n.attributes.paymentAmountType&&React.createElement("div",{__self:this,__source:{fileName:e,lineNumber:160}},React.createElement(wp.components.TextControl,{label:`Amount Start (${t([window,"optionalAccess",e=>e.DePay_payments_widget_amount_currency])})`,value:n.attributes.paymentAmountStart,onChange:e=>{n.setAttributes({paymentAmountStart:e})},__self:this,__source:{fileName:e,lineNumber:161}}),React.createElement(wp.components.TextControl,{label:`Amount Min (${t([window,"optionalAccess",e=>e.DePay_payments_widget_amount_currency])})`,value:n.attributes.paymentAmountMin,onChange:e=>{n.setAttributes({paymentAmountMin:e})},__self:this,__source:{fileName:e,lineNumber:166}}),React.createElement(wp.components.TextControl,{label:`Amount Step (${t([window,"optionalAccess",e=>e.DePay_payments_widget_amount_currency])})`,value:n.attributes.paymentAmountStep,onChange:e=>{n.setAttributes({paymentAmountStep:e})},__self:this,__source:{fileName:e,lineNumber:171}})))))},save:function(e){return null}})}(window.wp.blocks,window.wp.editor,window.wp.components,window.wp.i18n,window.wp.element,window.wp.data)})); diff --git a/core/includes/classes/class-depay-payments-admin.php b/core/includes/classes/class-depay-payments-admin.php index e0cd34a..d62a355 100644 --- a/core/includes/classes/class-depay-payments-admin.php +++ b/core/includes/classes/class-depay-payments-admin.php @@ -17,8 +17,8 @@ class DePay_Payments_Admin{ public static function add_admin_menu() { add_menu_page( - 'Payments', - 'Payments', + 'DePay', + 'DePay', 'manage_options', 'depay-payments', array( 'DePay_Payments_Admin', 'admin_page_contents' ), diff --git a/core/includes/classes/class-depay-payments-block.php b/core/includes/classes/class-depay-payments-block.php index 92e3702..a24317a 100644 --- a/core/includes/classes/class-depay-payments-block.php +++ b/core/includes/classes/class-depay-payments-block.php @@ -90,7 +90,7 @@ public static function render_block(array $attributes) { $wrapper_attributes ); - wp_register_style('depay-payments-frontend-style', DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/css/frontend.css', '2.5.1'); + wp_register_style('depay-payments-frontend-style', DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/css/frontend.css', DEPAYPAYMENTS_VERSION); wp_enqueue_style('depay-payments-frontend-style'); wp_register_script( @@ -159,28 +159,20 @@ public static function render_block(array $attributes) { $widgetColorText = get_option( 'DePay_payments_widget_color_text' ); $widgetCSS = preg_replace('~[\r\n]+~', '', get_option( 'DePay_payments_widget_css' )); $buttonCSS = preg_replace('~[\r\n]+~', '', get_option( 'DePay_payments_button_css' )); - $buttonLabel = get_option( 'DePay_payments_button_label' ); + $buttonLabel = isset($attributes['buttonLabel']) ? $attributes['buttonLabel'] : get_option( 'DePay_payments_button_label' ); $receiver = get_option('DePay_payments_receiving_wallet_address'); - $widgetAmountType = get_option( 'DePay_payments_widget_amount_type' ); - $widgetDisplayCurrency = get_option( 'DePay_payments_widget_display_currency' ); - $widgetAmountFreeStart = get_option( 'DePay_payments_widget_amount_free_start' ); - $widgetAmountFreeMin = get_option( 'DePay_payments_widget_amount_free_min' ); - $widgetAmountFreeStep = get_option( 'DePay_payments_widget_amount_free_step' ); + $widgetTitle = isset($attributes['widgetTitle']) ? $attributes['widgetTitle'] : 'Payment'; + $widgetAmountType = isset($attributes['paymentAmountType']) ? $attributes['paymentAmountType'] : get_option( 'DePay_payments_widget_amount_type' ); $widgetAmountCurrency = get_option( 'DePay_payments_widget_amount_currency' ); - $widgetFixAmount = get_option( 'DePay_payments_widget_fix_amount' ); + $widgetDisplayCurrency = get_option( 'DePay_payments_widget_display_currency' ); + $widgetAmountFreeStart = isset($attributes['paymentAmountStart']) ? $attributes['paymentAmountStart'] : get_option( 'DePay_payments_widget_amount_free_start' ); + $widgetAmountFreeMin = isset($attributes['paymentAmountMin']) ? $attributes['paymentAmountMin'] : get_option( 'DePay_payments_widget_amount_free_min' ); + $widgetAmountFreeStep = isset($attributes['paymentAmountStep']) ? $attributes['paymentAmountStep'] : get_option( 'DePay_payments_widget_amount_free_step' ); + $widgetFixAmount = isset($attributes['paymentAmount']) ? $attributes['paymentAmount'] : get_option( 'DePay_payments_widget_fix_amount' ); $accept = []; - if($attributes['paymentSettings'] === 'local' && $attributes['paymentAmountType'] === 'free') { - $widgetAmountType = 'free'; - $widgetAmountFreeStart = "1"; - $widgetAmountFreeMin = "1"; - $widgetAmountFreeStep = "1"; - } else if($attributes['paymentSettings'] === 'local' && $attributes['paymentAmountType'] === 'fixed') { - $widgetAmountType = 'fixed'; - $widgetFixAmount = $attributes['paymentAmount']; - } if(empty(get_option('DePay_payments_accepted_payments'))) { - $html = '!!! Please finish your payment configuration !!!'; + $html = 'Please finish your DePay configuration!'; return sprintf( '
%2$s
', @@ -201,7 +193,7 @@ public static function render_block(array $attributes) { $amount = (object)[]; - if(empty($widgetAmountType) || $widgetAmountType == 'free') { + if($widgetAmountType == 'free') { if(!empty($widgetAmountFreeStart)) { $amount->start = (float)$widgetAmountFreeStart; } if(!empty($widgetAmountFreeMin)) { $amount->min = (float)$widgetAmountFreeMin; } if(!empty($widgetAmountFreeStep)) { $amount->step = (float)$widgetAmountFreeStep; } @@ -210,9 +202,9 @@ public static function render_block(array $attributes) { if(!empty($widgetFixAmount)) { $amount->fix = (float)$widgetFixAmount; } } - $currency = (empty($widgetDisplayCurrency) || $widgetDisplayCurrency === 'local') ? "" : '"currency": "'.$widgetDisplayCurrency.'", '; + $currency = (empty($widgetDisplayCurrency) || $widgetDisplayCurrency === 'local') ? "" : '"currency": "'.$widgetDisplayCurrency.'"'; - $html = '
'; + $html = '
'; return sprintf( '
%2$s
', diff --git a/core/includes/classes/class-depay-payments-link.php b/core/includes/classes/class-depay-payments-link.php index b201e95..e767f90 100644 --- a/core/includes/classes/class-depay-payments-link.php +++ b/core/includes/classes/class-depay-payments-link.php @@ -12,7 +12,7 @@ public static function register() { DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/js/frontend.js', [], DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/js/frontend.js', - '2.5.1', + DEPAYPAYMENTS_VERSION, true ); diff --git a/core/includes/classes/class-depay-payments-run.php b/core/includes/classes/class-depay-payments-run.php index dc41909..23d5024 100644 --- a/core/includes/classes/class-depay-payments-run.php +++ b/core/includes/classes/class-depay-payments-run.php @@ -11,7 +11,7 @@ function __construct(){ private function add_hooks(){ - wp_register_style('depay-payments-frontend-style', DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/css/frontend.css', '2.5.1'); + wp_register_style('depay-payments-frontend-style', DEPAYPAYMENTS_PLUGIN_URL . 'core/includes/assets/css/frontend.css', DEPAYPAYMENTS_VERSION); wp_enqueue_style('depay-payments-frontend-style'); wp_register_script( diff --git a/depay-payments.php b/depay-payments.php index 1b54de4..2742d48 100644 --- a/depay-payments.php +++ b/depay-payments.php @@ -11,10 +11,10 @@ * @package DEPAYPAYMENTS * * @wordpress-plugin - * Plugin Name: DePay Payments + * Plugin Name: DePay for Wordpress * Plugin URI: https://depay.com/plugins/wordpress - * Description: Accept Web3 Payments, supporting various cryptocurrency tokens and wallets: MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL... - * Version: 2.5.1 + * Description: Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI… + * Version: 3.0.0 * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * Author: DePay @@ -26,10 +26,10 @@ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) exit; // Plugin name -define( 'DEPAYPAYMENTS_NAME', 'DePay Payments' ); +define( 'DEPAYPAYMENTS_NAME', 'DePay for Wordpress' ); // Plugin version -define( 'DEPAYPAYMENTS_VERSION', '2.5.1' ); +define( 'DEPAYPAYMENTS_VERSION', '3.0.0' ); // Plugin Root File define( 'DEPAYPAYMENTS_PLUGIN_FILE', __FILE__ ); diff --git a/package.json b/package.json index 01d35cb..309bf6e 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { - "name": "@depay/web3-wordpress-depay-payments", + "name": "@depay/web3-wordpress-depay", "moduleName": "WordpressDePayPayments", - "version": "2.5.1", - "description": "Accept Web3 Payments, supporting various cryptocurrency tokens and wallets: MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL...", + "version": "3.0.0", + "description": "Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…", "main": "./dist/umd/index.js", "module": "./dist/esm/index.js", "files": [ @@ -13,7 +13,7 @@ "release": "git push && node release.js", "update:version": "node update-version.js" }, - "repository": "git@github.com:DePayFi/web3-wordpress-depay-payments.git", + "repository": "git@github.com:DePayFi/web3-wordpress-depay.git", "keywords": [ "Wodpress", "web3", @@ -23,9 +23,9 @@ "author": "depay.com", "license": "MIT", "bugs": { - "url": "https://github.com/DePayFi/web3-wordpress-depay-payments/issues" + "url": "https://github.com/DePayFi/web3-wordpress-depay/issues" }, - "homepage": "https://github.com/DePayFi/web3-wordpress-depay-payments#readme", + "homepage": "https://github.com/DePayFi/web3-wordpress-depay#readme", "private": false, "dependencies": { "@depay/web3-blockchains": "^8.0.3", diff --git a/readme.txt b/readme.txt index 94af988..9970ddf 100644 --- a/readme.txt +++ b/readme.txt @@ -1,26 +1,26 @@ -=== Web3 Cryptocurrency Payments by DePay for Wordpress === +=== Web3 Crypto Payments by DePay for Wordpress === Contributors: depayfi -Tags: payments, cryptocurrency, web3, DePay, USDC +Tags: web3, crypto, payments, DePay, USDC Requires at least: 5.0 -Tested up to: 6.6 -Stable tag: 2.5.1 +Tested up to: 6.7 +Stable tag: 3.0.0 Requires PHP: 5.6 License: GPLv2 License URI: http://www.gnu.org/licenses/gpl-2.0.html -Accept Web3 Payments, supporting various cryptocurrency tokens and wallets: MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL... +Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI… == Description == -**Accept Web3 Payments, supporting various cryptocurrency tokens and wallets: MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL...** +**Accept Web3 Crypto Payments & Donations. Supports various tokens, blockchains and wallets. MetaMask, Phantom, USDC, USDT, ETH, SOL, BSC, POL, xDAI…** -A Block-enabled WordPress plugin for Web3, onchain, cryptocurrency payments supporting various blockchains and tokens (auto-conversion). +A Block-enabled WordPress plugin for Web3, onchain, crypto payments supporting various blockchains and tokens (auto-conversion). = Features = > 📌 Check out the [live demo](https://web3wordpress.xyz "Wordpress Plugin for Crypto P2P payments (live demo) by DePay"). * **Wallet-to-wallet**: Payments are sent directly to your wallet without the need for an intermediary.. * **Automatic token-conversion**: Payments are automatically converted into the token you’ve selected for receiving. -* **Open-source**: You can find our [Web3 Payments Plugin on GitHub](https://github.com/DePayFi/web3-wordpress-depay-payments). +* **Open-source**: You can find our [Web3 Payments Plugin on GitHub](https://github.com/DePayFi/web3-wordpress-depay). * **Block-enabled**: Supports WordPress Gutenberg blocks with customizable payment settings for each block. * **Customize style**: Customize the look of your payment button with your own CSS in the WordPress plugin dashboard. @@ -63,16 +63,16 @@ Start for free. Pay-as-you-go 1.5% per transaction. == Screenshots == -1. Performing a Web3 Payment with DePay. -2. Inline links can also trigger payments. -3. Block-enabled WordPress Plugin for crypto payments. -4. Insert inline payment links. -5. Simple Setup: Connect wallet & configure tokens. -6. Customize the CSS & label of your Web3 payment button. -7. Customize the theme appearance with a live preview. +1. Example of a Payment & Donation Button embedded as Gutenberg Blocks. +2. Configuring accepted payment methods with support for multiple tokens across various blockchains. +3. Customize the style of the payment button. +4. Customize the style of the payment widget. == Changelog == += 2024-12-1 - v3.0.0 = +* merges donation + payment plugin into one: DePay for Wordpress + = 2.5.1 = * fixes solflare handover and some solana rpcs diff --git a/release.js b/release.js new file mode 100644 index 0000000..c0bfb5d --- /dev/null +++ b/release.js @@ -0,0 +1,7 @@ +const package = require('./package.json') +var exec = require('child_process').exec + +exec(`git tag v${package.version}`, function(err, stdout, stderr){ + exec(`git push origin v${package.version}`, function(err, stdout, stderr){ + }) +}) diff --git a/rollup.build.config.js b/rollup.build.config.js index 0ec72e0..22d6c71 100644 --- a/rollup.build.config.js +++ b/rollup.build.config.js @@ -8,6 +8,7 @@ import { terser } from "rollup-plugin-terser" const files = [ 'src/admin.js', + 'src/block.js', ] export default files.map((file)=>{ diff --git a/src/admin.js b/src/admin.js index 0bacdc9..f7ff281 100644 --- a/src/admin.js +++ b/src/admin.js @@ -1,11 +1,11 @@ -(function ( React, ReactDOM ) { +(function ( React, ReactDOM, Components ) { const useEffect = window.React.useEffect const useState = window.React.useState const CURRENCIES = ["AED","AFN","ALL","AMD","ANG","AOA","ARS","AUD","AWG","AZN","BAM","BBD","BDT","BGN","BHD","BIF","BMD","BND","BOB","BRL","BSD","BTN","BWP","BYN","BZD","CAD","CDF","CHF","CLF","CLP","CNY","COP","CRC","CUC","CUP","CVE","CZK","DJF","DKK","DOP","DZD","EGP","ERN","ETB","EUR","FJD","FKP","GBP","GEL","GGP","GHS","GIP","GMD","GNF","GTQ","GYD","HKD","HNL","HRK","HTG","HUF","IDR","ILS","IMP","INR","IQD","IRR","ISK","JEP","JMD","JOD","JPY","KES","KGS","KHR","KMF","KPW","KRW","KWD","KYD","KZT","LAK","LBP","LKR","LRD","LSL","LYD","MAD","MDL","MGA","MKD","MMK","MNT","MOP","MRU","MUR","MVR","MWK","MXN","MYR","MZN","NAD","NGN","NIO","NOK","NPR","NZD","OMR","PAB","PEN","PGK","PHP","PKR","PLN","PYG","QAR","RON","RSD","RUB","RWF","SAR","SBD","SCR","SDG","SEK","SGD","SHP","SLL","SOS","SRD","STD","SVC","SYP","SZL","THB","TJS","TMT","TND","TOP","TRY","TTD","TWD","TZS","UAH","UGX","USD","UYU","UZS","VEF","VND","VUV","WST","XAF","XAG","XCD","XDR","XOF","XPF","YER","ZAR","ZMW","ZWL"] - const DePayPaymentsAdminPage = function(props) { + const DePayWordpressAdminPage = function(props) { const [ saved, setSaved ] = useState(false) const [ settingsAreLoaded, setSettingsAreLoaded ] = useState(false) @@ -23,6 +23,7 @@ const [ buttonCss, setButtonCss ] = useState() const [ widgetCss, setWidgetCss ] = useState() const [ payments, setPayments ] = useState([]) + const [ justConnected, setJustConnected ] = useState([]) const [ amount, setAmount ] = useState() const [ displayedCurrency, setDisplayedCurrency ] = useState() const [ startValue, setStartValue ] = useState() @@ -34,6 +35,15 @@ const [ displayedCurrencyExample, setDisplayedCurrencyExample ] = useState() + const addressEllipsis = (address, display = 4) => { + if(address === undefined) { return address } + let _address = ""; + _address += address.slice(0, address.match('0x') ? display + 2 : display); + _address += '...'; + _address += address.slice(address.length-display, address.length); + return _address; + } + const saveSettings = ()=>{ setIsSaving(true) const settings = new window.wp.api.models.Settings({ @@ -42,20 +52,15 @@ DePay_payments_button_background_color: buttonBackground, DePay_payments_button_text_color: buttonText, DePay_payments_button_border_radius: buttonRadius, - DePay_payments_button_label: label, DePay_payments_widget_color_primary: widgetPrimary, DePay_payments_widget_button_border_radius: widgetButtonRadius, DePay_payments_widget_color_button_text: widgetButtonText, DePay_payments_widget_color_icons: undefined, DePay_payments_widget_color_text: undefined, DePay_payments_widget_css: widgetCss, - DePay_payments_widget_amount_type: amount, + DePay_payments_widget_payment_amount_type: amount, DePay_payments_widget_display_currency: displayedCurrency, - DePay_payments_widget_amount_free_start: startValue, - DePay_payments_widget_amount_free_min: minValue, - DePay_payments_widget_amount_free_step: stepValue, DePay_payments_widget_amount_currency: amountCurrency, - DePay_payments_widget_fix_amount: fixAmount, }) settings.save().then((response) => { @@ -64,7 +69,7 @@ }) } - const setReceivingWalletAddress = (receiver, index, blockchain)=>{ + const setReceivingWalletAddress = (receiver, index, blockchain, connected)=>{ let newPayments = [...payments] if(!receiver || receiver.length === 0) { @@ -82,13 +87,28 @@ } } + if(connected) { + let newJustConnected = justConnected.slice() + newJustConnected[index] = true + setJustConnected(newJustConnected) + } + newPayments[index].receiver = receiver setPayments(newPayments) } + useEffect(()=>{ + if(justConnected.length) { + let timeout = setTimeout(()=>{ + setJustConnected([]) + }, 2000) + return ()=>{clearInterval(timeout)} + } + }, [justConnected]) + const connectWallet = async(index, blockchain)=> { let { account, accounts, wallet } = await window.DePayWidgets.Connect() - setReceivingWalletAddress(account, index, blockchain) + setReceivingWalletAddress(account, index, blockchain, true) } const addToken = async ()=>{ @@ -129,14 +149,9 @@ const settings = new wp.api.models.Settings() settings.fetch({ cache: 'no-cache' }).then((response)=> { if(response.DePay_payments_accepted_payments) { - response.DePay_payments_accepted_payments.forEach((payment)=>{ - if(payment.receiver === undefined && response.DePay_payments_receiving_wallet_address) { - payment.receiver = response.DePay_payments_receiving_wallet_address - } - }) setPayments(response.DePay_payments_accepted_payments) } - setLabel(response.DePay_payments_button_label || 'Pay') + setLabel(response.DePay_payments_button_payment_label || 'Pay') setButtonCss(response.DePay_payments_button_css || "button {\n border-radius: 2px;\n color: #FFFFFF;\n background: #32373c;\n}") setWidgetCss(response.DePay_payments_widget_css || ".ButtonPrimary {border-radius: 2px;}") setButtonBackground(response.DePay_payments_button_background_color || "#32373c") @@ -151,7 +166,7 @@ setMinValue(response.DePay_payments_widget_amount_free_min || 1) setStepValue(response.DePay_payments_widget_amount_free_step || 1) setAmountCurrency(response.DePay_payments_widget_amount_currency?.length > 0 ? response.DePay_payments_widget_amount_currency : 'USD') - setFixAmount(response.DePay_payments_widget_fix_amount || 1) + setFixAmount(response.DePay_payments_widget_fix_amount || 100) setWidgetIconColor() setWidgetText() setSettingsAreLoaded(true) @@ -169,7 +184,6 @@ useEffect(()=>{ - if(amount === 'fix') { LocalCurrency.Currency.rate({ from: amountCurrency || 'USD', to: 'USD' }).then((rate)=>{ @@ -204,7 +218,7 @@ return (
-

DePay Payments

+

DePay for Wordpress

To view received payments, please open the DePay App.

@@ -212,16 +226,16 @@ - Accepted Payments + Accepted
- Select the tokens that you want to receive as payment: + Select the tokens that you want to receive:
{ payments && payments.map((payment, index)=>{ return( - +
@@ -335,27 +356,30 @@ Widget @@ -438,7 +437,7 @@ { isDisabled &&
{ payments?.length > 0 && Please fix all errors before saving! } - { payments?.length == 0 && Please add at least one token as accepted payment! } + { payments?.length == 0 && Please add at least one token! }
} { !saved && @@ -463,7 +462,7 @@ document.addEventListener( "DOMContentLoaded", function(event) { ReactDOM.render( - , + , document.getElementById( 'depay-payments-admin' ) ) }) @@ -471,4 +470,5 @@ })( window.React, window.ReactDOM, + window.wp.components, ); diff --git a/src/block.js b/src/block.js new file mode 100644 index 0000000..9a3e55c --- /dev/null +++ b/src/block.js @@ -0,0 +1,196 @@ +( function (blocks, editor, components, i18n, element, data ) { + + const icon = props => React.createElement("svg", Object.assign({ + xmlns: "http://www.w3.org/2000/svg", + width: 20, + height: 20, + style: { + enableBackground: "new 0 0 20 20" + }, + xmlSpace: "preserve" + }, props), React.createElement("path", { + fill: "#1E1E1E", + d: "M17.4 13.2h-1.1c-.5.6-1 1.1-1.6 1.5H17v1.7H3v-1.7h2.3c-.6-.4-1.1-.9-1.6-1.5H2.6c-.6 0-1.1.5-1.1 1.1v2.5c0 .6.5 1.1 1.1 1.1h14.8c.6 0 1.1-.5 1.1-1.1v-2.5c0-.6-.5-1.1-1.1-1.1z" + }), React.createElement("path", { + fill: "#1E1E1E", + d: "M10 1.9a6.7 6.7 0 1 0 0 13.4 6.7 6.7 0 0 0 0-13.4z" + })); + + const el = wp.element.createElement + const registerBlockType = wp.blocks.registerBlockType + const { Fragment } = wp.element + const { serverSideRender: ServerSideRender } = wp + let isInitialized = false + + registerBlockType( 'depay-payments/block', { + title: 'DePay', + description: "Embed DePay's button.", + supports: { + align: ["left", "right", "center"], + spacing: { + margin: true, + padding: true + } + }, + attributes: { + align: { + type: "string", + default: "center" + }, + buttonLabel: { + type: 'string', + default: 'Pay', + }, + widgetTitle: { + type: 'string', + default: 'Payment', + }, + paymentAmountType: { + type: 'string', + default: 'fixed', + }, + paymentAmount: { + type: 'string', + default: '100', + }, + paymentAmountStart: { + type: 'string', + default: '1', + }, + paymentAmountMin: { + type: 'string', + default: '1', + }, + paymentAmountStep: { + type: 'string', + default: '1', + }, + }, + icon, + keywords: [ "web3", "crypto", "payments", "DePay", "USDC" ], + category: 'widgets', + example: {}, + edit: function (props) { + + if(!DePay_payments_accepted_payments || DePay_payments_accepted_payments[0] == ''){ + return( + + Please finish your DePay configuration! + + ) + } + + let accept = DePay_payments_accepted_payments.map((configuration)=>{ + return { + blockchain: configuration.blockchain, + token: configuration.address, + receiver: configuration.receiver + } + }) + + let configuration = { + accept, + style: { + colors: { + primary: DePay_payments_widget_color_primary, + text: DePay_payments_widget_color_text, + buttonText: DePay_payments_widget_color_buttons, + icons: DePay_payments_widget_color_icons + }, + css: DePay_payments_widget_css + }, + } + + return( + + +
+ { [ props.attributes.paymentAmountType == 'fixed' ? new LocalCurrency.Currency({ amount: props.attributes.paymentAmount, code: window?.DePay_payments_widget_amount_currency }).toString() : 'Selectable amount'].filter(Boolean).join(' ') } +
+ +
+ { props.attributes.widgetTitle } +
+ +
+ +
+ + + + + { props.setAttributes({ buttonLabel: value }) }} + /> + + { props.setAttributes({ widgetTitle: value }) }} + /> + + { props.setAttributes({ paymentAmountType: value }) }} + /> + + { + props.attributes.paymentAmountType === 'fixed' && + { props.setAttributes({ paymentAmount: value }) }} + /> + } + + { + props.attributes.paymentAmountType === 'free' && +
+ { props.setAttributes({ paymentAmountStart: value }) }} + /> + { props.setAttributes({ paymentAmountMin: value }) }} + /> + { props.setAttributes({ paymentAmountStep: value }) }} + /> +
+ } + +
+
+
+ ) + }, + save: function (props) { + return null + } + }) + +})( + window.wp.blocks, + window.wp.editor, + window.wp.components, + window.wp.i18n, + window.wp.element, + window.wp.data +) diff --git a/update-version.js b/update-version.js new file mode 100644 index 0000000..dda663e --- /dev/null +++ b/update-version.js @@ -0,0 +1,30 @@ +const replace = require('replace-in-file') +const prompt = require('prompt') +const package = require('./package.json') +const openExplorer = require('open-file-explorer') + +console.log(`Enter new version (current version ${package.version})`) +prompt.start() +prompt.get(['version'], async (err, result)=> { + if(!result.version) { return } + if(!result.version.match(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/)){ + console.log('WRONG VERSION FROMAT (see: https://semver.org)') + return + } + + const date = new Date() + var month = date.getUTCMonth() + 1 + var day = date.getUTCDate() + var year = date.getUTCFullYear() + + await replace({ files: './package.json', from: `"version": "${package.version}",`, to: `"version": "${result.version}",`}) + await replace({ files: './block.json', from: `"version": "${package.version}",`, to: `"version": "${result.version}",`}) + await replace({ files: './readme.txt', from: `Stable tag: ${package.version}`, to: `Stable tag: ${result.version}`}) + await replace({ files: './readme.txt', from: `== Changelog ==`, to: `== Changelog ==\n\n= ${year}-${month}-${day} - v${result.version} =\n*`}) + await replace({ files: './depay-payments.php', from: `define( 'DEPAYPAYMENTS_VERSION', '${package.version}' );`, to: `define( 'DEPAYPAYMENTS_VERSION', '${result.version}' );`}) + await replace({ files: './depay-payments.php', from: `Version: ${package.version}`, to: `Version: ${result.version}`}) + + console.log('Dont forget to add a changelog entry!') + openExplorer('./readme.txt') +}) +
@@ -241,6 +255,9 @@
+
- + { !justConnected[index] && + + } + { justConnected[index] && + + }
@@ -281,7 +303,7 @@ Each incoming payment will be converted on-the-fly into your selected tokens on the selected blockchains.

- Customers will be able to use any convertible token as means of payment. + Users will be able to use any convertible token as means of payment.

Payments are sent directly into your wallet. @@ -294,40 +316,39 @@ Button

-
- -
-
- -
-
+ +

Style

-
-

Usage

-
-
-

Search for the "DePay Payments" block in the editor and drop the button into layouts, pages and posts.

+ +
+
+ Preview +
+ +
+
+
+

Usage

+
+
+

+ Search for the "DePay" block in the editor and drop the button into layouts, pages and posts. +
+ You can individually customize each block for more precise configuration. +

+
+
- +
-
Payment
- { - amount === 'free' && -
Amount
{ displayedCurrencyExample }
- } -

+
+

Style

+
+
+
+
-
USDT{usdValue}
- { - amount === 'fix' && -
{ displayedCurrencyExample }
- } -

-
-

Amount

+
+

Amount Currency

- +
+
+ +
+

Display Currency

- { amount === 'free' && -
-
- -
-
- -
-
- -
+
+ +
+ Preview +
+
+
+
+
Payment
+ { + amount === 'free' && +
Amount
{ displayedCurrencyExample }
} - { amount === 'fix' && -
-
- -
-
- -
-
+

+ +
USDT{usdValue}
+ { + amount === 'fix' && +
{ displayedCurrencyExample }
} - -

-
-

Style

-
-
-
+