WooCommerce Stripe Payment Gateway - Version 4.0.0

Version Description

  • 2017-01-08 =
  • Add - Stripe Elements Credit Card form for PCI compliance.
  • Add - Stripe Sources.
  • Add - SEPA Direct Debit.
  • Add - Bancontact.
  • Add - Giropay.
  • Add - Sofort.
  • Add - iDeal.
  • Add - Bitcoin.
  • Add - P24.
  • Add - Alipay.
Download this release

Release Info

Developer mattyza
Plugin Icon 128x128 WooCommerce Stripe Payment Gateway
Version 4.0.0
Comparing to
See all releases

Code changes from version 3.2.3 to 4.0.0

Files changed (45) hide show
  1. apple-developer-merchantid-domain-association +0 -0
  2. assets/css/stripe-apple-pay.css +0 -1
  3. assets/css/stripe-apple-pay.less +0 -114
  4. assets/css/stripe-paymentfonts.css +4 -0
  5. assets/images/bitcoin.png +0 -0
  6. assets/images/bitcoin.svg +0 -7
  7. assets/images/diners.png +0 -0
  8. assets/images/p24.svg +1 -0
  9. assets/js/payment-request.js +0 -387
  10. assets/js/payment-request.min.js +0 -1
  11. assets/js/stripe-admin.js +4 -30
  12. assets/js/stripe-admin.min.js +1 -1
  13. assets/js/stripe-apple-pay-single.js +0 -251
  14. assets/js/stripe-apple-pay-single.min.js +0 -1
  15. assets/js/stripe-apple-pay.js +0 -183
  16. assets/js/stripe-apple-pay.min.js +0 -1
  17. assets/js/stripe-checkout.js +0 -154
  18. assets/js/stripe-checkout.min.js +0 -1
  19. assets/js/stripe-payment-request.js +498 -0
  20. assets/js/stripe-payment-request.min.js +1 -0
  21. assets/js/stripe.js +665 -82
  22. assets/js/stripe.min.js +1 -1
  23. assets/paymentfonts/paymentfont-webfont.eot +0 -0
  24. assets/paymentfonts/paymentfont-webfont.svg +148 -0
  25. assets/paymentfonts/paymentfont-webfont.ttf +0 -0
  26. assets/paymentfonts/paymentfont-webfont.woff +0 -0
  27. changelog.txt +11 -1
  28. includes/abstracts/abstract-wc-stripe-payment-gateway.php +634 -0
  29. includes/admin/stripe-alipay-settings.php +50 -0
  30. includes/admin/stripe-bancontact-settings.php +50 -0
  31. includes/admin/stripe-bitcoin-settings.php +50 -0
  32. includes/admin/stripe-giropay-settings.php +50 -0
  33. includes/admin/stripe-ideal-settings.php +50 -0
  34. includes/admin/stripe-p24-settings.php +46 -0
  35. includes/admin/stripe-sepa-settings.php +50 -0
  36. includes/{settings-stripe.php → admin/stripe-settings.php} +59 -28
  37. includes/admin/stripe-sofort-settings.php +50 -0
  38. includes/class-wc-gateway-stripe.php +290 -503
  39. includes/class-wc-stripe-api.php +83 -33
  40. includes/class-wc-stripe-apple-pay.php +0 -1148
  41. includes/class-wc-stripe-customer.php +82 -57
  42. includes/class-wc-stripe-helper.php +252 -0
  43. includes/class-wc-stripe-logger.php +52 -0
  44. includes/class-wc-stripe-order-handler.php +496 -0
  45. includes/class-wc-stripe-payment-request.php +0 -23
apple-developer-merchantid-domain-association CHANGED
File without changes
assets/css/stripe-apple-pay.css DELETED
@@ -1 +0,0 @@
1
- .apple-pay-button,.apple-pay-button-checkout-separator,.apple-pay-button-wrapper{display:none}@supports (-webkit-appearance:-apple-pay-button){.apple-pay-button-wrapper{display:block;margin-bottom:20px}.apple-pay-button{background-size:100% 100%;background-origin:content-box;background-repeat:no-repeat;width:100%;height:44px;padding:10px 0;border-radius:10px}.apple-pay-button-checkout-separator{text-transform:uppercase;text-align:center;font-size:1.2rem}.woocommerce-checkout .apple-pay-button-wrapper{text-align:center}.woocommerce-checkout .apple-pay-button{height:50px;margin:0 auto}.woocommerce-checkout .apple-pay-button-checkout-separator{border-bottom:1px solid #EBEBEB;padding-bottom:20px}.single-product div.product form.cart .apple-pay-button,.single-product div.product form.cart .quantity,.single-product div.product form.cart .quantity~.button{margin-bottom:10px}.single-product div.product form.cart .quantity{width:100%;margin-right:0}.single-product div.product form.cart .quantity input,.single-product div.product form.cart .quantity~.button{width:100%}.single-product div.product form.cart .apple-pay-button-wrapper{display:inline;margin-bottom:0}@media (min-width:768px){.woocommerce-checkout .apple-pay-button{width:30%}.single-product div.product form.cart .apple-pay-button,.single-product div.product form.cart .quantity,.single-product div.product form.cart .quantity~.button{margin-bottom:0}.single-product div.product form.cart .quantity{width:auto;margin-right:10px}.single-product div.product form.cart .quantity input{width:70px}.single-product div.product form.cart .quantity~.button{float:none;width:auto}.single-product div.product form.cart .apple-pay-button{float:left;max-width:20%;margin-right:10px}}}
 
assets/css/stripe-apple-pay.less DELETED
@@ -1,114 +0,0 @@
1
- .apple-pay-button-wrapper,
2
- .apple-pay-button,
3
- .apple-pay-button-checkout-separator {
4
- display: none;
5
- }
6
-
7
- @supports (-webkit-appearance: -apple-pay-button) {
8
- .apple-pay-button-wrapper {
9
- display: block;
10
- margin-bottom: 20px;
11
- }
12
-
13
- .apple-pay-button {
14
- background-size: 100% 100%;
15
- background-origin: content-box;
16
- background-repeat: no-repeat;
17
- width: 100%;
18
- height: 44px;
19
- padding: 10px 0;
20
- border-radius: 10px;
21
- }
22
-
23
- .apple-pay-button-checkout-separator {
24
- text-transform: uppercase;
25
- text-align: center;
26
- font-size: 1.2rem;
27
- }
28
-
29
- .woocommerce-checkout {
30
- .apple-pay-button-wrapper {
31
- text-align: center;
32
- }
33
-
34
- .apple-pay-button {
35
- height: 50px;
36
- margin: 0 auto;
37
- }
38
-
39
- .apple-pay-button-checkout-separator {
40
- border-bottom: 1px solid #EBEBEB;
41
- padding-bottom: 20px;
42
- }
43
- }
44
-
45
- .single-product {
46
- div.product {
47
- form.cart {
48
- .quantity,
49
- .quantity ~ .button,
50
- .apple-pay-button {
51
- margin-bottom: 10px;
52
- }
53
-
54
- .quantity {
55
- width: 100%;
56
- margin-right: 0;
57
-
58
- input {
59
- width: 100%;
60
- }
61
- }
62
-
63
- .quantity ~ .button {
64
- width: 100%;
65
- }
66
-
67
- .apple-pay-button-wrapper {
68
- display: inline;
69
- margin-bottom: 0;
70
- }
71
- }
72
- }
73
- }
74
-
75
- @media ( min-width: 768px ) {
76
- .woocommerce-checkout {
77
- .apple-pay-button {
78
- width: 30%;
79
- }
80
- }
81
-
82
- .single-product {
83
- div.product {
84
- form.cart {
85
- .quantity,
86
- .quantity ~ .button,
87
- .apple-pay-button {
88
- margin-bottom: 0;
89
- }
90
-
91
- .quantity {
92
- width: auto;
93
- margin-right: 10px;
94
-
95
- input {
96
- width: 70px;
97
- }
98
- }
99
-
100
- .quantity ~ .button {
101
- float: none;
102
- width: auto;
103
- }
104
-
105
- .apple-pay-button {
106
- float: left;
107
- max-width: 20%;
108
- margin-right: 10px;
109
- }
110
- }
111
- }
112
- }
113
- }
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/css/stripe-paymentfonts.css ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /*!
2
+ * PaymentFont 1.2.5 by @AMPoellmann - http://paymentfont.io
3
+ * License - http://paymentfont.io/#license (Font: SIL OFL 1.1, CSS: MIT License)
4
+ */@font-face{font-family:PaymentFont;src:url(../paymentfonts/paymentfont-webfont.eot);src:url(../paymentfonts/paymentfont-webfont.eot?#iefix) format('embedded-opentype'),url(../paymentfonts/paymentfont-webfont.woff) format('woff2'),url(../paymentfonts/paymentfont-webfont.woff) format('woff'),url(../paymentfonts/paymentfont-webfont.ttf) format('truetype'),url(../paymentfonts/paymentfont-webfont.svg#paymentfont-webfont) format('svg');font-weight:400;font-style:normal}.stripe-pf{display:inline-block;font:normal normal normal 14px/1 PaymentFont;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-size:1.2em}.stripe-pf-right{float:right}.stripe-pf-left{float:left}.stripe-pf-lg{font-size:1.33333333em;line-height:.75em;vertical-align:-15%}.stripe-pf-2x{font-size:2em}.stripe-pf-3x{font-size:3em}.stripe-pf-4x{font-size:4em}.stripe-pf-5x{font-size:5em}.stripe-pf-amazon:before{content:"\f000"}.stripe-pf-american-express:before{content:"\f001"}.stripe-pf-american-express-alt:before{content:"\f002"}.stripe-pf-atm:before{content:"\f003"}.stripe-pf-bankomat:before{content:"\f004"}.stripe-pf-bank-transfer:before{content:"\f005"}.stripe-pf-bitcoin:before{content:"\f006"}.stripe-pf-bitcoin-sign:before{content:"\f007"}.stripe-pf-braintree:before{content:"\f008"}.stripe-pf-btc:before{content:"\f009"}.stripe-pf-card:before{content:"\f00a"}.stripe-pf-carta-si:before{content:"\f00b"}.stripe-pf-cash:before{content:"\f00c"}.stripe-pf-cash-on-delivery:before{content:"\f00d"}.stripe-pf-cb:before{content:"\f00e"}.stripe-pf-cirrus:before{content:"\f00f"}.stripe-pf-cirrus-alt:before{content:"\f010"}.stripe-pf-clickandbuy:before{content:"\f011"}.stripe-pf-credit-card:before{content:"\f012"}.stripe-pf-diners:before{content:"\f013"}.stripe-pf-discover:before{content:"\f014"}.stripe-pf-ec:before{content:"\f015"}.stripe-pf-eps:before{content:"\f016"}.stripe-pf-eur:before{content:"\f017"}.stripe-pf-facture:before{content:"\f018"}.stripe-pf-fattura:before{content:"\f019"}.stripe-pf-flattr:before{content:"\f01a"}.stripe-pf-giropay:before{content:"\f01b"}.stripe-pf-google-wallet:before{content:"\f01c"}.stripe-pf-google-wallet-alt:before{content:"\f01d"}.stripe-pf-gpb:before{content:"\f01e"}.stripe-pf-gratipay:before{content:"\f01f"}.stripe-pf-ideal:before{content:"\f020"}.stripe-pf-ils:before{content:"\f021"}.stripe-pf-inr:before{content:"\f022"}.stripe-pf-invoice:before{content:"\f023"}.stripe-pf-invoice-sign:before{content:"\f024"}.stripe-pf-invoice-sign-alt:before{content:"\f025"}.stripe-pf-invoice-sign-alt-o:before{content:"\f026"}.stripe-pf-invoice-sign-o:before{content:"\f027"}.stripe-pf-jcb:before{content:"\f028"}.stripe-pf-jpy:before{content:"\f029"}.stripe-pf-krw:before{content:"\f02a"}.stripe-pf-maestro:before{content:"\f02b"}.stripe-pf-maestro-alt:before{content:"\f02c"}.stripe-pf-mastercard:before{content:"\f02d"}.stripe-pf-mastercard-alt:before{content:"\f02e"}.stripe-pf-mastercard-securecode:before{content:"\f02f"}.stripe-pf-ogone:before{content:"\f030"}.stripe-pf-paybox:before{content:"\f031"}.stripe-pf-paylife:before{content:"\f032"}.stripe-pf-paypal:before{content:"\f033"}.stripe-pf-paypal-alt:before{content:"\f034"}.stripe-pf-paysafecard:before{content:"\f035"}.stripe-pf-postepay:before{content:"\f036"}.stripe-pf-quick:before{content:"\f037"}.stripe-pf-rechnung:before{content:"\f038"}.stripe-pf-ripple:before{content:"\f039"}.stripe-pf-rub:before{content:"\f03a"}.stripe-pf-skrill:before{content:"\f03b"}.stripe-pf-sofort:before{content:"\f03c"}.stripe-pf-square:before{content:"\f03d"}.stripe-pf-stripe:before{content:"\f03e"}.stripe-pf-truste:before{content:"\f03f"}.stripe-pf-try:before{content:"\f040"}.stripe-pf-unionpay:before{content:"\f041"}.stripe-pf-usd:before{content:"\f042"}.stripe-pf-verified-by-visa:before{content:"\f043"}.stripe-pf-verisign:before{content:"\f044"}.stripe-pf-visa:before{content:"\f045"}.stripe-pf-visa-electron:before{content:"\f046"}.stripe-pf-western-union:before{content:"\f047"}.stripe-pf-western-union-alt:before{content:"\f048"}.stripe-pf-wirecard:before{content:"\f049"}.stripe-pf-sepa:before{content:"\f04a"}.stripe-pf-sepa-alt:before{content:"\f04b"}.stripe-pf-apple-pay:before{content:"\f04c"}.stripe-pf-interac:before{content:"\f04d"}.stripe-pf-paymill:before{content:"\f04e"}.stripe-pf-dankort:before{content:"\f04f"}.stripe-pf-bancontact-mister-cash:before{content:"\f050"}.stripe-pf-moip:before{content:"\f051"}.stripe-pf-pagseguro:before{content:"\f052"}.stripe-pf-cash-on-pickup:before{content:"\f053"}.stripe-pf-sage:before{content:"\f054"}.stripe-pf-elo:before{content:"\f055"}.stripe-pf-elo-alt:before{content:"\f056"}.stripe-pf-payu:before{content:"\f057"}.stripe-pf-mercado-pago:before{content:"\f058"}.stripe-pf-mercado-pago-sign:before{content:"\f059"}.stripe-pf-payshop:before{content:"\f05a"}.stripe-pf-multibanco:before{content:"\f05b"}.stripe-pf-gratipay-sign:before{content:"\f05c"}.stripe-pf-six:before{content:"\f05d"}.stripe-pf-cashcloud:before{content:"\f05e"}.stripe-pf-interac-alt:before{content:"\f05f"}.stripe-pf-klarna:before{content:"\f060"}.stripe-pf-bitpay:before{content:"\f061"}.stripe-pf-venmo:before{content:"\f062"}.stripe-pf-visa-debit:before{content:"\f063"}.stripe-pf-alipay:before{content:"\f064"}.stripe-pf-diners-alt:before{content:"\f065"}.stripe-pf-hipercard:before{content:"\f066"}.stripe-pf-skrill-alt:before{content:"\f067"}.stripe-pf-shopify:before{content:"\f068"}.stripe-pf-direct-debit:before{content:"\f069"}.stripe-pf-sodexo:before{content:"\f06a"}.stripe-pf-bpay:before{content:"\f06b"}.stripe-pf-contactless:before{content:"\f06c"}.stripe-pf-contactless-alt:before{content:"\f06d"}.stripe-pf-eth:before{content:"\f06e"}.stripe-pf-ltc:before{content:"\f06f"}.stripe-pf-visa-pay:before{content:"\f070"}.stripe-pf-wechat-pay:before{content:"\f071"}.stripe-pf-amazon-pay:before{content:"\f072"}.stripe-pf-amazon-pay-alt:before{content:"\f073"}.stripe-pf-p24{background-image:url(../images/p24.svg);background-repeat:no-repeat;width:2.5em;height:2.5em}
assets/images/bitcoin.png DELETED
Binary file
assets/images/bitcoin.svg DELETED
@@ -1,7 +0,0 @@
1
- <!-- Created with Inkscape (http://www.inkscape.org/) -->
2
- <svg xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://www.w3.org/2000/svg" height="64" width="64" version="1.1" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">
3
- <g transform="translate(0.00630876,-0.00301984)">
4
- <path fill="#f7931a" d="m63.033,39.744c-4.274,17.143-21.637,27.576-38.782,23.301-17.138-4.274-27.571-21.638-23.295-38.78,4.272-17.145,21.635-27.579,38.775-23.305,17.144,4.274,27.576,21.64,23.302,38.784z"/>
5
- <path fill="#FFF" d="m46.103,27.444c0.637-4.258-2.605-6.547-7.038-8.074l1.438-5.768-3.511-0.875-1.4,5.616c-0.923-0.23-1.871-0.447-2.813-0.662l1.41-5.653-3.509-0.875-1.439,5.766c-0.764-0.174-1.514-0.346-2.242-0.527l0.004-0.018-4.842-1.209-0.934,3.75s2.605,0.597,2.55,0.634c1.422,0.355,1.679,1.296,1.636,2.042l-1.638,6.571c0.098,0.025,0.225,0.061,0.365,0.117-0.117-0.029-0.242-0.061-0.371-0.092l-2.296,9.205c-0.174,0.432-0.615,1.08-1.609,0.834,0.035,0.051-2.552-0.637-2.552-0.637l-1.743,4.019,4.569,1.139c0.85,0.213,1.683,0.436,2.503,0.646l-1.453,5.834,3.507,0.875,1.439-5.772c0.958,0.26,1.888,0.5,2.798,0.726l-1.434,5.745,3.511,0.875,1.453-5.823c5.987,1.133,10.489,0.676,12.384-4.739,1.527-4.36-0.076-6.875-3.226-8.515,2.294-0.529,4.022-2.038,4.483-5.155zm-8.022,11.249c-1.085,4.36-8.426,2.003-10.806,1.412l1.928-7.729c2.38,0.594,10.012,1.77,8.878,6.317zm1.086-11.312c-0.99,3.966-7.1,1.951-9.082,1.457l1.748-7.01c1.982,0.494,8.365,1.416,7.334,5.553z"/>
6
- </g>
7
- </svg>
 
 
 
 
 
 
 
assets/images/diners.png DELETED
Binary file
assets/images/p24.svg ADDED
@@ -0,0 +1 @@
 
1
+ <svg id="Warstwa_1" data-name="Warstwa 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 672"><defs><style>.cls-1,.cls-2{fill:#5a5a5a;}.cls-1{fill-rule:evenodd;}</style></defs><title>Artboard 6</title><polygon class="cls-1" points="409.59 384.9 566.05 384.69 560.33 420.29 429.5 545.2 539.27 544.98 532.9 583.43 371.23 583.46 377.98 543.81 503.39 423.71 403.35 423.7 409.59 384.9 409.59 384.9"/><path class="cls-1" d="M238.54,324c-3.43-3.62-8.27-6.41-13.73-8.57a94.64,94.64,0,0,0-18.17-4.85,170.2,170.2,0,0,0-20.77-2.21c-5-.23-8.16-.18-8.16-.18H58.42L12.67,583.45l42.59,0,16.84-102,82.58.36s32.15,1.26,55-10.81,28.87-39.56,28.87-39.56,2.51-10.19,4.56-22.64c2.25-13.67,4.56-30.08,5.76-38.82.53-3.83.84-6.19.84-6.19a44.28,44.28,0,0,0,.61-7.23,49.59,49.59,0,0,0-5.62-24.11A40.3,40.3,0,0,0,238.54,324ZM205.65,372.6c0,.46-3.78,22.6-8.83,48.79-1.93,10-9.59,15.4-18.42,17.27-14.58,3.08-30.27,2.51-30.27,2.51l-69-.18,15.16-91.48,62.54.17s4.23-.09,10.14,0a214.09,214.09,0,0,1,22.9,1.4c6.25.82,11.35,2.11,12.92,4.09a17.07,17.07,0,0,1,3.22,9A33.84,33.84,0,0,1,205.65,372.6Z"/><polygon class="cls-1" points="778.09 308.15 819.06 308.12 773.16 583.51 732.09 583.45 778.09 308.15 778.09 308.15"/><polygon class="cls-1" points="996.95 384.86 1036.24 384.82 1050.12 524.55 1110.56 384.57 1159.06 384.7 1173.39 525.13 1233.84 384.84 1274.61 384.8 1187.97 583.34 1139.57 583.35 1125.62 444.32 1064.47 583.35 1016.89 583.48 996.95 384.86 996.95 384.86"/><path class="cls-2" d="M702.39,386.53c-11.48-3.74-31.42-4.48-48.25-4.28-16.31.2-23.79,1-29.88,2.28,0,0-29,4.16-45.49,24.56s-21.38,65-21.38,65-9.78,49.34-6.92,65.78,8,31.68,26.61,38.83a100.77,100.77,0,0,0,34.44,6.83s33.2,2.61,58.22-3.31a71.29,71.29,0,0,0,38.21-23.52A99.8,99.8,0,0,0,718,542.13a76,76,0,0,0,5.66-16.1l2.62-10.66-42.53.06s-2.34,28.07-25.28,30.66-35.23,1.61-39.67,1.44-29,.85-27-19.68c0-.28,0-.68.06-1.26,1.14-23.43,3.74-29.5,3.74-29.5l133.52-.38,5.7-33C741.35,426.22,736.59,397.69,702.39,386.53Zm-8.9,72.39-91.5-.1,3.64-14.52s3.18-11.36,9.52-16.21,14.46-5.67,22.1-6.41,27.88-2.17,44.39,1.23c5.48,1.13,10.7,4.21,12.05,8.78C696.91,442.47,693.49,458.92,693.49,458.92Z"/><path class="cls-2" d="M592,526.91c0,.32-.08.63-.11.93C591.79,529.41,592,526.83,592,526.91Z"/><path class="cls-2" d="M843.82,527c0,.32-.08.63-.11.93C843.66,529.45,843.84,526.87,843.82,527Z"/><path class="cls-2" d="M954.26,386.58c-11.49-3.74-31.43-4.48-48.26-4.27-16.31.2-23.79,1-29.88,2.28,0,0-29,4.17-45.49,24.56s-21.38,65-21.38,65-9.78,49.34-6.92,65.78,8,31.67,26.62,38.83a100.74,100.74,0,0,0,34.43,6.83s33.21,2.6,58.22-3.31a71.31,71.31,0,0,0,38.21-23.53,99.81,99.81,0,0,0,10.1-16.62,76.53,76.53,0,0,0,5.67-16.1l2.62-10.66-42.54.06s-2.34,28.07-25.28,30.66-35.23,1.62-39.66,1.45-29,.85-27-19.69c0-.28,0-.68.06-1.26,1.14-23.43,3.74-29.5,3.74-29.5L981,496.76l5.7-33C993.22,426.27,988.46,397.73,954.26,386.58ZM945,458.87l-91.49-.09,3.64-14.53s3.18-11.36,9.52-16.2,14.46-5.68,22.1-6.42,27.87-2.17,44.39,1.24c5.48,1.12,10.69,4.2,12.05,8.78C948.42,442.42,945,458.87,945,458.87Z"/><path class="cls-1" d="M1321.85,384.88,1348.12,530l74.35-145.31,41.81.36L1357.17,592.63s-19.38,37.56-31.41,47.08-19.37,13.8-29.2,14.78-13.78,1.66-23.21,0l-10-1.75,6.24-37.06s16.56,3.11,26.42-.78,17.84-20.7,17.84-20.7l5-8.4-38.71-201,41.71.06Z"/><path class="cls-1" d="M1479.37,404.61l43.11.06,2.57-16.72s4.61-30.17,14.88-36a48.2,48.2,0,0,1,14.67-4.7c11.26-2,25.64-2.18,37.27-1.76,17.94.65,24.65.81,42.89,2.88S1648.35,368,1648.35,368l-3.57,26.26s-1.56,11.76-5.77,19.11c-3.72,6.5-13.88,10.87-19.75,12.79-14.2,4.63-62.79,17-62.79,17l-38.24,11s-23.47,6.8-36.64,21.35a87.37,87.37,0,0,0-20.16,39.74c-1.8,8.63-11.89,68.11-11.89,68.11l206.2.09,6.87-41.22-163.09.19,2.94-16.8s1.89-17.32,8.9-23c2.21-1.79,3.32-4.15,16.33-8.8,7.77-2.77,34.37-9.86,34.37-9.86l61.54-16.79s33.57-8.65,46.79-27,18.31-53.4,18.31-53.4,3.56-34.07.85-44.75-12.81-23.51-25.07-29-25.11-8.67-62.24-8.16-55.46,2.25-74.25,9.16-29.65,19.51-36.57,37.28c-7.63,16.78-12,53.16-12,53.16Z"/><path class="cls-1" d="M1867.55,481.23l28.88-173.16-51.16,0L1685.84,479.25l-7.24,43.36,139.42,0-10.2,60.84,42.77.06,10.1-60.89,39.5.08,7.14-41.5Zm-42.6,0-90.14-.14,109.72-116.89Z"/><path class="cls-1" d="M328.93,330.76H460.2s29.45-23.79,50.32-39.05,58.86-39.36,58.86-39.36l-74.15-34.7S432.56,256.46,406,274.77c-25.87,16.87-77,56-77,56Z"/><path class="cls-1" d="M611.13,227.81l-60.89-41A1154.91,1154.91,0,0,1,678.6,126.3c73.25-29.22,112.31-41.37,112.31-41.37L803.29,143s-70.52,23.58-110.94,42.68c-41.74,17.8-81.21,42.13-81.21,42.13Z"/><path class="cls-1" d="M848.33,130.25,837.77,70.74s75.17-20,144-32.8S1142,19.07,1142,19.07L1111.81,111s-80.35-11-155.73-.73a873.42,873.42,0,0,0-107.75,20Z"/><path class="cls-1" d="M1159.5,118.75l50.85-102.14s111.32-2.16,207.3,12.65,183.78,37.65,181.87,38.65L1356.08,195.23s-56.85-36-127.5-58.12c-40-11.67-69.08-18.36-69.08-18.36Z"/><path class="cls-1" d="M1399.72,223l53.53,40.56h439.68s-.89-14.24-12.61-34.4c-7.33-12.64-20.6-26-34.52-39.87-5.06-5-25.34-20.85-40.47-30.66-38.82-25.16-60.5-34.89-100.75-53.23L1399.72,223Z"/><path class="cls-2" d="M357.38,384.69c-16.5,0-32.09,6.51-45.41,13.8l2.34-13.8H270.57l-35,197.72h43.77l19.4-109.54c4-22.23,20.58-49.67,53-49.67l22.63-.09,6.81-38.43Z"/></svg>
assets/js/payment-request.js DELETED
@@ -1,387 +0,0 @@
1
- /*global jQuery, wcStripePaymentRequestParams, PaymentRequest, Stripe, Promise */
2
- /*jshint es3: false */
3
- /*jshint devel: true */
4
- (function( $ ) {
5
-
6
- /**
7
- * WooCommerce Stripe PaymentRequest class.
8
- *
9
- * @type {Object}
10
- */
11
- var wcStripePaymentRequest = {
12
-
13
- /**
14
- * Initialize class events.
15
- */
16
- init: function() {
17
- var self = this;
18
-
19
- if ( self.hasPaymentRequestSupport() ) {
20
- $( document.body )
21
- .on( 'click', '.cart_totals a.checkout-button', self.initPaymentRequest );
22
- }
23
- },
24
-
25
- /**
26
- * Check if browser support PaymentRequest class and if is under HTTPS.
27
- *
28
- * @return {Bool}
29
- */
30
- hasPaymentRequestSupport: function() {
31
- return window.PaymentRequest && 'https:' === window.location.protocol;
32
- },
33
-
34
- /**
35
- * Get Stripe supported methods.
36
- *
37
- * @return {Array}
38
- */
39
- getSupportedMethods: function() {
40
- return [
41
- 'amex',
42
- 'diners',
43
- 'discover',
44
- 'jcb',
45
- 'mastercard',
46
- 'visa'
47
- ];
48
- },
49
-
50
- /**
51
- * Get WC AJAX endpoint URL.
52
- *
53
- * @param {String} endpoint Endpoint.
54
- * @return {String}
55
- */
56
- getAjaxURL: function( endpoint ) {
57
- return wcStripePaymentRequestParams.ajax_url
58
- .toString()
59
- .replace( '%%endpoint%%', 'wc_stripe_' + endpoint );
60
- },
61
-
62
- /**
63
- * Initialize the PaymentRequest.
64
- *
65
- * @param {Object} evt DOM events.
66
- */
67
- initPaymentRequest: function( evt ) {
68
- evt.preventDefault();
69
- var self = wcStripePaymentRequest;
70
- var data = {
71
- security: wcStripePaymentRequestParams.nonce.payment
72
- };
73
-
74
- $.ajax({
75
- type: 'POST',
76
- data: data,
77
- url: self.getAjaxURL( 'get_cart_details' ),
78
- success: function( response ) {
79
- self.openPaymentRequest( response );
80
- }
81
- });
82
- },
83
-
84
- /**
85
- * Open Payment Request modal.
86
- *
87
- * @param {Object} details Payment request details.
88
- */
89
- openPaymentRequest: function( details ) {
90
- var self = this;
91
-
92
- // PaymentRequest options.
93
- var supportedInstruments = [{
94
- supportedMethods: self.getSupportedMethods()
95
- }];
96
- var options = {
97
- requestPayerPhone: true,
98
- requestPayerEmail: true
99
- };
100
- if ( details.shipping_required ) {
101
- options.requestShipping = true;
102
- }
103
- var paymentDetails = details.order_data;
104
-
105
- // Init PaymentRequest.
106
- var request = new PaymentRequest( supportedInstruments, paymentDetails, options );
107
-
108
- // Set up shipping.
109
- request.addEventListener( 'shippingaddresschange', function( evt ) {
110
- evt.updateWith( new Promise( function( resolve, reject ) {
111
- self.updateShippingOptions( paymentDetails, request.shippingAddress, resolve, reject );
112
- }));
113
- });
114
- request.addEventListener( 'shippingoptionchange', function( evt ) {
115
- evt.updateWith( new Promise( function( resolve, reject ) {
116
- self.updateShippingDetails( paymentDetails, request.shippingOption, resolve, reject );
117
- }));
118
- });
119
-
120
- // Open Payment Request UI.
121
- request.show().then( function( payment ) {
122
- self.processPayment( payment );
123
- })
124
- .catch( function( err ) {
125
- console.error( err );
126
- });
127
- },
128
-
129
- /**
130
- * Update shipping options.
131
- *
132
- * @param {Object} details Payment details.
133
- * @param {PaymentAddress} address Shipping address.
134
- * @param {Function} resolve The callback to invoke with updated line items and shipping options.
135
- * @param {Function} reject The callback to invoke in case of failure.
136
- */
137
- updateShippingOptions: function( details, address, resolve, reject ) {
138
- var self = this;
139
- var data = {
140
- security: wcStripePaymentRequestParams.nonce.shipping,
141
- country: address.country,
142
- state: address.region,
143
- postcode: address.postalCode,
144
- city: address.city,
145
- address: typeof address.addressLine[0] === 'undefined' ? '' : address.addressLine[0],
146
- address_2: typeof address.addressLine[1] === 'undefined' ? '' : address.addressLine[1]
147
- };
148
-
149
- $.ajax({
150
- type: 'POST',
151
- data: data,
152
- url: self.getAjaxURL( 'get_shipping_options' ),
153
- success: function( response ) {
154
- details.shippingOptions = response;
155
- if ( details.shippingOptions.length == 1 ) {
156
- // The sole shipping option was auto-selected. Update the details
157
- // (including the total).
158
- self.updateShippingDetails(
159
- details, details.shippingOptions[0].id, resolve, reject );
160
- } else {
161
- resolve( details );
162
- }
163
- }
164
- });
165
- },
166
-
167
- /**
168
- * Updates the shipping price and the total based on the shipping option.
169
- *
170
- * @param {Object} details The line items and shipping options.
171
- * @param {String} shippingOption User's preferred shipping option to use for shipping price calculations.
172
- * @param {Function} resolve The callback to invoke with updated line items and shipping options.
173
- * @param {Function} reject The callback to invoke in case of failure.
174
- */
175
- updateShippingDetails: function( details, shippingOption, resolve, reject ) {
176
- var self = this;
177
- var selected = null;
178
- var data = {
179
- security: wcStripePaymentRequestParams.nonce.update_shipping,
180
- shipping_method: [
181
- shippingOption
182
- ]
183
- };
184
-
185
- $.ajax({
186
- type: 'POST',
187
- data: data,
188
- url: self.getAjaxURL( 'update_shipping_method' ),
189
- success: function( response ) {
190
- details.shippingOptions.forEach( function( value, index ) {
191
- if ( value.id === shippingOption ) {
192
- selected = index;
193
- value.selected = true;
194
- details.total.amount.value = parseFloat( response.total );
195
-
196
- if ( response.items ) {
197
- details.displayItems = response.items;
198
- }
199
- } else {
200
- value.selected = false;
201
- }
202
- });
203
-
204
- if ( null === selected ) {
205
- reject( wcStripePaymentRequestParams.i18n.unknown_shipping.toString().replace( '[option]', shippingOption ) );
206
- }
207
-
208
- resolve( details );
209
- }
210
- });
211
- },
212
-
213
- /**
214
- * Get order data.
215
- *
216
- * @param {PaymentResponse} payment Payment Response instance.
217
- *
218
- * @return {Object}
219
- */
220
- getOrderData: function( payment ) {
221
- var billing = payment.details.billingAddress;
222
- var shipping = payment.shippingAddress;
223
- var data = {
224
- _wpnonce: wcStripePaymentRequestParams.nonce.checkout,
225
- billing_first_name: billing.recipient.split( ' ' ).slice( 0, 1 ).join( ' ' ),
226
- billing_last_name: billing.recipient.split( ' ' ).slice( 1 ).join( ' ' ),
227
- billing_company: billing.organization,
228
- billing_email: payment.payerEmail,
229
- billing_phone: payment.payerPhone,
230
- billing_country: billing.country,
231
- billing_address_1: typeof billing.addressLine[0] === 'undefined' ? '' : billing.addressLine[0],
232
- billing_address_2: typeof billing.addressLine[1] === 'undefined' ? '' : billing.addressLine[1],
233
- billing_city: billing.city,
234
- billing_state: billing.region,
235
- billing_postcode: billing.postalCode,
236
- shipping_first_name: '',
237
- shipping_last_name: '',
238
- shipping_company: '',
239
- shipping_country: '',
240
- shipping_address_1: '',
241
- shipping_address_2: '',
242
- shipping_city: '',
243
- shipping_state: '',
244
- shipping_postcode: '',
245
- shipping_method: [ payment.shippingOption ],
246
- order_comments: '',
247
- payment_method: 'stripe',
248
- // 'wc-stripe-payment-token': 'new',
249
- stripe_token: '',
250
- };
251
-
252
- if ( shipping ) {
253
- data.shipping_first_name = shipping.recipient.split( ' ' ).slice( 0, 1 ).join( ' ' );
254
- data.shipping_last_name = shipping.recipient.split( ' ' ).slice( 1 ).join( ' ' );
255
- data.shipping_company = shipping.organization;
256
- data.shipping_country = shipping.country;
257
- data.shipping_address_1 = typeof shipping.addressLine[0] === 'undefined' ? '' : shipping.addressLine[0];
258
- data.shipping_address_2 = typeof shipping.addressLine[1] === 'undefined' ? '' : shipping.addressLine[1];
259
- data.shipping_city = shipping.city;
260
- data.shipping_state = shipping.region;
261
- data.shipping_postcode = shipping.postalCode;
262
- }
263
-
264
- return data;
265
- },
266
-
267
- /**
268
- * Get credit card data.
269
- *
270
- * @param {PaymentResponse} payment Payment Response instance.
271
- *
272
- * @return {Object}
273
- */
274
- getCardData: function( payment ) {
275
- var billing = payment.details.billingAddress;
276
- var data = {
277
- number: payment.details.cardNumber,
278
- cvc: payment.details.cardSecurityCode,
279
- exp_month: parseInt( payment.details.expiryMonth, 10 ) || 0,
280
- exp_year: parseInt( payment.details.expiryYear, 10 ) || 0,
281
- name: billing.recipient,
282
- address_line1: typeof billing.addressLine[0] === 'undefined' ? '' : billing.addressLine[0],
283
- address_line2: typeof billing.addressLine[1] === 'undefined' ? '' : billing.addressLine[1],
284
- address_state: billing.region,
285
- address_city: billing.city,
286
- address_zip: billing.postalCode,
287
- address_country: billing.country
288
- };
289
-
290
- return data;
291
- },
292
-
293
- /**
294
- * Generate error message HTML.
295
- *
296
- * @param {String} message Error message.
297
- * @return {Object}
298
- */
299
- getErrorMessageHTML: function( message ) {
300
- return $( '<div class="woocommerce-error" />' ).text( message );
301
- },
302
-
303
- /**
304
- * Abort payment and display error messages.
305
- *
306
- * @param {PaymentResponse} payment Payment response instance.
307
- * @param {String} message Error message to display.
308
- */
309
- abortPayment: function( payment, message ) {
310
- payment.complete( 'fail' ).then( function() {
311
- var $form = $( '.shop_table.cart' ).closest( 'form' );
312
- $( '.woocommerce-error' ).remove();
313
- $form.before( message );
314
- $( 'html, body' ).animate({
315
- scrollTop: $form.prev( '.woocommerce-error' ).offset().top
316
- }, 600 );
317
- })
318
- .catch( function( err ) {
319
- console.error( err );
320
- });
321
- },
322
-
323
- /**
324
- * Complete payment.
325
- *
326
- * @param {PaymentResponse} payment Payment response instance.
327
- * @param {String} url Order thank you page URL.
328
- */
329
- completePayment: function( payment, url ) {
330
- payment.complete( 'success' ).then( function() {
331
- // Success, then redirect to the Thank You page.
332
- window.location = url;
333
- })
334
- .catch( function( err ) {
335
- console.error( err );
336
- });
337
- },
338
-
339
- /**
340
- * Process payment.
341
- *
342
- * @param {PaymentResponse} payment Payment response instance.
343
- */
344
- processPayment: function( payment ) {
345
- var self = this;
346
- var orderData = self.getOrderData( payment );
347
- var cardData = self.getCardData( payment );
348
-
349
- Stripe.setPublishableKey( wcStripePaymentRequestParams.stripe.key );
350
- Stripe.createToken( cardData, function( status, response ) {
351
- if ( response.error ) {
352
- self.abortPayment( payment, self.getErrorMessageHTML( response.error.message ) );
353
- } else {
354
- // Check if we allow prepaid cards.
355
- if ( 'no' === wcStripePaymentRequestParams.stripe.allow_prepaid_card && 'prepaid' === response.card.funding ) {
356
- self.abortPayment( payment, self.getErrorMessageHTML( wcStripePaymentRequestParams.i18n.no_prepaid_card ) );
357
- } else {
358
- // Token contains id, last4, and card type.
359
- orderData.stripe_token = response.id;
360
-
361
- $.ajax({
362
- type: 'POST',
363
- data: orderData,
364
- dataType: 'json',
365
- url: self.getAjaxURL( 'create_order' ),
366
- success: function( response ) {
367
- if ( 'success' === response.result ) {
368
- self.completePayment( payment, response.redirect );
369
- } else {
370
- self.abortPayment( payment, response.messages );
371
- }
372
- },
373
- complete: function( jqXHR, textStatus ) {
374
- if ( 'success' !== textStatus ) {
375
- console.error( jqXHR );
376
- }
377
- }
378
- });
379
- }
380
- }
381
- });
382
- }
383
- };
384
-
385
- wcStripePaymentRequest.init();
386
-
387
- })( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/payment-request.min.js DELETED
@@ -1 +0,0 @@
1
- !function(a){var b={init:function(){var b=this;b.hasPaymentRequestSupport()&&a(document.body).on("click",".cart_totals a.checkout-button",b.initPaymentRequest)},hasPaymentRequestSupport:function(){return window.PaymentRequest&&"https:"===window.location.protocol},getSupportedMethods:function(){return["amex","diners","discover","jcb","mastercard","visa"]},getAjaxURL:function(a){return wcStripePaymentRequestParams.ajax_url.toString().replace("%%endpoint%%","wc_stripe_"+a)},initPaymentRequest:function(c){c.preventDefault();var d=b,e={security:wcStripePaymentRequestParams.nonce.payment};a.ajax({type:"POST",data:e,url:d.getAjaxURL("get_cart_details"),success:function(a){d.openPaymentRequest(a)}})},openPaymentRequest:function(a){var b=this,c=[{supportedMethods:b.getSupportedMethods()}],d={requestPayerPhone:!0,requestPayerEmail:!0};a.shipping_required&&(d.requestShipping=!0);var e=a.order_data,f=new PaymentRequest(c,e,d);f.addEventListener("shippingaddresschange",function(a){a.updateWith(new Promise(function(a,c){b.updateShippingOptions(e,f.shippingAddress,a,c)}))}),f.addEventListener("shippingoptionchange",function(a){a.updateWith(new Promise(function(a,c){b.updateShippingDetails(e,f.shippingOption,a,c)}))}),f.show().then(function(a){b.processPayment(a)})["catch"](function(a){console.error(a)})},updateShippingOptions:function(b,c,d,e){var f=this,g={security:wcStripePaymentRequestParams.nonce.shipping,country:c.country,state:c.region,postcode:c.postalCode,city:c.city,address:"undefined"==typeof c.addressLine[0]?"":c.addressLine[0],address_2:"undefined"==typeof c.addressLine[1]?"":c.addressLine[1]};a.ajax({type:"POST",data:g,url:f.getAjaxURL("get_shipping_options"),success:function(a){b.shippingOptions=a,1==b.shippingOptions.length?f.updateShippingDetails(b,b.shippingOptions[0].id,d,e):d(b)}})},updateShippingDetails:function(b,c,d,e){var f=this,g=null,h={security:wcStripePaymentRequestParams.nonce.update_shipping,shipping_method:[c]};a.ajax({type:"POST",data:h,url:f.getAjaxURL("update_shipping_method"),success:function(a){b.shippingOptions.forEach(function(d,e){d.id===c?(g=e,d.selected=!0,b.total.amount.value=parseFloat(a.total),a.items&&(b.displayItems=a.items)):d.selected=!1}),null===g&&e(wcStripePaymentRequestParams.i18n.unknown_shipping.toString().replace("[option]",c)),d(b)}})},getOrderData:function(a){var b=a.details.billingAddress,c=a.shippingAddress,d={_wpnonce:wcStripePaymentRequestParams.nonce.checkout,billing_first_name:b.recipient.split(" ").slice(0,1).join(" "),billing_last_name:b.recipient.split(" ").slice(1).join(" "),billing_company:b.organization,billing_email:a.payerEmail,billing_phone:a.payerPhone,billing_country:b.country,billing_address_1:"undefined"==typeof b.addressLine[0]?"":b.addressLine[0],billing_address_2:"undefined"==typeof b.addressLine[1]?"":b.addressLine[1],billing_city:b.city,billing_state:b.region,billing_postcode:b.postalCode,shipping_first_name:"",shipping_last_name:"",shipping_company:"",shipping_country:"",shipping_address_1:"",shipping_address_2:"",shipping_city:"",shipping_state:"",shipping_postcode:"",shipping_method:[a.shippingOption],order_comments:"",payment_method:"stripe",stripe_token:""};return c&&(d.shipping_first_name=c.recipient.split(" ").slice(0,1).join(" "),d.shipping_last_name=c.recipient.split(" ").slice(1).join(" "),d.shipping_company=c.organization,d.shipping_country=c.country,d.shipping_address_1="undefined"==typeof c.addressLine[0]?"":c.addressLine[0],d.shipping_address_2="undefined"==typeof c.addressLine[1]?"":c.addressLine[1],d.shipping_city=c.city,d.shipping_state=c.region,d.shipping_postcode=c.postalCode),d},getCardData:function(a){var b=a.details.billingAddress,c={number:a.details.cardNumber,cvc:a.details.cardSecurityCode,exp_month:parseInt(a.details.expiryMonth,10)||0,exp_year:parseInt(a.details.expiryYear,10)||0,name:b.recipient,address_line1:"undefined"==typeof b.addressLine[0]?"":b.addressLine[0],address_line2:"undefined"==typeof b.addressLine[1]?"":b.addressLine[1],address_state:b.region,address_city:b.city,address_zip:b.postalCode,address_country:b.country};return c},getErrorMessageHTML:function(b){return a('<div class="woocommerce-error" />').text(b)},abortPayment:function(b,c){b.complete("fail").then(function(){var b=a(".shop_table.cart").closest("form");a(".woocommerce-error").remove(),b.before(c),a("html, body").animate({scrollTop:b.prev(".woocommerce-error").offset().top},600)})["catch"](function(a){console.error(a)})},completePayment:function(a,b){a.complete("success").then(function(){window.location=b})["catch"](function(a){console.error(a)})},processPayment:function(b){var c=this,d=c.getOrderData(b),e=c.getCardData(b);Stripe.setPublishableKey(wcStripePaymentRequestParams.stripe.key),Stripe.createToken(e,function(e,f){f.error?c.abortPayment(b,c.getErrorMessageHTML(f.error.message)):"no"===wcStripePaymentRequestParams.stripe.allow_prepaid_card&&"prepaid"===f.card.funding?c.abortPayment(b,c.getErrorMessageHTML(wcStripePaymentRequestParams.i18n.no_prepaid_card)):(d.stripe_token=f.id,a.ajax({type:"POST",data:d,dataType:"json",url:c.getAjaxURL("create_order"),success:function(a){"success"===a.result?c.completePayment(b,a.redirect):c.abortPayment(b,a.messages)},complete:function(a,b){"success"!==b&&console.error(a)}}))})}};b.init()}(jQuery);
 
assets/js/stripe-admin.js CHANGED
@@ -46,45 +46,19 @@ jQuery( function( $ ) {
46
  $( '#woocommerce_stripe_stripe_checkout' ).change( function() {
47
  if ( $( this ).is( ':checked' ) ) {
48
  $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).show();
49
- $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).hide();
50
  } else {
51
  $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).hide();
52
- $( '#woocommerce_stripe_request_payment_api' ).closest( 'tr' ).show();
53
  }
54
  }).change();
55
 
56
- // Toggle Apple Pay settings.
57
- $( '#woocommerce_stripe_apple_pay' ).change( function() {
58
  if ( $( this ).is( ':checked' ) ) {
59
- $( '#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang' ).closest( 'tr' ).show();
60
  } else {
61
- $( '#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang' ).closest( 'tr' ).hide();
62
  }
63
  }).change();
64
-
65
- // Validate the keys to make sure it is matching test with test field.
66
- $( '#woocommerce_stripe_secret_key, #woocommerce_stripe_publishable_key' ).on( 'input', function() {
67
- var value = $( this ).val();
68
-
69
- if ( value.indexOf( '_test_' ) >= 0 ) {
70
- $( this ).css( 'border-color', 'red' ).after( '<span class="description stripe-error-description" style="color:red; display:block;">' + wc_stripe_admin_params.localized_messages.not_valid_live_key_msg + '</span>' );
71
- } else {
72
- $( this ).css( 'border-color', '' );
73
- $( '.stripe-error-description', $( this ).parent() ).remove();
74
- }
75
- }).trigger( 'input' );
76
-
77
- // Validate the keys to make sure it is matching live with live field.
78
- $( '#woocommerce_stripe_test_secret_key, #woocommerce_stripe_test_publishable_key' ).on( 'input', function() {
79
- var value = $( this ).val();
80
-
81
- if ( value.indexOf( '_live_' ) >= 0 ) {
82
- $( this ).css( 'border-color', 'red' ).after( '<span class="description stripe-error-description" style="color:red; display:block;">' + wc_stripe_admin_params.localized_messages.not_valid_test_key_msg + '</span>' );
83
- } else {
84
- $( this ).css( 'border-color', '' );
85
- $( '.stripe-error-description', $( this ).parent() ).remove();
86
- }
87
- }).trigger( 'input' );
88
  }
89
  };
90
 
46
  $( '#woocommerce_stripe_stripe_checkout' ).change( function() {
47
  if ( $( this ).is( ':checked' ) ) {
48
  $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).show();
 
49
  } else {
50
  $( '#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image' ).closest( 'tr' ).hide();
 
51
  }
52
  }).change();
53
 
54
+ // Toggle Payment Request buttons settings.
55
+ $( '#woocommerce_stripe_payment_request' ).change( function() {
56
  if ( $( this ).is( ':checked' ) ) {
57
+ $( '#woocommerce_stripe_payment_request_button_theme, #woocommerce_stripe_payment_request_button_type, #woocommerce_stripe_payment_request_button_height' ).closest( 'tr' ).show();
58
  } else {
59
+ $( '#woocommerce_stripe_payment_request_button_theme, #woocommerce_stripe_payment_request_button_type, #woocommerce_stripe_payment_request_button_height' ).closest( 'tr' ).hide();
60
  }
61
  }).change();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
  };
64
 
assets/js/stripe-admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(a){"use strict";var b={isTestMode:function(){return a("#woocommerce_stripe_testmode").is(":checked")},getSecretKey:function(){return b.isTestMode()?a("#woocommerce_stripe_test_secret_key").val():a("#woocommerce_stripe_secret_key").val()},init:function(){a(document.body).on("change","#woocommerce_stripe_testmode",function(){var b=a("#woocommerce_stripe_test_secret_key").parents("tr").eq(0),c=a("#woocommerce_stripe_test_publishable_key").parents("tr").eq(0),d=a("#woocommerce_stripe_secret_key").parents("tr").eq(0),e=a("#woocommerce_stripe_publishable_key").parents("tr").eq(0);a(this).is(":checked")?(b.show(),c.show(),d.hide(),e.hide()):(b.hide(),c.hide(),d.show(),e.show())}),a("#woocommerce_stripe_testmode").change(),a("#woocommerce_stripe_stripe_checkout").change(function(){a(this).is(":checked")?(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").show(),a("#woocommerce_stripe_request_payment_api").closest("tr").hide()):(a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").hide(),a("#woocommerce_stripe_request_payment_api").closest("tr").show())}).change(),a("#woocommerce_stripe_apple_pay").change(function(){a(this).is(":checked")?a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").show():a("#woocommerce_stripe_apple_pay_button, #woocommerce_stripe_apple_pay_button_lang").closest("tr").hide()}).change(),a("#woocommerce_stripe_secret_key, #woocommerce_stripe_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_test_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_live_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input"),a("#woocommerce_stripe_test_secret_key, #woocommerce_stripe_test_publishable_key").on("input",function(){var b=a(this).val();b.indexOf("_live_")>=0?a(this).css("border-color","red").after('<span class="description stripe-error-description" style="color:red; display:block;">'+wc_stripe_admin_params.localized_messages.not_valid_test_key_msg+"</span>"):(a(this).css("border-color",""),a(".stripe-error-description",a(this).parent()).remove())}).trigger("input")}};b.init()});
1
+ jQuery(function(a){"use strict";var b={isTestMode:function(){return a("#woocommerce_stripe_testmode").is(":checked")},getSecretKey:function(){return b.isTestMode()?a("#woocommerce_stripe_test_secret_key").val():a("#woocommerce_stripe_secret_key").val()},init:function(){a(document.body).on("change","#woocommerce_stripe_testmode",function(){var b=a("#woocommerce_stripe_test_secret_key").parents("tr").eq(0),c=a("#woocommerce_stripe_test_publishable_key").parents("tr").eq(0),d=a("#woocommerce_stripe_secret_key").parents("tr").eq(0),e=a("#woocommerce_stripe_publishable_key").parents("tr").eq(0);a(this).is(":checked")?(b.show(),c.show(),d.hide(),e.hide()):(b.hide(),c.hide(),d.show(),e.show())}),a("#woocommerce_stripe_testmode").change(),a("#woocommerce_stripe_stripe_checkout").change(function(){a(this).is(":checked")?a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").show():a("#woocommerce_stripe_stripe_checkout_locale, #woocommerce_stripe_stripe_bitcoin, #woocommerce_stripe_stripe_checkout_image").closest("tr").hide()}).change(),a("#woocommerce_stripe_payment_request").change(function(){a(this).is(":checked")?a("#woocommerce_stripe_payment_request_button_theme, #woocommerce_stripe_payment_request_button_type, #woocommerce_stripe_payment_request_button_height").closest("tr").show():a("#woocommerce_stripe_payment_request_button_theme, #woocommerce_stripe_payment_request_button_type, #woocommerce_stripe_payment_request_button_height").closest("tr").hide()}).change()}};b.init()});
assets/js/stripe-apple-pay-single.js DELETED
@@ -1,251 +0,0 @@
1
- /* global wc_stripe_apple_pay_single_params, Stripe */
2
- Stripe.setPublishableKey( wc_stripe_apple_pay_single_params.key );
3
-
4
- jQuery( function( $ ) {
5
- 'use strict';
6
-
7
- /**
8
- * Object to handle Stripe payment forms.
9
- */
10
- var wc_stripe_apple_pay_single = {
11
- /**
12
- * Get WC AJAX endpoint URL.
13
- *
14
- * @param {String} endpoint Endpoint.
15
- * @return {String}
16
- */
17
- getAjaxURL: function( endpoint ) {
18
- return wc_stripe_apple_pay_single_params.ajaxurl
19
- .toString()
20
- .replace( '%%endpoint%%', 'wc_stripe_' + endpoint );
21
- },
22
-
23
- /**
24
- * Initialize event handlers and UI state.
25
- */
26
- init: function() {
27
- Stripe.applePay.checkAvailability( function( available ) {
28
- if ( available ) {
29
- $( '.apple-pay-button' ).show();
30
- }
31
- });
32
-
33
- $( document.body ).on( 'click', '.apple-pay-button', function( e ) {
34
- e.preventDefault();
35
-
36
- var addToCartButton = $( '.single_add_to_cart_button' );
37
-
38
- // First check if product can be added to cart.
39
- if ( addToCartButton.is( '.disabled' ) ) {
40
- if ( addToCartButton.is( '.wc-variation-is-unavailable' ) ) {
41
- window.alert( wc_add_to_cart_variation_params.i18n_unavailable_text );
42
- } else if ( addToCartButton.is( '.wc-variation-selection-needed' ) ) {
43
- window.alert( wc_add_to_cart_variation_params.i18n_make_a_selection_text );
44
- }
45
-
46
- return;
47
- }
48
-
49
- var paymentRequest = {
50
- countryCode: wc_stripe_apple_pay_single_params.country_code,
51
- currencyCode: wc_stripe_apple_pay_single_params.currency_code,
52
- total: {
53
- label: wc_stripe_apple_pay_single_params.label,
54
- amount: '1.00',
55
- type: 'pending'
56
- },
57
- lineItems: [{
58
- label: wc_stripe_apple_pay_single_params.i18n.sub_total,
59
- amount: '1.00',
60
- type: 'pending'
61
- }],
62
- requiredBillingContactFields: ['postalAddress'],
63
- requiredShippingContactFields: 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ? ['postalAddress', 'phone', 'email', 'name'] : ['phone', 'email', 'name']
64
- };
65
-
66
- var applePaySession = Stripe.applePay.buildSession( paymentRequest, function( result, completion ) {
67
- var data = {
68
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,
69
- 'result': result
70
- };
71
-
72
- $.ajax({
73
- type: 'POST',
74
- data: data,
75
- url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay' ),
76
- success: function( response ) {
77
- if ( 'true' === response.success ) {
78
- completion( ApplePaySession.STATUS_SUCCESS );
79
- window.location.href = response.redirect;
80
- }
81
-
82
- if ( 'false' === response.success ) {
83
- completion( ApplePaySession.STATUS_FAILURE );
84
-
85
- $( '.apple-pay-button' ).before( '<p class="woocommerce-error wc-stripe-apple-pay-error">' + response.msg + '</p>' );
86
-
87
- // Scroll to error so user can see it.
88
- $( document.body ).animate({ scrollTop: $( '.wc-stripe-apple-pay-error' ).offset().top }, 500 );
89
- }
90
- }
91
- });
92
- }, function( error ) {
93
- var data = {
94
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,
95
- 'errors': error.message
96
- };
97
-
98
- $.ajax({
99
- type: 'POST',
100
- data: data,
101
- url: wc_stripe_apple_pay_single.getAjaxURL( 'log_apple_pay_errors' )
102
- });
103
- });
104
-
105
- // If shipping is needed -- get shipping methods.
106
- if ( 'yes' === wc_stripe_apple_pay_single_params.needs_shipping ) {
107
- // After the shipping contact/address has been selected
108
- applePaySession.onshippingcontactselected = function( shipping ) {
109
- $.when( wc_stripe_apple_pay_single.generate_cart() ).then( function() {
110
- var data = {
111
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,
112
- 'address': shipping.shippingContact
113
- };
114
-
115
- $.ajax({
116
- type: 'POST',
117
- data: data,
118
- url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_get_shipping_methods' ),
119
- success: function( response ) {
120
- var total = {
121
- 'label': wc_stripe_apple_pay_single_params.label,
122
- 'amount': response.total
123
- };
124
-
125
- if ( response.total <= 0 ) {
126
- total.amount = 1;
127
- total.type = 'pending';
128
- }
129
-
130
- if ( 'true' === response.success ) {
131
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_SUCCESS, response.shipping_methods, total, response.line_items );
132
- }
133
-
134
- if ( 'false' === response.success ) {
135
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, response.shipping_methods, total, response.line_items );
136
- }
137
- }
138
- });
139
- });
140
- };
141
-
142
- // After the shipping method has been selected.
143
- applePaySession.onshippingmethodselected = function( event ) {
144
- var data = {
145
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,
146
- 'selected_shipping_method': event.shippingMethod
147
- };
148
-
149
- $.ajax({
150
- type: 'POST',
151
- data: data,
152
- url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_update_shipping_method' ),
153
- success: function( response ) {
154
- var newTotal = {
155
- 'label': wc_stripe_apple_pay_single_params.label,
156
- 'amount': parseFloat( response.total ).toFixed(2)
157
- };
158
-
159
- if ( 'true' === response.success ) {
160
- applePaySession.completeShippingMethodSelection( ApplePaySession.STATUS_SUCCESS, newTotal, response.line_items );
161
- }
162
-
163
- if ( 'false' === response.success ) {
164
- applePaySession.completeShippingMethodSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, newTotal, response.line_items );
165
- }
166
- }
167
- });
168
- };
169
- }
170
-
171
- // When payment is selected, we need to fetch cart.
172
- applePaySession.onpaymentmethodselected = function( event ) {
173
- $.when( wc_stripe_apple_pay_single.generate_cart() ).then( function() {
174
-
175
- var total = {
176
- label: wc_stripe_apple_pay_single_params.label,
177
- amount: wc_stripe_apple_pay_single_params.total
178
- },
179
- lineItems = wc_stripe_apple_pay_single_params.line_items;
180
-
181
- applePaySession.completePaymentMethodSelection( total, lineItems );
182
- });
183
- };
184
-
185
- applePaySession.oncancel = function( event ) {
186
- wc_stripe_apple_pay_single.clear_cart();
187
- };
188
-
189
- applePaySession.begin();
190
- });
191
- },
192
-
193
- get_attributes: function() {
194
- var select = $( '.variations_form' ).find( '.variations select' ),
195
- data = {},
196
- count = 0,
197
- chosen = 0;
198
-
199
- select.each( function() {
200
- var attribute_name = $( this ).data( 'attribute_name' ) || $( this ).attr( 'name' );
201
- var value = $( this ).val() || '';
202
-
203
- if ( value.length > 0 ) {
204
- chosen ++;
205
- }
206
-
207
- count ++;
208
- data[ attribute_name ] = value;
209
- });
210
-
211
- return {
212
- 'count' : count,
213
- 'chosenCount': chosen,
214
- 'data' : data
215
- };
216
- },
217
-
218
- generate_cart: function() {
219
- var data = {
220
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce,
221
- 'qty': $( '.quantity .qty' ).val(),
222
- 'attributes': $( '.variations_form' ).length ? wc_stripe_apple_pay_single.get_attributes().data : []
223
- };
224
-
225
- return $.ajax({
226
- type: 'POST',
227
- data: data,
228
- url: wc_stripe_apple_pay_single.getAjaxURL( 'generate_apple_pay_single' ),
229
- success: function( response ) {
230
- wc_stripe_apple_pay_single_params.total = response.total;
231
- wc_stripe_apple_pay_single_params.line_items = response.line_items;
232
- }
233
- });
234
- },
235
-
236
- clear_cart: function() {
237
- var data = {
238
- 'nonce': wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce
239
- };
240
-
241
- return $.ajax({
242
- type: 'POST',
243
- data: data,
244
- url: wc_stripe_apple_pay_single.getAjaxURL( 'apple_pay_clear_cart' ),
245
- success: function( response ) {}
246
- });
247
- }
248
- };
249
-
250
- wc_stripe_apple_pay_single.init();
251
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/stripe-apple-pay-single.min.js DELETED
@@ -1 +0,0 @@
1
- Stripe.setPublishableKey(wc_stripe_apple_pay_single_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_single_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(b){b&&a(".apple-pay-button").show()}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d=a(".single_add_to_cart_button");if(d.is(".disabled"))return void(d.is(".wc-variation-is-unavailable")?window.alert(wc_add_to_cart_variation_params.i18n_unavailable_text):d.is(".wc-variation-selection-needed")&&window.alert(wc_add_to_cart_variation_params.i18n_make_a_selection_text));var e={countryCode:wc_stripe_apple_pay_single_params.country_code,currencyCode:wc_stripe_apple_pay_single_params.currency_code,total:{label:wc_stripe_apple_pay_single_params.label,amount:"1.00",type:"pending"},lineItems:[{label:wc_stripe_apple_pay_single_params.i18n.sub_total,amount:"1.00",type:"pending"}],requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_single_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},f=Stripe.applePay.buildSession(e,function(c,d){var e={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})},function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_nonce,errors:c.message};a.ajax({type:"POST",data:d,url:b.getAjaxURL("log_apple_pay_errors")})});"yes"===wc_stripe_apple_pay_single_params.needs_shipping&&(f.onshippingcontactselected=function(c){a.when(b.generate_cart()).then(function(){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:a.total};a.total<=0&&(b.amount=1,b.type="pending"),"true"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&f.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})})},f.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_single_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&f.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),f.onpaymentmethodselected=function(c){a.when(b.generate_cart()).then(function(){var a={label:wc_stripe_apple_pay_single_params.label,amount:wc_stripe_apple_pay_single_params.total},b=wc_stripe_apple_pay_single_params.line_items;f.completePaymentMethodSelection(a,b)})},f.oncancel=function(a){b.clear_cart()},f.begin()})},get_attributes:function(){var b=a(".variations_form").find(".variations select"),c={},d=0,e=0;return b.each(function(){var b=a(this).data("attribute_name")||a(this).attr("name"),f=a(this).val()||"";f.length>0&&e++,d++,c[b]=f}),{count:d,chosenCount:e,data:c}},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce,qty:a(".quantity .qty").val(),attributes:a(".variations_form").length?b.get_attributes().data:[]};return a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_single"),success:function(a){wc_stripe_apple_pay_single_params.total=a.total,wc_stripe_apple_pay_single_params.line_items=a.line_items}})},clear_cart:function(){var c={nonce:wc_stripe_apple_pay_single_params.stripe_apple_pay_cart_nonce};return a.ajax({type:"POST",data:c,url:b.getAjaxURL("apple_pay_clear_cart"),success:function(a){}})}};b.init()});
 
assets/js/stripe-apple-pay.js DELETED
@@ -1,183 +0,0 @@
1
- /* global wc_stripe_apple_pay_params, Stripe */
2
- Stripe.setPublishableKey( wc_stripe_apple_pay_params.key );
3
-
4
- jQuery( function( $ ) {
5
- 'use strict';
6
-
7
- /**
8
- * Object to handle Stripe payment forms.
9
- */
10
- var wc_stripe_apple_pay = {
11
- /**
12
- * Get WC AJAX endpoint URL.
13
- *
14
- * @param {String} endpoint Endpoint.
15
- * @return {String}
16
- */
17
- getAjaxURL: function( endpoint ) {
18
- return wc_stripe_apple_pay_params.ajaxurl
19
- .toString()
20
- .replace( '%%endpoint%%', 'wc_stripe_' + endpoint );
21
- },
22
-
23
- /**
24
- * Initialize event handlers and UI state.
25
- */
26
- init: function() {
27
- Stripe.applePay.checkAvailability( function( available ) {
28
- if ( available ) {
29
- $( '.apple-pay-button' ).show();
30
- // This is so it is centered on the checkout page.
31
- $( '.woocommerce-checkout .apple-pay-button' ).css( 'visibility', 'visible' );
32
- $( '.apple-pay-button-checkout-separator' ).show();
33
-
34
- wc_stripe_apple_pay.generate_cart();
35
- }
36
- });
37
-
38
- $( document.body ).on( 'click', '.apple-pay-button', function( e ) {
39
- e.preventDefault();
40
-
41
- var paymentRequest = {
42
- countryCode: wc_stripe_apple_pay_params.country_code,
43
- currencyCode: wc_stripe_apple_pay_params.currency_code,
44
- total: {
45
- label: wc_stripe_apple_pay_params.label,
46
- amount: wc_stripe_apple_pay_params.total
47
- },
48
- lineItems: wc_stripe_apple_pay_params.line_items,
49
- requiredBillingContactFields: ['postalAddress'],
50
- requiredShippingContactFields: 'yes' === wc_stripe_apple_pay_params.needs_shipping ? ['postalAddress', 'phone', 'email', 'name'] : ['phone', 'email', 'name']
51
- };
52
-
53
- var applePaySession = Stripe.applePay.buildSession( paymentRequest, function( result, completion ) {
54
- var data = {
55
- 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_nonce,
56
- 'result': result
57
- };
58
-
59
- $.ajax({
60
- type: 'POST',
61
- data: data,
62
- url: wc_stripe_apple_pay.getAjaxURL( 'apple_pay' ),
63
- success: function( response ) {
64
- if ( 'true' === response.success ) {
65
- completion( ApplePaySession.STATUS_SUCCESS );
66
- window.location.href = response.redirect;
67
- }
68
-
69
- if ( 'false' === response.success ) {
70
- completion( ApplePaySession.STATUS_FAILURE );
71
-
72
- $( '.apple-pay-button' ).before( '<p class="woocommerce-error wc-stripe-apple-pay-error">' + response.msg + '</p>' );
73
-
74
- // Scroll to error so user can see it.
75
- $( document.body ).animate({ scrollTop: $( '.wc-stripe-apple-pay-error' ).offset().top }, 500 );
76
- }
77
- }
78
- });
79
- }, function( error ) {
80
- var data = {
81
- 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce,
82
- 'errors': error.message
83
- };
84
-
85
- $.ajax({
86
- type: 'POST',
87
- data: data,
88
- url: wc_stripe_apple_pay.getAjaxURL( 'log_apple_pay_errors' )
89
- });
90
- });
91
-
92
- // If shipping is needed -- get shipping methods.
93
- if ( 'yes' === wc_stripe_apple_pay_params.needs_shipping ) {
94
- // After the shipping contact/address has been selected
95
- applePaySession.onshippingcontactselected = function( shipping ) {
96
- var data = {
97
- 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_get_shipping_methods_nonce,
98
- 'address': shipping.shippingContact
99
- };
100
-
101
- $.ajax({
102
- type: 'POST',
103
- data: data,
104
- url: wc_stripe_apple_pay.getAjaxURL( 'apple_pay_get_shipping_methods' ),
105
- success: function( response ) {
106
- var total = {
107
- 'label': wc_stripe_apple_pay_params.label,
108
- 'amount': response.total
109
- };
110
-
111
- if ( 'true' === response.success ) {
112
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_SUCCESS, response.shipping_methods, total, response.line_items );
113
- }
114
-
115
- if ( 'false' === response.success ) {
116
- applePaySession.completeShippingContactSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, response.shipping_methods, total, response.line_items );
117
- }
118
- }
119
- });
120
- };
121
-
122
- // After the shipping method has been selected
123
- applePaySession.onshippingmethodselected = function( event ) {
124
- var data = {
125
- 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_update_shipping_method_nonce,
126
- 'selected_shipping_method': event.shippingMethod
127
- };
128
-
129
- $.ajax({
130
- type: 'POST',
131
- data: data,
132
- url: wc_stripe_apple_pay.getAjaxURL( 'apple_pay_update_shipping_method' ),
133
- success: function( response ) {
134
- var newTotal = {
135
- 'label': wc_stripe_apple_pay_params.label,
136
- 'amount': parseFloat( response.total ).toFixed(2)
137
- };
138
-
139
- if ( 'true' === response.success ) {
140
- applePaySession.completeShippingMethodSelection( ApplePaySession.STATUS_SUCCESS, newTotal, response.line_items );
141
- }
142
-
143
- if ( 'false' === response.success ) {
144
- applePaySession.completeShippingMethodSelection( ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS, newTotal, response.line_items );
145
- }
146
- }
147
- });
148
- };
149
- }
150
-
151
- applePaySession.begin();
152
- });
153
- },
154
-
155
- generate_cart: function() {
156
- var data = {
157
- 'nonce': wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce
158
- };
159
-
160
- $.ajax({
161
- type: 'POST',
162
- data: data,
163
- url: wc_stripe_apple_pay.getAjaxURL( 'generate_apple_pay_cart' ),
164
- success: function( response ) {
165
- wc_stripe_apple_pay_params.total = response.total;
166
- wc_stripe_apple_pay_params.line_items = response.line_items;
167
- }
168
- });
169
- }
170
- };
171
-
172
- wc_stripe_apple_pay.init();
173
-
174
- // We need to refresh Apple Pay data when total is updated.
175
- $( document.body ).on( 'updated_cart_totals', function() {
176
- wc_stripe_apple_pay.init();
177
- });
178
-
179
- // We need to refresh Apple Pay data when total is updated.
180
- $( document.body ).on( 'updated_checkout', function() {
181
- wc_stripe_apple_pay.init();
182
- });
183
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/stripe-apple-pay.min.js DELETED
@@ -1 +0,0 @@
1
- Stripe.setPublishableKey(wc_stripe_apple_pay_params.key),jQuery(function(a){"use strict";var b={getAjaxURL:function(a){return wc_stripe_apple_pay_params.ajaxurl.toString().replace("%%endpoint%%","wc_stripe_"+a)},init:function(){Stripe.applePay.checkAvailability(function(c){c&&(a(".apple-pay-button").show(),a(".woocommerce-checkout .apple-pay-button").css("visibility","visible"),a(".apple-pay-button-checkout-separator").show(),b.generate_cart())}),a(document.body).on("click",".apple-pay-button",function(c){c.preventDefault();var d={countryCode:wc_stripe_apple_pay_params.country_code,currencyCode:wc_stripe_apple_pay_params.currency_code,total:{label:wc_stripe_apple_pay_params.label,amount:wc_stripe_apple_pay_params.total},lineItems:wc_stripe_apple_pay_params.line_items,requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:"yes"===wc_stripe_apple_pay_params.needs_shipping?["postalAddress","phone","email","name"]:["phone","email","name"]},e=Stripe.applePay.buildSession(d,function(c,d){var e={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_nonce,result:c};a.ajax({type:"POST",data:e,url:b.getAjaxURL("apple_pay"),success:function(b){"true"===b.success&&(d(ApplePaySession.STATUS_SUCCESS),window.location.href=b.redirect),"false"===b.success&&(d(ApplePaySession.STATUS_FAILURE),a(".apple-pay-button").before('<p class="woocommerce-error wc-stripe-apple-pay-error">'+b.msg+"</p>"),a(document.body).animate({scrollTop:a(".wc-stripe-apple-pay-error").offset().top},500))}})},function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce,errors:c.message};a.ajax({type:"POST",data:d,url:b.getAjaxURL("log_apple_pay_errors")})});"yes"===wc_stripe_apple_pay_params.needs_shipping&&(e.onshippingcontactselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_get_shipping_methods_nonce,address:c.shippingContact};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_get_shipping_methods"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:a.total};"true"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_SUCCESS,a.shipping_methods,b,a.line_items),"false"===a.success&&e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,a.shipping_methods,b,a.line_items)}})},e.onshippingmethodselected=function(c){var d={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_update_shipping_method_nonce,selected_shipping_method:c.shippingMethod};a.ajax({type:"POST",data:d,url:b.getAjaxURL("apple_pay_update_shipping_method"),success:function(a){var b={label:wc_stripe_apple_pay_params.label,amount:parseFloat(a.total).toFixed(2)};"true"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_SUCCESS,b,a.line_items),"false"===a.success&&e.completeShippingMethodSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,b,a.line_items)}})}),e.begin()})},generate_cart:function(){var c={nonce:wc_stripe_apple_pay_params.stripe_apple_pay_cart_nonce};a.ajax({type:"POST",data:c,url:b.getAjaxURL("generate_apple_pay_cart"),success:function(a){wc_stripe_apple_pay_params.total=a.total,wc_stripe_apple_pay_params.line_items=a.line_items}})}};b.init(),a(document.body).on("updated_cart_totals",function(){b.init()}),a(document.body).on("updated_checkout",function(){b.init()})});
 
assets/js/stripe-checkout.js DELETED
@@ -1,154 +0,0 @@
1
- jQuery( function( $ ) {
2
- 'use strict';
3
-
4
- /**
5
- * Object to handle Stripe payment forms.
6
- */
7
- var wc_stripe_form = {
8
-
9
- /**
10
- * Initialize e handlers and UI state.
11
- */
12
- init: function( form ) {
13
- this.form = form;
14
- this.stripe_submit = false;
15
-
16
- $( this.form )
17
- // We need to bind directly to the click (and not checkout_place_order_stripe) to avoid popup blockers
18
- // especially on mobile devices (like on Chrome for iOS) from blocking StripeCheckout.open from opening a tab
19
- .on( 'click', '#place_order', this.onSubmit )
20
-
21
- // WooCommerce lets us return a false on checkout_place_order_{gateway} to keep the form from submitting
22
- .on( 'submit checkout_place_order_stripe' );
23
-
24
- $( document.body ).on( 'checkout_error', this.resetModal );
25
- },
26
-
27
- isStripeChosen: function() {
28
- return $( '#payment_method_stripe' ).is( ':checked' ) && ( ! $( 'input[name="wc-stripe-payment-token"]:checked' ).length || 'new' === $( 'input[name="wc-stripe-payment-token"]:checked' ).val() );
29
- },
30
-
31
- isStripeModalNeeded: function( e ) {
32
- var token = wc_stripe_form.form.find( 'input.stripe_token' ),
33
- $required_inputs;
34
-
35
- // If this is a stripe submission (after modal) and token exists, allow submit.
36
- if ( wc_stripe_form.stripe_submit && token ) {
37
- return false;
38
- }
39
-
40
- // Don't affect submission if modal is not needed.
41
- if ( ! wc_stripe_form.isStripeChosen() ) {
42
- return false;
43
- }
44
-
45
- // Don't open modal if required fields are not complete
46
- if ( $( 'input#terms' ).length === 1 && $( 'input#terms:checked' ).length === 0 ) {
47
- return false;
48
- }
49
-
50
- if ( $( '#createaccount' ).is( ':checked' ) && $( '#account_password' ).length && $( '#account_password' ).val() === '' ) {
51
- return false;
52
- }
53
-
54
- // check to see if we need to validate shipping address
55
- if ( $( '#ship-to-different-address-checkbox' ).is( ':checked' ) ) {
56
- $required_inputs = $( '.woocommerce-billing-fields .validate-required, .woocommerce-shipping-fields .validate-required' );
57
- } else {
58
- $required_inputs = $( '.woocommerce-billing-fields .validate-required' );
59
- }
60
-
61
- if ( $required_inputs.length ) {
62
- var required_error = false;
63
-
64
- $required_inputs.each( function() {
65
- if ( $( this ).find( 'input.input-text, select' ).not( $( '#account_password, #account_username' ) ).val() === '' ) {
66
- required_error = true;
67
- }
68
-
69
- var emailField = $( this ).find( '#billing_email' );
70
-
71
- if ( emailField.length ) {
72
- var re = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
73
-
74
- if ( ! re.test( emailField.val() ) ) {
75
- required_error = true;
76
- }
77
- }
78
- });
79
-
80
- if ( required_error ) {
81
- return false;
82
- }
83
- }
84
-
85
- return true;
86
- },
87
-
88
- block: function() {
89
- wc_stripe_form.form.block({
90
- message: null,
91
- overlayCSS: {
92
- background: '#fff',
93
- opacity: 0.6
94
- }
95
- });
96
- },
97
-
98
- unblock: function() {
99
- wc_stripe_form.form.unblock();
100
- },
101
-
102
- onClose: function() {
103
- wc_stripe_form.unblock();
104
- },
105
-
106
- onSubmit: function( e ) {
107
- if ( wc_stripe_form.isStripeModalNeeded() ) {
108
- e.preventDefault();
109
-
110
- // Capture submittal and open stripecheckout
111
- var $form = wc_stripe_form.form,
112
- $data = $( '#stripe-payment-data' ),
113
- token = $form.find( 'input.stripe_token' );
114
-
115
- token.val( '' );
116
-
117
- var token_action = function( res ) {
118
- $form.find( 'input.stripe_token' ).remove();
119
- $form.append( '<input type="hidden" class="stripe_token" name="stripe_token" value="' + res.id + '"/>' );
120
- wc_stripe_form.stripe_submit = true;
121
- $form.submit();
122
- };
123
-
124
- StripeCheckout.open({
125
- key : wc_stripe_params.key,
126
- billingAddress : 'yes' === wc_stripe_params.stripe_checkout_require_billing_address,
127
- amount : $data.data( 'amount' ),
128
- name : $data.data( 'name' ),
129
- description : $data.data( 'description' ),
130
- currency : $data.data( 'currency' ),
131
- image : $data.data( 'image' ),
132
- bitcoin : $data.data( 'bitcoin' ),
133
- locale : $data.data( 'locale' ),
134
- email : $( '#billing_email' ).val() || $data.data( 'email' ),
135
- panelLabel : $data.data( 'panel-label' ),
136
- allowRememberMe : $data.data( 'allow-remember-me' ),
137
- token : token_action,
138
- closed : wc_stripe_form.onClose()
139
- });
140
-
141
- return false;
142
- }
143
-
144
- return true;
145
- },
146
-
147
- resetModal: function() {
148
- wc_stripe_form.form.find( 'input.stripe_token' ).remove();
149
- wc_stripe_form.stripe_submit = false;
150
- }
151
- };
152
-
153
- wc_stripe_form.init( $( "form.checkout, form#order_review, form#add_payment_method" ) );
154
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/js/stripe-checkout.min.js DELETED
@@ -1 +0,0 @@
1
- jQuery(function(a){"use strict";var b={init:function(b){this.form=b,this.stripe_submit=!1,a(this.form).on("click","#place_order",this.onSubmit).on("submit checkout_place_order_stripe"),a(document.body).on("checkout_error",this.resetModal)},isStripeChosen:function(){return a("#payment_method_stripe").is(":checked")&&(!a('input[name="wc-stripe-payment-token"]:checked').length||"new"===a('input[name="wc-stripe-payment-token"]:checked').val())},isStripeModalNeeded:function(c){var d,e=b.form.find("input.stripe_token");if(b.stripe_submit&&e)return!1;if(!b.isStripeChosen())return!1;if(1===a("input#terms").length&&0===a("input#terms:checked").length)return!1;if(a("#createaccount").is(":checked")&&a("#account_password").length&&""===a("#account_password").val())return!1;if(d=a(a("#ship-to-different-address-checkbox").is(":checked")?".woocommerce-billing-fields .validate-required, .woocommerce-shipping-fields .validate-required":".woocommerce-billing-fields .validate-required"),d.length){var f=!1;if(d.each(function(){""===a(this).find("input.input-text, select").not(a("#account_password, #account_username")).val()&&(f=!0);var b=a(this).find("#billing_email");if(b.length){var c=/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;c.test(b.val())||(f=!0)}}),f)return!1}return!0},block:function(){b.form.block({message:null,overlayCSS:{background:"#fff",opacity:.6}})},unblock:function(){b.form.unblock()},onClose:function(){b.unblock()},onSubmit:function(c){if(b.isStripeModalNeeded()){c.preventDefault();var d=b.form,e=a("#stripe-payment-data"),f=d.find("input.stripe_token");f.val("");var g=function(a){d.find("input.stripe_token").remove(),d.append('<input type="hidden" class="stripe_token" name="stripe_token" value="'+a.id+'"/>'),b.stripe_submit=!0,d.submit()};return StripeCheckout.open({key:wc_stripe_params.key,billingAddress:"yes"===wc_stripe_params.stripe_checkout_require_billing_address,amount:e.data("amount"),name:e.data("name"),description:e.data("description"),currency:e.data("currency"),image:e.data("image"),bitcoin:e.data("bitcoin"),locale:e.data("locale"),email:a("#billing_email").val()||e.data("email"),panelLabel:e.data("panel-label"),allowRememberMe:e.data("allow-remember-me"),token:g,closed:b.onClose()}),!1}return!0},resetModal:function(){b.form.find("input.stripe_token").remove(),b.stripe_submit=!1}};b.init(a("form.checkout, form#order_review, form#add_payment_method"))});
 
assets/js/stripe-payment-request.js ADDED
@@ -0,0 +1,498 @@