Version Description
- Fix - Improve Subscription plugin support. #161
- Fix - Disable vault setting if vaulting feature is not available. #150
- Fix - Cast item get_quantity into int. #168
- Fix - Fix Credit Card form fields placeholder and label. #146
- Fix - Filter PayPal-supported language codes. #154
- Fix - Wrong order status for orders with contain only products which are both virtual and downloadable. #145
- Fix - Use order_number instead of internal id when creating invoice Id. #163
- Fix - Fix pay later messaging options. #141
- Fix - UI/UX for vaulting settings. #166
Download this release
Release Info
Developer | woothemes |
Plugin | WooCommerce PayPal Payments |
Version | 1.3.2 |
Comparing to | |
See all releases |
Code changes from version 1.3.1 to 1.3.2
- changelog.txt +11 -0
- modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php +1 -5
- modules/ppcp-api-client/src/Entity/class-token.php +20 -0
- modules/ppcp-api-client/src/Factory/class-itemfactory.php +1 -1
- modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php +6 -2
- modules/ppcp-api-client/src/Repository/class-applicationcontextrepository.php +21 -1
- modules/ppcp-api-client/src/Repository/class-partnerreferralsdata.php +1 -0
- modules/ppcp-button/assets/js/button.js +1 -1
- modules/ppcp-button/assets/js/button.js.map +1 -1
- modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js +1 -1
- modules/ppcp-button/services.php +3 -1
- modules/ppcp-button/src/Assets/class-smartbutton.php +7 -25
- modules/ppcp-button/src/Endpoint/class-approveorderendpoint.php +25 -13
- modules/ppcp-button/src/Helper/class-messagesdisclaimers.php +1 -1
- modules/ppcp-onboarding/assets/js/settings.js +275 -240
- modules/ppcp-subscription/src/Helper/class-subscriptionhelper.php +21 -0
- modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php +30 -0
- modules/ppcp-subscription/src/class-renewalhandler.php +13 -0
- modules/ppcp-subscription/src/class-subscriptionmodule.php +187 -4
- modules/ppcp-wc-gateway/assets/js/gateway-settings.js +1 -1
- modules/ppcp-wc-gateway/assets/js/gateway-settings.js.map +1 -1
- modules/ppcp-wc-gateway/resources/js/gateway-settings.js +4 -0
- modules/ppcp-wc-gateway/services.php +24 -9
- modules/ppcp-wc-gateway/src/Assets/class-settingspageassets.php +28 -4
- modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php +38 -1
- modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php +14 -4
- modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php +29 -2
- modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php +10 -4
- modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php +19 -2
- modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php +2 -1
- modules/ppcp-webhooks/src/Handler/class-paymentcapturecompleted.php +1 -1
- readme.txt +12 -1
- vendor/autoload.php +1 -1
- vendor/composer/ClassLoader.php +3 -1
- vendor/composer/InstalledVersions.php +314 -391
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +4 -4
- vendor/composer/installed.json +8 -8
- vendor/composer/installed.php +137 -138
- vendor/psr/log/Psr/Log/AbstractLogger.php +16 -16
- vendor/psr/log/Psr/Log/LoggerAwareTrait.php +1 -1
- vendor/psr/log/composer.json +1 -1
- woocommerce-paypal-payments.php +1 -1
changelog.txt
CHANGED
@@ -1,5 +1,16 @@
|
|
1 |
*** Changelog ***
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
= 1.3.1 - 2021-04-30 =
|
4 |
* Fix - Fix Credit Card fields for non logged-in users. #152
|
5 |
|
1 |
*** Changelog ***
|
2 |
|
3 |
+
= 1.3.2 - 2021-06-08 =
|
4 |
+
* Fix - Improve Subscription plugin support. #161
|
5 |
+
* Fix - Disable vault setting if vaulting feature is not available. #150
|
6 |
+
* Fix - Cast item get_quantity into int. #168
|
7 |
+
* Fix - Fix Credit Card form fields placeholder and label. #146
|
8 |
+
* Fix - Filter PayPal-supported language codes. #154
|
9 |
+
* Fix - Wrong order status for orders with contain only products which are both virtual and downloadable. #145
|
10 |
+
* Fix - Use order_number instead of internal id when creating invoice Id. #163
|
11 |
+
* Fix - Fix pay later messaging options. #141
|
12 |
+
* Fix - UI/UX for vaulting settings. #166
|
13 |
+
|
14 |
= 1.3.1 - 2021-04-30 =
|
15 |
* Fix - Fix Credit Card fields for non logged-in users. #152
|
16 |
|
modules/ppcp-api-client/src/Endpoint/class-orderendpoint.php
CHANGED
@@ -231,11 +231,7 @@ class OrderEndpoint {
|
|
231 |
$response = $this->request( $url, $args );
|
232 |
if ( is_wp_error( $response ) ) {
|
233 |
$error = new RuntimeException(
|
234 |
-
|
235 |
-
// translators: %s is the error message.
|
236 |
-
__( 'Could not create order: %s', 'woocommerce-paypal-payments' ),
|
237 |
-
$response->get_error_message()
|
238 |
-
)
|
239 |
);
|
240 |
$this->logger->log(
|
241 |
'warning',
|
231 |
$response = $this->request( $url, $args );
|
232 |
if ( is_wp_error( $response ) ) {
|
233 |
$error = new RuntimeException(
|
234 |
+
__( 'Could not create order.', 'woocommerce-paypal-payments' )
|
|
|
|
|
|
|
|
|
235 |
);
|
236 |
$this->logger->log(
|
237 |
'warning',
|
modules/ppcp-api-client/src/Entity/class-token.php
CHANGED
@@ -99,6 +99,26 @@ class Token {
|
|
99 |
return new Token( $json );
|
100 |
}
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
/**
|
103 |
* Validates whether a JSON object can be transformed to a Token object.
|
104 |
*
|
99 |
return new Token( $json );
|
100 |
}
|
101 |
|
102 |
+
/**
|
103 |
+
* Checks if vaulting is available in access token scope.
|
104 |
+
*
|
105 |
+
* @return bool Whether vaulting features are enabled or not.
|
106 |
+
*/
|
107 |
+
public function vaulting_available(): bool {
|
108 |
+
if ( ! isset( $this->json->scope ) ) {
|
109 |
+
return false;
|
110 |
+
}
|
111 |
+
|
112 |
+
if ( strpos(
|
113 |
+
$this->json->scope,
|
114 |
+
'https://uri.paypal.com/services/vault/payment-tokens/readwrite'
|
115 |
+
) !== false ) {
|
116 |
+
return true;
|
117 |
+
}
|
118 |
+
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
/**
|
123 |
* Validates whether a JSON object can be transformed to a Token object.
|
124 |
*
|
modules/ppcp-api-client/src/Factory/class-itemfactory.php
CHANGED
@@ -91,7 +91,7 @@ class ItemFactory {
|
|
91 |
*
|
92 |
* @var \WC_Product $product
|
93 |
*/
|
94 |
-
$quantity = $item->get_quantity();
|
95 |
|
96 |
$price = (float) $order->get_item_subtotal( $item, true );
|
97 |
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
|
91 |
*
|
92 |
* @var \WC_Product $product
|
93 |
*/
|
94 |
+
$quantity = (int) $item->get_quantity();
|
95 |
|
96 |
$price = (float) $order->get_item_subtotal( $item, true );
|
97 |
$price_without_tax = (float) $order->get_item_subtotal( $item, false );
|
modules/ppcp-api-client/src/Factory/class-purchaseunitfactory.php
CHANGED
@@ -119,7 +119,7 @@ class PurchaseUnitFactory {
|
|
119 |
$reference_id = 'default';
|
120 |
$description = '';
|
121 |
$payee = $this->payee_repository->payee();
|
122 |
-
$wc_order_id = $order->
|
123 |
$custom_id = $this->prefix . $wc_order_id;
|
124 |
$invoice_id = $this->prefix . $wc_order_id;
|
125 |
$soft_descriptor = '';
|
@@ -134,7 +134,11 @@ class PurchaseUnitFactory {
|
|
134 |
$invoice_id,
|
135 |
$soft_descriptor
|
136 |
);
|
137 |
-
return
|
|
|
|
|
|
|
|
|
138 |
}
|
139 |
|
140 |
/**
|
119 |
$reference_id = 'default';
|
120 |
$description = '';
|
121 |
$payee = $this->payee_repository->payee();
|
122 |
+
$wc_order_id = $order->get_order_number();
|
123 |
$custom_id = $this->prefix . $wc_order_id;
|
124 |
$invoice_id = $this->prefix . $wc_order_id;
|
125 |
$soft_descriptor = '';
|
134 |
$invoice_id,
|
135 |
$soft_descriptor
|
136 |
);
|
137 |
+
return apply_filters(
|
138 |
+
'woocommerce_paypal_payments_purchase_unit_from_wc_order',
|
139 |
+
$purchase_unit,
|
140 |
+
$order
|
141 |
+
);
|
142 |
}
|
143 |
|
144 |
/**
|
modules/ppcp-api-client/src/Repository/class-applicationcontextrepository.php
CHANGED
@@ -46,7 +46,7 @@ class ApplicationContextRepository {
|
|
46 |
): ApplicationContext {
|
47 |
|
48 |
$brand_name = $this->settings->has( 'brand_name' ) ? $this->settings->get( 'brand_name' ) : '';
|
49 |
-
$locale =
|
50 |
$landingpage = $this->settings->has( 'landing_page' ) ?
|
51 |
$this->settings->get( 'landing_page' ) : ApplicationContext::LANDING_PAGE_NO_PREFERENCE;
|
52 |
$context = new ApplicationContext(
|
@@ -59,4 +59,24 @@ class ApplicationContextRepository {
|
|
59 |
);
|
60 |
return $context;
|
61 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
46 |
): ApplicationContext {
|
47 |
|
48 |
$brand_name = $this->settings->has( 'brand_name' ) ? $this->settings->get( 'brand_name' ) : '';
|
49 |
+
$locale = $this->valid_bcp47_code();
|
50 |
$landingpage = $this->settings->has( 'landing_page' ) ?
|
51 |
$this->settings->get( 'landing_page' ) : ApplicationContext::LANDING_PAGE_NO_PREFERENCE;
|
52 |
$context = new ApplicationContext(
|
59 |
);
|
60 |
return $context;
|
61 |
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Returns a PayPal-supported BCP-47 code, for example de-DE-formal becomes de-DE.
|
65 |
+
*
|
66 |
+
* @return string
|
67 |
+
*/
|
68 |
+
protected function valid_bcp47_code() {
|
69 |
+
$locale = str_replace( '_', '-', get_user_locale() );
|
70 |
+
|
71 |
+
if ( preg_match( '/^[a-z]{2}(?:-[A-Z][a-z]{3})?(?:-(?:[A-Z]{2}))?$/', $locale ) ) {
|
72 |
+
return $locale;
|
73 |
+
}
|
74 |
+
|
75 |
+
$parts = explode( '-', $locale );
|
76 |
+
if ( count( $parts ) === 3 ) {
|
77 |
+
return substr( $locale, 0, strrpos( $locale, '-' ) );
|
78 |
+
}
|
79 |
+
|
80 |
+
return 'en';
|
81 |
+
}
|
82 |
}
|
modules/ppcp-api-client/src/Repository/class-partnerreferralsdata.php
CHANGED
@@ -106,6 +106,7 @@ class PartnerReferralsData {
|
|
106 |
'FUTURE_PAYMENT',
|
107 |
'REFUND',
|
108 |
'ADVANCED_TRANSACTIONS_SEARCH',
|
|
|
109 |
),
|
110 |
'seller_nonce' => $this->nonce(),
|
111 |
),
|
106 |
'FUTURE_PAYMENT',
|
107 |
'REFUND',
|
108 |
'ADVANCED_TRANSACTIONS_SEARCH',
|
109 |
+
'VAULT',
|
110 |
),
|
111 |
'seller_nonce' => $this->nonce(),
|
112 |
),
|
modules/ppcp-button/assets/js/button.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([,function(e,t,r){"use strict";r.r(t);var n=class{constructor(e){this.genericErrorText=e,this.wrapper=document.querySelector(".woocommerce-notices-wrapper"),this.messagesList=document.querySelector("ul.woocommerce-error")}genericError(){this.wrapper.classList.contains("ppcp-persist")||(this.clear(),this.message(this.genericErrorText))}appendPreparedErrorMessageElement(e){null===this.messagesList&&this.prepareMessagesList(),this.messagesList.replaceWith(e)}message(e,t=!1){if(0===e.length)throw new Error("A new message text must be a non-empty string.");null===this.messagesList&&this.prepareMessagesList(),t?this.wrapper.classList.add("ppcp-persist"):this.wrapper.classList.remove("ppcp-persist");let r=this.prepareMessagesListItem(e);this.messagesList.appendChild(r),jQuery.scroll_to_notices(jQuery(".woocommerce-notices-wrapper"))}prepareMessagesList(){null===this.messagesList&&(this.messagesList=document.createElement("ul"),this.messagesList.setAttribute("class","woocommerce-error"),this.messagesList.setAttribute("role","alert"),this.wrapper.appendChild(this.messagesList))}prepareMessagesListItem(e){const t=document.createElement("li");return t.innerHTML=e,t}sanitize(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value.replace("Error: ","")}clear(){this.wrapper.classList.contains("woocommerce-error")&&(this.wrapper.classList.remove("woocommerce-error"),this.wrapper.innerText="")}};var a=(e,t)=>(r,n)=>fetch(e.config.ajax.approve_order.endpoint,{method:"POST",body:JSON.stringify({nonce:e.config.ajax.approve_order.nonce,order_id:r.orderID})}).then(e=>e.json()).then(r=>{if(!r.success)return t.genericError(),n.restart().catch(e=>{t.genericError()});location.href=e.config.redirect});const s=()=>{const e=PayPalCommerceGateway.payer;if(!e)return null;const t=document.querySelector("#billing_phone")||void 0!==e.phone?{phone_type:"HOME",phone_number:{national_number:document.querySelector("#billing_phone")?document.querySelector("#billing_phone").value:e.phone.phone_number.national_number}}:null,r={email_address:document.querySelector("#billing_email")?document.querySelector("#billing_email").value:e.email_address,name:{surname:document.querySelector("#billing_last_name")?document.querySelector("#billing_last_name").value:e.name.surname,given_name:document.querySelector("#billing_first_name")?document.querySelector("#billing_first_name").value:e.name.given_name},address:{country_code:document.querySelector("#billing_country")?document.querySelector("#billing_country").value:e.address.country_code,address_line_1:document.querySelector("#billing_address_1")?document.querySelector("#billing_address_1").value:e.address.address_line_1,address_line_2:document.querySelector("#billing_address_2")?document.querySelector("#billing_address_2").value:e.address.address_line_2,admin_area_1:document.querySelector("#billing_state")?document.querySelector("#billing_state").value:e.address.admin_area_1,admin_area_2:document.querySelector("#billing_city")?document.querySelector("#billing_city").value:e.address.admin_area_2,postal_code:document.querySelector("#billing_postcode")?document.querySelector("#billing_postcode").value:e.address.postal_code}};return t&&(r.phone=t),r};var o=class{constructor(e,t){this.config=e,this.errorHandler=t}configuration(){return{createOrder:(e,t)=>{const r=s(),n=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"";return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,purchase_units:[],bn_code:n,payer:r,context:this.config.context})}).then((function(e){return e.json()})).then((function(e){if(!e.success)throw console.error(e),Error(e.data.message);return e.data.id}))},onApprove:a(this,this.errorHandler),onError:e=>{this.errorHandler.genericError()}}}};var i=class{constructor(e,t){this.gateway=e,this.renderer=t,this.actionHandler=null}init(){this.actionHandler=new o(PayPalCommerceGateway,new n(this.gateway.labels.error.generic)),this.render(),jQuery(document.body).on("wc_fragments_loaded wc_fragments_refreshed",()=>{this.render()})}shouldRender(){return null!==document.querySelector(this.gateway.button.mini_cart_wrapper)||null!==document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper)}render(){this.shouldRender()&&this.renderer.render(this.gateway.button.mini_cart_wrapper,this.gateway.hosted_fields.mini_cart_wrapper,this.actionHandler.configuration())}};var c=class{constructor(e,t,r){this.id=e,this.quantity=t,this.variations=r}data(){return{id:this.id,quantity:this.quantity,variations:this.variations}}};var d=class{constructor(e,t){this.endpoint=e,this.nonce=t}update(e,t){return new Promise((r,n)=>{fetch(this.endpoint,{method:"POST",body:JSON.stringify({nonce:this.nonce,products:t})}).then(e=>e.json()).then(t=>{if(!t.success)return void n(t.data);const a=e(t.data);r(a)})})}};var u=class{constructor(e,t,r){this.element=e,this.showCallback=t,this.hideCallback=r,this.observer=null}init(){const e=()=>{this.element.classList.contains("disabled")?this.hideCallback():this.showCallback()};this.observer=new MutationObserver(e),this.observer.observe(this.element,{attributes:!0}),e()}disconnect(){this.observer.disconnect()}};var l=class{constructor(e,t,r,n,a,s){this.config=e,this.updateCart=t,this.showButtonCallback=r,this.hideButtonCallback=n,this.formElement=a,this.errorHandler=s}configuration(){if(this.hasVariations()){new u(this.formElement.querySelector(".single_add_to_cart_button"),this.showButtonCallback,this.hideButtonCallback).init()}return{createOrder:this.createOrder(),onApprove:a(this,this.errorHandler),onError:e=>{this.errorHandler.genericError()}}}createOrder(){var e=null;e=this.isGroupedProduct()?()=>{const e=[];return this.formElement.querySelectorAll('input[type="number"]').forEach(t=>{if(!t.value)return;const r=t.getAttribute("name").match(/quantity\[([\d]*)\]/);if(2!==r.length)return;const n=parseInt(r[1]),a=parseInt(t.value);e.push(new c(n,a,null))}),e}:()=>{const e=document.querySelector('[name="add-to-cart"]').value,t=document.querySelector('[name="quantity"]').value,r=this.variations();return[new c(e,t,r)]};return(t,r)=>{this.errorHandler.clear();return this.updateCart.update(e=>{const t=s(),r=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"";return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,purchase_units:e,payer:t,bn_code:r,context:this.config.context})}).then((function(e){return e.json()})).then((function(e){if(!e.success)throw console.error(e),Error(e.data.message);return e.data.id}))},e())}}variations(){if(!this.hasVariations())return null;return[...this.formElement.querySelectorAll("[name^='attribute_']")].map(e=>({value:e.value,name:e.name}))}hasVariations(){return this.formElement.classList.contains("variations_form")}isGroupedProduct(){return this.formElement.classList.contains("grouped_form")}};var h=class{constructor(e,t,r){this.gateway=e,this.renderer=t,this.messages=r}init(){this.shouldRender()?this.render():this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)}shouldRender(){return null!==document.querySelector("form.cart")}render(){const e=new l(this.gateway,new d(this.gateway.ajax.change_cart.endpoint,this.gateway.ajax.change_cart.nonce),()=>{this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper);let e="0";document.querySelector("form.cart ins .woocommerce-Price-amount")?e=document.querySelector("form.cart ins .woocommerce-Price-amount").innerText:document.querySelector("form.cart .woocommerce-Price-amount")&&(e=document.querySelector("form.cart .woocommerce-Price-amount").innerText);const t=parseInt(e.replace(/([^\d,\.\s]*)/g,""));this.messages.renderWithAmount(t)},()=>{this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)},document.querySelector("form.cart"),new n(this.gateway.labels.error.generic));this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}};var p=class{constructor(e,t){this.gateway=e,this.renderer=t}init(){this.shouldRender()&&(this.render(),jQuery(document.body).on("updated_cart_totals updated_checkout",()=>{this.render()}))}shouldRender(){return null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper)}render(){const e=new o(PayPalCommerceGateway,new n(this.gateway.labels.error.generic));this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}};var y=(e,t,r)=>(n,a)=>(r.block(),fetch(e.config.ajax.approve_order.endpoint,{method:"POST",body:JSON.stringify({nonce:e.config.ajax.approve_order.nonce,order_id:n.orderID})}).then(e=>e.json()).then(e=>{if(r.unblock(),!e.success){if(100===e.data.code?t.message(e.data.message):t.genericError(),void 0!==a&&void 0!==a.restart)return a.restart();throw new Error(e.data.message)}document.querySelector("#place_order").click()}));var m=class{constructor(e,t,r){this.config=e,this.errorHandler=t,this.spinner=r}configuration(){const e=this.spinner;return{createOrder:(t,r)=>{const n=s(),a=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"",o=this.errorHandler,i="checkout"===this.config.context?"form.checkout":"form#order_review",c=jQuery(i).serialize();return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,payer:n,bn_code:a,context:this.config.context,order_id:this.config.order_id,form:c})}).then((function(e){return e.json()})).then((function(t){if(!t.success){if(e.unblock(),void 0!==t.messages){const e=new DOMParser;o.appendPreparedErrorMessageElement(e.parseFromString(t.messages,"text/html").querySelector("ul"))}else o.message(t.data.message,!0);return}const r=document.createElement("input");return r.setAttribute("type","hidden"),r.setAttribute("name","ppcp-resume-order"),r.setAttribute("value",t.data.purchase_units[0].custom_id),document.querySelector(i).append(r),t.data.id}))},onApprove:y(this,this.errorHandler,this.spinner),onCancel:()=>{e.unblock()},onError:()=>{this.errorHandler.genericError(),e.unblock()}}}};var g=class{constructor(e,t,r,n){this.gateway=e,this.renderer=t,this.messages=r,this.spinner=n}init(){this.render(),jQuery(document.body).on("updated_checkout",()=>{this.render()}),jQuery(document.body).on("updated_checkout payment_method_selected",()=>{this.switchBetweenPayPalandOrderButton(),this.displayPlaceOrderButtonForSavedCreditCards()}),jQuery("#saved-credit-card").on("change",()=>{this.displayPlaceOrderButtonForSavedCreditCards()}),this.switchBetweenPayPalandOrderButton(),this.displayPlaceOrderButtonForSavedCreditCards()}shouldRender(){return!document.querySelector(this.gateway.button.cancel_wrapper)&&(null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper))}render(){if(!this.shouldRender())return;document.querySelector(this.gateway.hosted_fields.wrapper+">div")&&document.querySelector(this.gateway.hosted_fields.wrapper+">div").setAttribute("style","");const e=new m(PayPalCommerceGateway,new n(this.gateway.labels.error.generic),this.spinner);this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}switchBetweenPayPalandOrderButton(){jQuery("#saved-credit-card").val(jQuery("#saved-credit-card option:first").val());const e=jQuery('input[name="payment_method"]:checked').val();"ppcp-gateway"!==e&&"ppcp-credit-card-gateway"!==e?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),"ppcp-gateway"===e&&(this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.messages.wrapper),this.messages.render(),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)),"ppcp-credit-card-gateway"===e&&(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}displayPlaceOrderButtonForSavedCreditCards(){"ppcp-credit-card-gateway"===jQuery('input[name="payment_method"]:checked').val()&&(jQuery("#saved-credit-card").length&&""!==jQuery("#saved-credit-card").val()?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}};var w=class{constructor(e,t,r,n){this.gateway=e,this.renderer=t,this.messages=r,this.spinner=n}init(){this.render(),jQuery(document.body).on("updated_checkout",()=>{this.render()}),jQuery(document.body).on("updated_checkout payment_method_selected",()=>{this.switchBetweenPayPalandOrderButton()}),this.switchBetweenPayPalandOrderButton()}shouldRender(){return!document.querySelector(this.gateway.button.cancel_wrapper)&&(null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper))}render(){if(!this.shouldRender())return;document.querySelector(this.gateway.hosted_fields.wrapper+">div")&&document.querySelector(this.gateway.hosted_fields.wrapper+">div").setAttribute("style","");const e=new m(PayPalCommerceGateway,new n(this.gateway.labels.error.generic),this.spinner);this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}switchBetweenPayPalandOrderButton(){if(new URLSearchParams(window.location.search).has("change_payment_method"))return;const e=jQuery('input[name="payment_method"]:checked').val();"ppcp-gateway"!==e&&"ppcp-credit-card-gateway"!==e?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),"ppcp-gateway"===e&&(this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.messages.wrapper),this.messages.render(),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)),"ppcp-credit-card-gateway"===e&&(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}};var f=class{constructor(e,t){this.defaultConfig=t,this.creditCardRenderer=e}render(e,t,r){this.renderButtons(e,r),this.creditCardRenderer.render(t,r)}renderButtons(e,t){if(!document.querySelector(e)||this.isAlreadyRendered(e)||void 0===paypal.Buttons)return;const r=e===this.defaultConfig.button.wrapper?this.defaultConfig.button.style:this.defaultConfig.button.mini_cart_style;paypal.Buttons({style:r,...t}).render(e)}isAlreadyRendered(e){return document.querySelector(e).hasChildNodes()}hideButtons(e){const t=document.querySelector(e);return!!t&&(t.style.display="none",!0)}showButtons(e){const t=document.querySelector(e);return!!t&&(t.style.display="block",!0)}};var _=e=>{const t=window.getComputedStyle(e),r=document.createElement("span");return r.setAttribute("id",e.id),Object.values(t).forEach(e=>{t[e]&&isNaN(e)&&r.style.setProperty(e,""+t[e])}),r};var b=class{constructor(e,t,r){this.defaultConfig=e,this.errorHandler=t,this.spinner=r,this.cardValid=!1}render(e,t){if("checkout"!==this.defaultConfig.context&&"pay-now"!==this.defaultConfig.context||null===e||null===document.querySelector(e))return;if(void 0===paypal.HostedFields||!paypal.HostedFields.isEligible()){const t=document.querySelector(e);return void t.parentNode.removeChild(t)}const r=document.querySelector(".payment_box.payment_method_ppcp-credit-card-gateway"),n=r.style.display;r.style.display="block";const a=document.querySelector("#ppcp-hide-dcc");a&&a.parentNode.removeChild(a);const s=document.querySelector("#ppcp-credit-card-gateway-card-number"),o=window.getComputedStyle(s);let i={};Object.values(o).forEach(e=>{o[e]&&(i[e]=""+o[e])});const c=_(s);s.parentNode.replaceChild(c,s);const d=document.querySelector("#ppcp-credit-card-gateway-card-expiry"),u=_(d);d.parentNode.replaceChild(u,d);const l=document.querySelector("#ppcp-credit-card-gateway-card-cvc"),h=_(l);l.parentNode.replaceChild(h,l),r.style.display=n;const p=".payment_box payment_method_ppcp-credit-card-gateway";this.defaultConfig.enforce_vault&&document.querySelector(p+" .ppcp-credit-card-vault")&&(document.querySelector(p+" .ppcp-credit-card-vault").checked=!0,document.querySelector(p+" .ppcp-credit-card-vault").setAttribute("disabled",!0)),paypal.HostedFields.render({createOrder:t.createOrder,styles:{input:i},fields:{number:{selector:"#ppcp-credit-card-gateway-card-number",placeholder:this.defaultConfig.hosted_fields.labels.credit_card_number},cvv:{selector:"#ppcp-credit-card-gateway-card-cvc",placeholder:this.defaultConfig.hosted_fields.labels.cvv},expirationDate:{selector:"#ppcp-credit-card-gateway-card-expiry",placeholder:this.defaultConfig.hosted_fields.labels.mm_yyyy}}}).then(r=>{const n=e=>{this.spinner.block(),e&&e.preventDefault(),this.errorHandler.clear();const n=r.getState();if(Object.keys(n.fields).every((function(e){return n.fields[e].isValid}))&&this.cardValid){const e=!!this.defaultConfig.save_card,n=document.getElementById("ppcp-credit-card-vault")?document.getElementById("ppcp-credit-card-vault").checked:e;r.submit({contingencies:["3D_SECURE"],vault:n}).then(e=>(e.orderID=e.orderId,this.spinner.unblock(),t.onApprove(e))).catch(()=>{this.errorHandler.genericError(),this.spinner.unblock()})}else{this.spinner.unblock();const e=this.cardValid?this.defaultConfig.hosted_fields.labels.fields_not_valid:this.defaultConfig.hosted_fields.labels.card_not_supported;this.errorHandler.message(e)}};r.on("inputSubmitRequest",(function(){n(null)})),r.on("cardTypeChange",e=>{if(!e.cards.length)return void(this.cardValid=!1);const t=this.defaultConfig.hosted_fields.valid_cards;this.cardValid=-1!==t.indexOf(e.cards[0].type)}),document.querySelector(e+" button").addEventListener("click",n)}),document.querySelector("#payment_method_ppcp-credit-card-gateway").addEventListener("click",()=>{document.querySelector("label[for=ppcp-credit-card-gateway-card-number]").click()})}};const v=(e,t)=>{if(!e)return!1;if(e.user!==t)return!1;return!((new Date).getTime()>=1e3*e.expiration)};var S=(e,t)=>{fetch(t.endpoint,{method:"POST",body:JSON.stringify({nonce:t.nonce})}).then(e=>e.json()).then(r=>{var n;v(r,t.user)&&(n=r,sessionStorage.setItem("ppcp-data-client-id",JSON.stringify(n)),e.setAttribute("data-client-token",r.token),document.body.append(e))})};var q=class{constructor(e){this.config=e}render(){this.shouldRender()&&paypal.Messages({amount:this.config.amount,placement:this.config.placement,style:this.config.style}).render(this.config.wrapper)}renderWithAmount(e){if(!this.shouldRender())return;const t=document.createElement("div");t.setAttribute("id",this.config.wrapper.replace("#",""));const r=document.querySelector(this.config.wrapper).nextSibling;document.querySelector(this.config.wrapper).parentElement.removeChild(document.querySelector(this.config.wrapper)),r.parentElement.insertBefore(t,r),paypal.Messages({amount:e,placement:this.config.placement,style:this.config.style}).render(this.config.wrapper)}shouldRender(){return void 0!==paypal.Messages&&void 0!==this.config.wrapper&&!!document.querySelector(this.config.wrapper)}};var P=class{constructor(){this.target="form.woocommerce-checkout"}setTarget(e){this.target=e}block(){jQuery(this.target).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}unblock(){jQuery(this.target).unblock()}};document.addEventListener("DOMContentLoaded",()=>{const e=document.createElement("script");e.addEventListener("load",e=>{(()=>{const e=new n(PayPalCommerceGateway.labels.error.generic),t=new P,r=new b(PayPalCommerceGateway,e,t),a=new f(r,PayPalCommerceGateway),s=new q(PayPalCommerceGateway.messages),o=PayPalCommerceGateway.context;if("mini-cart"===o||"product"===o){new i(PayPalCommerceGateway,a).init()}if("product"===o){new h(PayPalCommerceGateway,a,s).init()}if("cart"===o){new p(PayPalCommerceGateway,a).init()}if("checkout"===o){new g(PayPalCommerceGateway,a,s,t).init()}if("pay-now"===o){new w(PayPalCommerceGateway,a,s,t).init()}"checkout"!==o&&s.render()})()}),e.setAttribute("src",PayPalCommerceGateway.button.url),Object.entries(PayPalCommerceGateway.script_attributes).forEach(t=>{e.setAttribute(t[0],t[1])}),PayPalCommerceGateway.data_client_id.set_attribute?S(e,PayPalCommerceGateway.data_client_id):document.body.append(e)})}]);
|
2 |
//# sourceMappingURL=button.js.map
|
1 |
+
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([,function(e,t,r){"use strict";r.r(t);var n=class{constructor(e){this.genericErrorText=e,this.wrapper=document.querySelector(".woocommerce-notices-wrapper"),this.messagesList=document.querySelector("ul.woocommerce-error")}genericError(){this.wrapper.classList.contains("ppcp-persist")||(this.clear(),this.message(this.genericErrorText))}appendPreparedErrorMessageElement(e){null===this.messagesList&&this.prepareMessagesList(),this.messagesList.replaceWith(e)}message(e,t=!1){if(0===e.length)throw new Error("A new message text must be a non-empty string.");null===this.messagesList&&this.prepareMessagesList(),t?this.wrapper.classList.add("ppcp-persist"):this.wrapper.classList.remove("ppcp-persist");let r=this.prepareMessagesListItem(e);this.messagesList.appendChild(r),jQuery.scroll_to_notices(jQuery(".woocommerce-notices-wrapper"))}prepareMessagesList(){null===this.messagesList&&(this.messagesList=document.createElement("ul"),this.messagesList.setAttribute("class","woocommerce-error"),this.messagesList.setAttribute("role","alert"),this.wrapper.appendChild(this.messagesList))}prepareMessagesListItem(e){const t=document.createElement("li");return t.innerHTML=e,t}sanitize(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value.replace("Error: ","")}clear(){this.wrapper.classList.contains("woocommerce-error")&&(this.wrapper.classList.remove("woocommerce-error"),this.wrapper.innerText="")}};var a=(e,t)=>(r,n)=>fetch(e.config.ajax.approve_order.endpoint,{method:"POST",body:JSON.stringify({nonce:e.config.ajax.approve_order.nonce,order_id:r.orderID})}).then(e=>e.json()).then(r=>{if(!r.success)return t.genericError(),n.restart().catch(e=>{t.genericError()});location.href=e.config.redirect});const s=()=>{const e=PayPalCommerceGateway.payer;if(!e)return null;const t=document.querySelector("#billing_phone")||void 0!==e.phone?{phone_type:"HOME",phone_number:{national_number:document.querySelector("#billing_phone")?document.querySelector("#billing_phone").value:e.phone.phone_number.national_number}}:null,r={email_address:document.querySelector("#billing_email")?document.querySelector("#billing_email").value:e.email_address,name:{surname:document.querySelector("#billing_last_name")?document.querySelector("#billing_last_name").value:e.name.surname,given_name:document.querySelector("#billing_first_name")?document.querySelector("#billing_first_name").value:e.name.given_name},address:{country_code:document.querySelector("#billing_country")?document.querySelector("#billing_country").value:e.address.country_code,address_line_1:document.querySelector("#billing_address_1")?document.querySelector("#billing_address_1").value:e.address.address_line_1,address_line_2:document.querySelector("#billing_address_2")?document.querySelector("#billing_address_2").value:e.address.address_line_2,admin_area_1:document.querySelector("#billing_state")?document.querySelector("#billing_state").value:e.address.admin_area_1,admin_area_2:document.querySelector("#billing_city")?document.querySelector("#billing_city").value:e.address.admin_area_2,postal_code:document.querySelector("#billing_postcode")?document.querySelector("#billing_postcode").value:e.address.postal_code}};return t&&(r.phone=t),r};var o=class{constructor(e,t){this.config=e,this.errorHandler=t}configuration(){return{createOrder:(e,t)=>{const r=s(),n=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"";return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,purchase_units:[],bn_code:n,payer:r,context:this.config.context})}).then((function(e){return e.json()})).then((function(e){if(!e.success)throw console.error(e),Error(e.data.message);return e.data.id}))},onApprove:a(this,this.errorHandler),onError:e=>{this.errorHandler.genericError()}}}};var i=class{constructor(e,t){this.gateway=e,this.renderer=t,this.actionHandler=null}init(){this.actionHandler=new o(PayPalCommerceGateway,new n(this.gateway.labels.error.generic)),this.render(),jQuery(document.body).on("wc_fragments_loaded wc_fragments_refreshed",()=>{this.render()})}shouldRender(){return null!==document.querySelector(this.gateway.button.mini_cart_wrapper)||null!==document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper)}render(){this.shouldRender()&&this.renderer.render(this.gateway.button.mini_cart_wrapper,this.gateway.hosted_fields.mini_cart_wrapper,this.actionHandler.configuration())}};var c=class{constructor(e,t,r){this.id=e,this.quantity=t,this.variations=r}data(){return{id:this.id,quantity:this.quantity,variations:this.variations}}};var d=class{constructor(e,t){this.endpoint=e,this.nonce=t}update(e,t){return new Promise((r,n)=>{fetch(this.endpoint,{method:"POST",body:JSON.stringify({nonce:this.nonce,products:t})}).then(e=>e.json()).then(t=>{if(!t.success)return void n(t.data);const a=e(t.data);r(a)})})}};var u=class{constructor(e,t,r){this.element=e,this.showCallback=t,this.hideCallback=r,this.observer=null}init(){const e=()=>{this.element.classList.contains("disabled")?this.hideCallback():this.showCallback()};this.observer=new MutationObserver(e),this.observer.observe(this.element,{attributes:!0}),e()}disconnect(){this.observer.disconnect()}};var l=class{constructor(e,t,r,n,a,s){this.config=e,this.updateCart=t,this.showButtonCallback=r,this.hideButtonCallback=n,this.formElement=a,this.errorHandler=s}configuration(){if(this.hasVariations()){new u(this.formElement.querySelector(".single_add_to_cart_button"),this.showButtonCallback,this.hideButtonCallback).init()}return{createOrder:this.createOrder(),onApprove:a(this,this.errorHandler),onError:e=>{this.errorHandler.genericError()}}}createOrder(){var e=null;e=this.isGroupedProduct()?()=>{const e=[];return this.formElement.querySelectorAll('input[type="number"]').forEach(t=>{if(!t.value)return;const r=t.getAttribute("name").match(/quantity\[([\d]*)\]/);if(2!==r.length)return;const n=parseInt(r[1]),a=parseInt(t.value);e.push(new c(n,a,null))}),e}:()=>{const e=document.querySelector('[name="add-to-cart"]').value,t=document.querySelector('[name="quantity"]').value,r=this.variations();return[new c(e,t,r)]};return(t,r)=>{this.errorHandler.clear();return this.updateCart.update(e=>{const t=s(),r=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"";return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,purchase_units:e,payer:t,bn_code:r,context:this.config.context})}).then((function(e){return e.json()})).then((function(e){if(!e.success)throw console.error(e),Error(e.data.message);return e.data.id}))},e())}}variations(){if(!this.hasVariations())return null;return[...this.formElement.querySelectorAll("[name^='attribute_']")].map(e=>({value:e.value,name:e.name}))}hasVariations(){return this.formElement.classList.contains("variations_form")}isGroupedProduct(){return this.formElement.classList.contains("grouped_form")}};var h=class{constructor(e,t,r){this.gateway=e,this.renderer=t,this.messages=r}init(){this.shouldRender()?this.render():this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)}shouldRender(){return null!==document.querySelector("form.cart")}render(){const e=new l(this.gateway,new d(this.gateway.ajax.change_cart.endpoint,this.gateway.ajax.change_cart.nonce),()=>{this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper);let e="0";document.querySelector("form.cart ins .woocommerce-Price-amount")?e=document.querySelector("form.cart ins .woocommerce-Price-amount").innerText:document.querySelector("form.cart .woocommerce-Price-amount")&&(e=document.querySelector("form.cart .woocommerce-Price-amount").innerText);const t=parseInt(e.replace(/([^\d,\.\s]*)/g,""));this.messages.renderWithAmount(t)},()=>{this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)},document.querySelector("form.cart"),new n(this.gateway.labels.error.generic));this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}};var p=class{constructor(e,t){this.gateway=e,this.renderer=t}init(){this.shouldRender()&&(this.render(),jQuery(document.body).on("updated_cart_totals updated_checkout",()=>{this.render()}))}shouldRender(){return null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper)}render(){const e=new o(PayPalCommerceGateway,new n(this.gateway.labels.error.generic));this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}};var m=(e,t,r)=>(n,a)=>(r.block(),fetch(e.config.ajax.approve_order.endpoint,{method:"POST",body:JSON.stringify({nonce:e.config.ajax.approve_order.nonce,order_id:n.orderID})}).then(e=>e.json()).then(e=>{if(r.unblock(),!e.success){if(100===e.data.code?t.message(e.data.message):t.genericError(),void 0!==a&&void 0!==a.restart)return a.restart();throw new Error(e.data.message)}document.querySelector("#place_order").click()}));var y=class{constructor(e,t,r){this.config=e,this.errorHandler=t,this.spinner=r}configuration(){const e=this.spinner;return{createOrder:(t,r)=>{const n=s(),a=void 0!==this.config.bn_codes[this.config.context]?this.config.bn_codes[this.config.context]:"",o=this.errorHandler,i="checkout"===this.config.context?"form.checkout":"form#order_review",c=jQuery(i).serialize();return fetch(this.config.ajax.create_order.endpoint,{method:"POST",body:JSON.stringify({nonce:this.config.ajax.create_order.nonce,payer:n,bn_code:a,context:this.config.context,order_id:this.config.order_id,form:c})}).then((function(e){return e.json()})).then((function(t){if(!t.success){if(e.unblock(),void 0!==t.messages){const e=new DOMParser;o.appendPreparedErrorMessageElement(e.parseFromString(t.messages,"text/html").querySelector("ul"))}else o.message(t.data.message,!0);return}const r=document.createElement("input");return r.setAttribute("type","hidden"),r.setAttribute("name","ppcp-resume-order"),r.setAttribute("value",t.data.purchase_units[0].custom_id),document.querySelector(i).append(r),t.data.id}))},onApprove:m(this,this.errorHandler,this.spinner),onCancel:()=>{e.unblock()},onError:()=>{this.errorHandler.genericError(),e.unblock()}}}};var g=class{constructor(e,t,r,n){this.gateway=e,this.renderer=t,this.messages=r,this.spinner=n}init(){this.render(),jQuery(document.body).on("updated_checkout",()=>{this.render()}),jQuery(document.body).on("updated_checkout payment_method_selected",()=>{this.switchBetweenPayPalandOrderButton(),this.displayPlaceOrderButtonForSavedCreditCards()}),jQuery("#saved-credit-card").on("change",()=>{this.displayPlaceOrderButtonForSavedCreditCards()}),this.switchBetweenPayPalandOrderButton(),this.displayPlaceOrderButtonForSavedCreditCards()}shouldRender(){return!document.querySelector(this.gateway.button.cancel_wrapper)&&(null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper))}render(){if(!this.shouldRender())return;document.querySelector(this.gateway.hosted_fields.wrapper+">div")&&document.querySelector(this.gateway.hosted_fields.wrapper+">div").setAttribute("style","");const e=new y(PayPalCommerceGateway,new n(this.gateway.labels.error.generic),this.spinner);this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}switchBetweenPayPalandOrderButton(){jQuery("#saved-credit-card").val(jQuery("#saved-credit-card option:first").val());const e=jQuery('input[name="payment_method"]:checked').val();"ppcp-gateway"!==e&&"ppcp-credit-card-gateway"!==e?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),"ppcp-gateway"===e&&(this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.messages.wrapper),this.messages.render(),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)),"ppcp-credit-card-gateway"===e&&(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}displayPlaceOrderButtonForSavedCreditCards(){"ppcp-credit-card-gateway"===jQuery('input[name="payment_method"]:checked').val()&&(jQuery("#saved-credit-card").length&&""!==jQuery("#saved-credit-card").val()?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}};var w=class{constructor(e,t,r,n){this.gateway=e,this.renderer=t,this.messages=r,this.spinner=n}init(){this.render(),jQuery(document.body).on("updated_checkout",()=>{this.render()}),jQuery(document.body).on("updated_checkout payment_method_selected",()=>{this.switchBetweenPayPalandOrderButton()}),this.switchBetweenPayPalandOrderButton()}shouldRender(){return!document.querySelector(this.gateway.button.cancel_wrapper)&&(null!==document.querySelector(this.gateway.button.wrapper)||null!==document.querySelector(this.gateway.hosted_fields.wrapper))}render(){if(!this.shouldRender())return;document.querySelector(this.gateway.hosted_fields.wrapper+">div")&&document.querySelector(this.gateway.hosted_fields.wrapper+">div").setAttribute("style","");const e=new y(PayPalCommerceGateway,new n(this.gateway.labels.error.generic),this.spinner);this.renderer.render(this.gateway.button.wrapper,this.gateway.hosted_fields.wrapper,e.configuration())}switchBetweenPayPalandOrderButton(){if(new URLSearchParams(window.location.search).has("change_payment_method"))return;const e=jQuery('input[name="payment_method"]:checked').val();"ppcp-gateway"!==e&&"ppcp-credit-card-gateway"!==e?(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper),jQuery("#place_order").show()):(jQuery("#place_order").hide(),"ppcp-gateway"===e&&(this.renderer.showButtons(this.gateway.button.wrapper),this.renderer.showButtons(this.gateway.messages.wrapper),this.messages.render(),this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)),"ppcp-credit-card-gateway"===e&&(this.renderer.hideButtons(this.gateway.button.wrapper),this.renderer.hideButtons(this.gateway.messages.wrapper),this.renderer.showButtons(this.gateway.hosted_fields.wrapper)))}};var f=class{constructor(e,t){this.defaultConfig=t,this.creditCardRenderer=e}render(e,t,r){this.renderButtons(e,r),this.creditCardRenderer.render(t,r)}renderButtons(e,t){if(!document.querySelector(e)||this.isAlreadyRendered(e)||void 0===paypal.Buttons)return;const r=e===this.defaultConfig.button.wrapper?this.defaultConfig.button.style:this.defaultConfig.button.mini_cart_style;paypal.Buttons({style:r,...t}).render(e)}isAlreadyRendered(e){return document.querySelector(e).hasChildNodes()}hideButtons(e){const t=document.querySelector(e);return!!t&&(t.style.display="none",!0)}showButtons(e){const t=document.querySelector(e);return!!t&&(t.style.display="block",!0)}};var _=e=>{const t=window.getComputedStyle(e),r=document.createElement("span");return r.setAttribute("id",e.id),Object.values(t).forEach(e=>{t[e]&&isNaN(e)&&r.style.setProperty(e,""+t[e])}),r};var b=class{constructor(e,t,r){this.defaultConfig=e,this.errorHandler=t,this.spinner=r,this.cardValid=!1}render(e,t){if("checkout"!==this.defaultConfig.context&&"pay-now"!==this.defaultConfig.context||null===e||null===document.querySelector(e))return;if(void 0===paypal.HostedFields||!paypal.HostedFields.isEligible()){const t=document.querySelector(e);return void t.parentNode.removeChild(t)}const r=document.querySelector(".payment_box.payment_method_ppcp-credit-card-gateway"),n=r.style.display;r.style.display="block";const a=document.querySelector("#ppcp-hide-dcc");a&&a.parentNode.removeChild(a);const s=document.querySelector("#ppcp-credit-card-gateway-card-number"),o=window.getComputedStyle(s);let i={};Object.values(o).forEach(e=>{o[e]&&(i[e]=""+o[e])});const c=_(s);s.parentNode.replaceChild(c,s);const d=document.querySelector("#ppcp-credit-card-gateway-card-expiry"),u=_(d);d.parentNode.replaceChild(u,d);const l=document.querySelector("#ppcp-credit-card-gateway-card-cvc"),h=_(l);l.parentNode.replaceChild(h,l),r.style.display=n;const p=".payment_box payment_method_ppcp-credit-card-gateway";this.defaultConfig.enforce_vault&&document.querySelector(p+" .ppcp-credit-card-vault")&&(document.querySelector(p+" .ppcp-credit-card-vault").checked=!0,document.querySelector(p+" .ppcp-credit-card-vault").setAttribute("disabled",!0)),paypal.HostedFields.render({createOrder:t.createOrder,styles:{input:i},fields:{number:{selector:"#ppcp-credit-card-gateway-card-number",placeholder:this.defaultConfig.hosted_fields.labels.credit_card_number},cvv:{selector:"#ppcp-credit-card-gateway-card-cvc",placeholder:this.defaultConfig.hosted_fields.labels.cvv},expirationDate:{selector:"#ppcp-credit-card-gateway-card-expiry",placeholder:this.defaultConfig.hosted_fields.labels.mm_yy}}}).then(r=>{const n=e=>{this.spinner.block(),e&&e.preventDefault(),this.errorHandler.clear();const n=r.getState();if(Object.keys(n.fields).every((function(e){return n.fields[e].isValid}))&&this.cardValid){const e=!!this.defaultConfig.save_card,n=document.getElementById("ppcp-credit-card-vault")?document.getElementById("ppcp-credit-card-vault").checked:e;r.submit({contingencies:["3D_SECURE"],vault:n}).then(e=>(e.orderID=e.orderId,this.spinner.unblock(),t.onApprove(e))).catch(()=>{this.errorHandler.genericError(),this.spinner.unblock()})}else{this.spinner.unblock();const e=this.cardValid?this.defaultConfig.hosted_fields.labels.fields_not_valid:this.defaultConfig.hosted_fields.labels.card_not_supported;this.errorHandler.message(e)}};r.on("inputSubmitRequest",(function(){n(null)})),r.on("cardTypeChange",e=>{if(!e.cards.length)return void(this.cardValid=!1);const t=this.defaultConfig.hosted_fields.valid_cards;this.cardValid=-1!==t.indexOf(e.cards[0].type)}),document.querySelector(e+" button").addEventListener("click",n)}),document.querySelector("#payment_method_ppcp-credit-card-gateway").addEventListener("click",()=>{document.querySelector("label[for=ppcp-credit-card-gateway-card-number]").click()})}};const v=(e,t)=>{if(!e)return!1;if(e.user!==t)return!1;return!((new Date).getTime()>=1e3*e.expiration)};var S=(e,t)=>{fetch(t.endpoint,{method:"POST",body:JSON.stringify({nonce:t.nonce})}).then(e=>e.json()).then(r=>{var n;v(r,t.user)&&(n=r,sessionStorage.setItem("ppcp-data-client-id",JSON.stringify(n)),e.setAttribute("data-client-token",r.token),document.body.append(e))})};var q=class{constructor(e){this.config=e}render(){this.shouldRender()&&paypal.Messages({amount:this.config.amount,placement:this.config.placement,style:this.config.style}).render(this.config.wrapper)}renderWithAmount(e){if(!this.shouldRender())return;const t=document.createElement("div");t.setAttribute("id",this.config.wrapper.replace("#",""));const r=document.querySelector(this.config.wrapper).nextSibling;document.querySelector(this.config.wrapper).parentElement.removeChild(document.querySelector(this.config.wrapper)),r.parentElement.insertBefore(t,r),paypal.Messages({amount:e,placement:this.config.placement,style:this.config.style}).render(this.config.wrapper)}shouldRender(){return void 0!==paypal.Messages&&void 0!==this.config.wrapper&&!!document.querySelector(this.config.wrapper)}};var P=class{constructor(){this.target="form.woocommerce-checkout"}setTarget(e){this.target=e}block(){jQuery(this.target).block({message:null,overlayCSS:{background:"#fff",opacity:.6}})}unblock(){jQuery(this.target).unblock()}};document.addEventListener("DOMContentLoaded",()=>{const e=document.createElement("script");e.addEventListener("load",e=>{(()=>{const e=new n(PayPalCommerceGateway.labels.error.generic),t=new P,r=new b(PayPalCommerceGateway,e,t),a=new f(r,PayPalCommerceGateway),s=new q(PayPalCommerceGateway.messages),o=PayPalCommerceGateway.context;if("mini-cart"===o||"product"===o){new i(PayPalCommerceGateway,a).init()}if("product"===o){new h(PayPalCommerceGateway,a,s).init()}if("cart"===o){new p(PayPalCommerceGateway,a).init()}if("checkout"===o){new g(PayPalCommerceGateway,a,s,t).init()}if("pay-now"===o){new w(PayPalCommerceGateway,a,s,t).init()}"checkout"!==o&&s.render()})()}),e.setAttribute("src",PayPalCommerceGateway.button.url),Object.entries(PayPalCommerceGateway.script_attributes).forEach(t=>{e.setAttribute(t[0],t[1])}),PayPalCommerceGateway.data_client_id.set_attribute?S(e,PayPalCommerceGateway.data_client_id):document.body.append(e)})}]);
|
2 |
//# sourceMappingURL=button.js.map
|
modules/ppcp-button/assets/js/button.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./resources/js/modules/ErrorHandler.js","webpack:///./resources/js/modules/OnApproveHandler/onApproveForContinue.js","webpack:///./resources/js/modules/Helper/PayerData.js","webpack:///./resources/js/modules/ActionHandler/CartActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/MiniCartBootstap.js","webpack:///./resources/js/modules/Entity/Product.js","webpack:///./resources/js/modules/Helper/UpdateCart.js","webpack:///./resources/js/modules/Helper/ButtonsToggleListener.js","webpack:///./resources/js/modules/ActionHandler/SingleProductActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/SingleProductBootstap.js","webpack:///./resources/js/modules/ContextBootstrap/CartBootstap.js","webpack:///./resources/js/modules/OnApproveHandler/onApproveForPayNow.js","webpack:///./resources/js/modules/ActionHandler/CheckoutActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/CheckoutBootstap.js","webpack:///./resources/js/modules/ContextBootstrap/PayNowBootstrap.js","webpack:///./resources/js/modules/Renderer/Renderer.js","webpack:///./resources/js/modules/Helper/DccInputFactory.js","webpack:///./resources/js/modules/Renderer/CreditCardRenderer.js","webpack:///./resources/js/modules/DataClientIdAttributeHandler.js","webpack:///./resources/js/modules/Renderer/MessageRenderer.js","webpack:///./resources/js/modules/Helper/Spinner.js","webpack:///./resources/js/button.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ErrorHandler","constructor","genericErrorText","this","wrapper","document","querySelector","messagesList","genericError","classList","contains","clear","message","appendPreparedErrorMessageElement","errorMessageElement","prepareMessagesList","replaceWith","text","persist","length","Error","add","remove","messageNode","prepareMessagesListItem","appendChild","jQuery","scroll_to_notices","createElement","setAttribute","li","innerHTML","sanitize","textarea","replace","innerText","onApprove","context","errorHandler","data","actions","fetch","config","ajax","approve_order","endpoint","method","body","JSON","stringify","nonce","order_id","orderID","then","res","json","success","restart","catch","err","location","href","redirect","payerData","payer","PayPalCommerceGateway","phone","phone_type","phone_number","national_number","email_address","surname","given_name","address","country_code","address_line_1","address_line_2","admin_area_1","admin_area_2","postal_code","CartActionHandler","configuration","createOrder","bnCode","bn_codes","create_order","purchase_units","bn_code","console","error","id","onError","MiniCartBootstap","gateway","renderer","actionHandler","init","labels","generic","render","on","shouldRender","button","mini_cart_wrapper","hosted_fields","Product","quantity","variations","UpdateCart","update","onResolve","products","Promise","resolve","reject","result","resolved","ButtonsToggleListener","element","showCallback","hideCallback","observer","callback","MutationObserver","observe","attributes","disconnect","SingleProductActionHandler","updateCart","showButtonCallback","hideButtonCallback","formElement","hasVariations","getProducts","isGroupedProduct","querySelectorAll","forEach","elementName","getAttribute","match","parseInt","push","qty","map","SingleProductBootstap","messages","hideButtons","change_cart","showButtons","priceText","amount","renderWithAmount","CartBootstrap","spinner","block","unblock","code","click","CheckoutActionHandler","formSelector","formValues","serialize","form","domParser","DOMParser","parseFromString","input","custom_id","append","onCancel","CheckoutBootstap","switchBetweenPayPalandOrderButton","displayPlaceOrderButtonForSavedCreditCards","cancel_wrapper","val","currentPaymentMethod","show","hide","PayNowBootstrap","URLSearchParams","window","search","has","Renderer","creditCardRenderer","defaultConfig","hostedFieldsWrapper","contextConfig","renderButtons","isAlreadyRendered","paypal","Buttons","style","mini_cart_style","hasChildNodes","domElement","display","dccInputFactory","original","styles","getComputedStyle","newElement","values","prop","isNaN","setProperty","CreditCardRenderer","cardValid","HostedFields","isEligible","wrapperElement","parentNode","removeChild","gateWayBox","oldDisplayStyle","hideDccGateway","cardNumberField","stylesRaw","cardNumber","replaceChild","cardExpiryField","cardExpiry","cardCodeField","cardCode","formWrapper","enforce_vault","checked","fields","number","selector","placeholder","credit_card_number","cvv","expirationDate","mm_yyyy","hostedFields","submitEvent","event","preventDefault","state","getState","keys","every","isValid","save_card","vault","getElementById","submit","contingencies","payload","orderId","fields_not_valid","card_not_supported","cards","validCards","valid_cards","indexOf","type","addEventListener","validateToken","token","user","Date","getTime","expiration","dataClientIdAttributeHandler","script","sessionStorage","setItem","MessageRenderer","Messages","placement","newWrapper","sibling","nextSibling","parentElement","insertBefore","Spinner","target","setTarget","overlayCSS","background","opacity","messageRenderer","bootstrap","url","entries","script_attributes","keyValue","data_client_id","set_attribute"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,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A,EAAS,MAI9C/N,sBAAsBgO,eAAeC,cACrCzB,EAA6BC,EAAQzM,sBAAsBgO,gBAI/D5R,SAAS0C,KAAKyH,OAAOkG","file":"js/button.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","class ErrorHandler {\n\n constructor(genericErrorText)\n {\n this.genericErrorText = genericErrorText;\n this.wrapper = document.querySelector('.woocommerce-notices-wrapper');\n this.messagesList = document.querySelector('ul.woocommerce-error');\n }\n\n genericError() {\n if (this.wrapper.classList.contains('ppcp-persist')) {\n return;\n }\n this.clear();\n this.message(this.genericErrorText)\n }\n\n appendPreparedErrorMessageElement(errorMessageElement)\n {\n if(this.messagesList === null) {\n this.prepareMessagesList();\n }\n\n this.messagesList.replaceWith(errorMessageElement);\n }\n\n message(text, persist = false)\n {\n if(! typeof String || text.length === 0){\n throw new Error('A new message text must be a non-empty string.');\n }\n\n if(this.messagesList === null){\n this.prepareMessagesList();\n }\n\n if (persist) {\n this.wrapper.classList.add('ppcp-persist');\n } else {\n this.wrapper.classList.remove('ppcp-persist');\n }\n\n let messageNode = this.prepareMessagesListItem(text);\n this.messagesList.appendChild(messageNode);\n\n jQuery.scroll_to_notices(jQuery('.woocommerce-notices-wrapper'))\n }\n\n prepareMessagesList()\n {\n if(this.messagesList === null){\n this.messagesList = document.createElement('ul');\n this.messagesList.setAttribute('class', 'woocommerce-error');\n this.messagesList.setAttribute('role', 'alert');\n this.wrapper.appendChild(this.messagesList);\n }\n }\n\n prepareMessagesListItem(message)\n {\n const li = document.createElement('li');\n li.innerHTML = message;\n\n return li;\n }\n\n sanitize(text)\n {\n const textarea = document.createElement('textarea');\n textarea.innerHTML = text;\n return textarea.value.replace('Error: ', '');\n }\n\n clear()\n {\n if (! this.wrapper.classList.contains('woocommerce-error')) {\n return;\n }\n this.wrapper.classList.remove('woocommerce-error');\n this.wrapper.innerText = '';\n }\n}\n\nexport default ErrorHandler;\n","const onApprove = (context, errorHandler) => {\n return (data, actions) => {\n return fetch(context.config.ajax.approve_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: context.config.ajax.approve_order.nonce,\n order_id:data.orderID\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n if (!data.success) {\n errorHandler.genericError();\n return actions.restart().catch(err => {\n errorHandler.genericError();\n });;\n }\n location.href = context.config.redirect;\n });\n\n }\n}\n\nexport default onApprove;\n","export const payerData = () => {\n const payer = PayPalCommerceGateway.payer;\n if (! payer) {\n return null;\n }\n\n const phone = (document.querySelector('#billing_phone') || typeof payer.phone !== 'undefined') ?\n {\n phone_type:\"HOME\",\n phone_number:{\n national_number : (document.querySelector('#billing_phone')) ? document.querySelector('#billing_phone').value : payer.phone.phone_number.national_number\n }\n } : null;\n const payerData = {\n email_address:(document.querySelector('#billing_email')) ? document.querySelector('#billing_email').value : payer.email_address,\n name : {\n surname: (document.querySelector('#billing_last_name')) ? document.querySelector('#billing_last_name').value : payer.name.surname,\n given_name: (document.querySelector('#billing_first_name')) ? document.querySelector('#billing_first_name').value : payer.name.given_name\n },\n address : {\n country_code : (document.querySelector('#billing_country')) ? document.querySelector('#billing_country').value : payer.address.country_code,\n address_line_1 : (document.querySelector('#billing_address_1')) ? document.querySelector('#billing_address_1').value : payer.address.address_line_1,\n address_line_2 : (document.querySelector('#billing_address_2')) ? document.querySelector('#billing_address_2').value : payer.address.address_line_2,\n admin_area_1 : (document.querySelector('#billing_state')) ? document.querySelector('#billing_state').value : payer.address.admin_area_1,\n admin_area_2 : (document.querySelector('#billing_city')) ? document.querySelector('#billing_city').value : payer.address.admin_area_2,\n postal_code : (document.querySelector('#billing_postcode')) ? document.querySelector('#billing_postcode').value : payer.address.postal_code\n }\n };\n\n if (phone) {\n payerData.phone = phone;\n }\n return payerData;\n}\n","import onApprove from '../OnApproveHandler/onApproveForContinue.js';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass CartActionHandler {\n\n constructor(config, errorHandler) {\n this.config = config;\n this.errorHandler = errorHandler;\n }\n\n configuration() {\n const createOrder = (data, actions) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n purchase_units: [],\n bn_code:bnCode,\n payer,\n context:this.config.context\n }),\n }).then(function(res) {\n return res.json();\n }).then(function(data) {\n if (!data.success) {\n console.error(data);\n throw Error(data.data.message);\n }\n return data.data.id;\n });\n };\n\n return {\n createOrder,\n onApprove: onApprove(this, this.errorHandler),\n onError: (error) => {\n this.errorHandler.genericError();\n }\n };\n }\n}\n\nexport default CartActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport CartActionHandler from '../ActionHandler/CartActionHandler';\n\nclass MiniCartBootstap {\n constructor(gateway, renderer) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.actionHandler = null;\n }\n\n init() {\n\n this.actionHandler = new CartActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n this.render();\n\n jQuery(document.body).on('wc_fragments_loaded wc_fragments_refreshed', () => {\n this.render();\n });\n }\n\n shouldRender() {\n return document.querySelector(this.gateway.button.mini_cart_wrapper) !==\n null || document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper) !==\n null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n\n this.renderer.render(\n this.gateway.button.mini_cart_wrapper,\n this.gateway.hosted_fields.mini_cart_wrapper,\n this.actionHandler.configuration()\n );\n }\n}\n\nexport default MiniCartBootstap;","class Product {\n\n constructor(id, quantity, variations) {\n this.id = id;\n this.quantity = quantity;\n this.variations = variations;\n }\n\n data() {\n return {\n id:this.id,\n quantity:this.quantity,\n variations:this.variations\n }\n }\n}\n\nexport default Product;","import Product from \"../Entity/Product\";\nclass UpdateCart {\n\n constructor(endpoint, nonce)\n {\n this.endpoint = endpoint;\n this.nonce = nonce;\n }\n\n /**\n *\n * @param onResolve\n * @param {Product[]} products\n * @returns {Promise<unknown>}\n */\n update(onResolve, products)\n {\n return new Promise((resolve, reject) => {\n fetch(\n this.endpoint,\n {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.nonce,\n products,\n })\n }\n ).then(\n (result) => {\n return result.json();\n }\n ).then((result) => {\n if (! result.success) {\n reject(result.data);\n return;\n }\n\n const resolved = onResolve(result.data);\n resolve(resolved);\n })\n });\n }\n}\n\nexport default UpdateCart;","/**\n * When you can't add something to the cart, the PayPal buttons should not show.\n * Therefore we listen for changes on the add to cart button and show/hide the buttons accordingly.\n */\n\nclass ButtonsToggleListener {\n constructor(element, showCallback, hideCallback)\n {\n this.element = element;\n this.showCallback = showCallback;\n this.hideCallback = hideCallback;\n this.observer = null;\n }\n\n init()\n {\n const config = { attributes : true };\n const callback = () => {\n if (this.element.classList.contains('disabled')) {\n this.hideCallback();\n return;\n }\n this.showCallback();\n }\n this.observer = new MutationObserver(callback);\n this.observer.observe(this.element, config);\n callback();\n }\n\n disconnect()\n {\n this.observer.disconnect();\n }\n}\n\nexport default ButtonsToggleListener;","import ButtonsToggleListener from '../Helper/ButtonsToggleListener';\nimport Product from '../Entity/Product';\nimport onApprove from '../OnApproveHandler/onApproveForContinue';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass SingleProductActionHandler {\n\n constructor(\n config,\n updateCart,\n showButtonCallback,\n hideButtonCallback,\n formElement,\n errorHandler\n ) {\n this.config = config;\n this.updateCart = updateCart;\n this.showButtonCallback = showButtonCallback;\n this.hideButtonCallback = hideButtonCallback;\n this.formElement = formElement;\n this.errorHandler = errorHandler;\n }\n\n configuration()\n {\n\n if ( this.hasVariations() ) {\n const observer = new ButtonsToggleListener(\n this.formElement.querySelector('.single_add_to_cart_button'),\n this.showButtonCallback,\n this.hideButtonCallback\n );\n observer.init();\n }\n\n return {\n createOrder: this.createOrder(),\n onApprove: onApprove(this, this.errorHandler),\n onError: (error) => {\n this.errorHandler.genericError();\n }\n }\n }\n\n createOrder()\n {\n var getProducts = null;\n if (! this.isGroupedProduct() ) {\n getProducts = () => {\n const id = document.querySelector('[name=\"add-to-cart\"]').value;\n const qty = document.querySelector('[name=\"quantity\"]').value;\n const variations = this.variations();\n return [new Product(id, qty, variations)];\n }\n } else {\n getProducts = () => {\n const products = [];\n this.formElement.querySelectorAll('input[type=\"number\"]').forEach((element) => {\n if (! element.value) {\n return;\n }\n const elementName = element.getAttribute('name').match(/quantity\\[([\\d]*)\\]/);\n if (elementName.length !== 2) {\n return;\n }\n const id = parseInt(elementName[1]);\n const quantity = parseInt(element.value);\n products.push(new Product(id, quantity, null));\n })\n return products;\n }\n }\n const createOrder = (data, actions) => {\n this.errorHandler.clear();\n\n const onResolve = (purchase_units) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n purchase_units,\n payer,\n bn_code:bnCode,\n context:this.config.context\n })\n }).then(function (res) {\n return res.json();\n }).then(function (data) {\n if (!data.success) {\n console.error(data);\n throw Error(data.data.message);\n }\n return data.data.id;\n });\n };\n\n const promise = this.updateCart.update(onResolve, getProducts());\n return promise;\n };\n return createOrder;\n }\n\n variations()\n {\n\n if (! this.hasVariations()) {\n return null;\n }\n const attributes = [...this.formElement.querySelectorAll(\"[name^='attribute_']\")].map(\n (element) => {\n return {\n value:element.value,\n name:element.name\n }\n }\n );\n return attributes;\n }\n\n hasVariations()\n {\n return this.formElement.classList.contains('variations_form');\n }\n\n isGroupedProduct()\n {\n return this.formElement.classList.contains('grouped_form');\n }\n}\nexport default SingleProductActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport UpdateCart from \"../Helper/UpdateCart\";\nimport SingleProductActionHandler from \"../ActionHandler/SingleProductActionHandler\";\n\nclass SingleProductBootstap {\n constructor(gateway, renderer, messages) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n }\n\n init() {\n if (!this.shouldRender()) {\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n return;\n }\n\n this.render();\n }\n\n shouldRender() {\n if (document.querySelector('form.cart') === null) {\n return false;\n }\n\n return true;\n }\n\n render() {\n const actionHandler = new SingleProductActionHandler(\n this.gateway,\n new UpdateCart(\n this.gateway.ajax.change_cart.endpoint,\n this.gateway.ajax.change_cart.nonce,\n ),\n () => {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper);\n let priceText = \"0\";\n if (document.querySelector('form.cart ins .woocommerce-Price-amount')) {\n priceText = document.querySelector('form.cart ins .woocommerce-Price-amount').innerText;\n }\n else if (document.querySelector('form.cart .woocommerce-Price-amount')) {\n priceText = document.querySelector('form.cart .woocommerce-Price-amount').innerText;\n }\n const amount = parseInt(priceText.replace(/([^\\d,\\.\\s]*)/g, ''));\n this.messages.renderWithAmount(amount)\n },\n () => {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n },\n document.querySelector('form.cart'),\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n}\n\nexport default SingleProductBootstap;","import CartActionHandler from '../ActionHandler/CartActionHandler';\nimport ErrorHandler from '../ErrorHandler';\n\nclass CartBootstrap {\n constructor(gateway, renderer) {\n this.gateway = gateway;\n this.renderer = renderer;\n }\n\n init() {\n if (!this.shouldRender()) {\n return;\n }\n\n this.render();\n\n jQuery(document.body).on('updated_cart_totals updated_checkout', () => {\n this.render();\n });\n }\n\n shouldRender() {\n return document.querySelector(this.gateway.button.wrapper) !==\n null || document.querySelector(this.gateway.hosted_fields.wrapper) !==\n null;\n }\n\n render() {\n const actionHandler = new CartActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n}\n\nexport default CartBootstrap;","const onApprove = (context, errorHandler, spinner) => {\n return (data, actions) => {\n spinner.block();\n return fetch(context.config.ajax.approve_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: context.config.ajax.approve_order.nonce,\n order_id:data.orderID\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n spinner.unblock();\n if (!data.success) {\n if (data.data.code === 100) {\n errorHandler.message(data.data.message);\n } else {\n errorHandler.genericError();\n }\n if (typeof actions !== 'undefined' && typeof actions.restart !== 'undefined') {\n return actions.restart();\n }\n throw new Error(data.data.message);\n }\n document.querySelector('#place_order').click()\n });\n\n }\n}\n\nexport default onApprove;\n","import onApprove from '../OnApproveHandler/onApproveForPayNow.js';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass CheckoutActionHandler {\n\n constructor(config, errorHandler, spinner) {\n this.config = config;\n this.errorHandler = errorHandler;\n this.spinner = spinner;\n }\n\n configuration() {\n const spinner = this.spinner;\n const createOrder = (data, actions) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n\n const errorHandler = this.errorHandler;\n\n const formSelector = this.config.context === 'checkout' ? 'form.checkout' : 'form#order_review';\n const formValues = jQuery(formSelector).serialize();\n\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n payer,\n bn_code:bnCode,\n context:this.config.context,\n order_id:this.config.order_id,\n form:formValues\n })\n }).then(function (res) {\n return res.json();\n }).then(function (data) {\n if (!data.success) {\n spinner.unblock();\n //handle both messages sent from Woocommerce (data.messages) and this plugin (data.data.message)\n if (typeof(data.messages) !== 'undefined' )\n {\n const domParser = new DOMParser();\n errorHandler.appendPreparedErrorMessageElement(\n domParser.parseFromString(data.messages, 'text/html')\n .querySelector('ul')\n );\n } else {\n errorHandler.message(data.data.message, true);\n }\n\n return;\n }\n const input = document.createElement('input');\n input.setAttribute('type', 'hidden');\n input.setAttribute('name', 'ppcp-resume-order');\n input.setAttribute('value', data.data.purchase_units[0].custom_id);\n document.querySelector(formSelector).append(input);\n return data.data.id;\n });\n }\n return {\n createOrder,\n onApprove:onApprove(this, this.errorHandler, this.spinner),\n onCancel: () => {\n spinner.unblock();\n },\n onError: () => {\n this.errorHandler.genericError();\n spinner.unblock();\n }\n }\n }\n}\n\nexport default CheckoutActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport CheckoutActionHandler from '../ActionHandler/CheckoutActionHandler';\n\nclass CheckoutBootstap {\n constructor(gateway, renderer, messages, spinner) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n this.spinner = spinner;\n }\n\n init() {\n\n this.render();\n\n jQuery(document.body).on('updated_checkout', () => {\n this.render()\n });\n\n jQuery(document.body).\n on('updated_checkout payment_method_selected', () => {\n this.switchBetweenPayPalandOrderButton()\n this.displayPlaceOrderButtonForSavedCreditCards()\n\n })\n\n jQuery('#saved-credit-card').on('change', () => {\n this.displayPlaceOrderButtonForSavedCreditCards()\n })\n\n this.switchBetweenPayPalandOrderButton()\n this.displayPlaceOrderButtonForSavedCreditCards()\n }\n\n shouldRender() {\n if (document.querySelector(this.gateway.button.cancel_wrapper)) {\n return false;\n }\n\n return document.querySelector(this.gateway.button.wrapper) !== null || document.querySelector(this.gateway.hosted_fields.wrapper) !== null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n if (document.querySelector(this.gateway.hosted_fields.wrapper + '>div')) {\n document.querySelector(this.gateway.hosted_fields.wrapper + '>div').setAttribute('style', '');\n }\n const actionHandler = new CheckoutActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n this.spinner\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n\n switchBetweenPayPalandOrderButton() {\n jQuery('#saved-credit-card').val(jQuery('#saved-credit-card option:first').val());\n\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n\n if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n jQuery('#place_order').show();\n }\n else {\n jQuery('#place_order').hide();\n if (currentPaymentMethod === 'ppcp-gateway') {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.messages.wrapper);\n this.messages.render()\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)\n }\n if (currentPaymentMethod === 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper)\n }\n }\n }\n\n displayPlaceOrderButtonForSavedCreditCards() {\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n if (currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n return;\n }\n\n if (jQuery('#saved-credit-card').length && jQuery('#saved-credit-card').val() !== '') {\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)\n jQuery('#place_order').show()\n } else {\n jQuery('#place_order').hide()\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper)\n }\n }\n}\n\nexport default CheckoutBootstap\n","import ErrorHandler from '../ErrorHandler';\nimport CheckoutActionHandler from '../ActionHandler/CheckoutActionHandler';\n\nclass PayNowBootstrap {\n constructor(gateway, renderer, messages, spinner) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n this.spinner = spinner;\n }\n\n init() {\n\n this.render();\n\n jQuery(document.body).on('updated_checkout', () => {\n this.render();\n });\n\n jQuery(document.body).\n on('updated_checkout payment_method_selected', () => {\n this.switchBetweenPayPalandOrderButton();\n });\n this.switchBetweenPayPalandOrderButton();\n }\n\n shouldRender() {\n if (document.querySelector(this.gateway.button.cancel_wrapper)) {\n return false;\n }\n\n return document.querySelector(this.gateway.button.wrapper) !== null || document.querySelector(this.gateway.hosted_fields.wrapper) !== null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n if (document.querySelector(this.gateway.hosted_fields.wrapper + '>div')) {\n document.querySelector(this.gateway.hosted_fields.wrapper + '>div').setAttribute('style', '');\n }\n const actionHandler = new CheckoutActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n this.spinner\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n\n switchBetweenPayPalandOrderButton() {\n const urlParams = new URLSearchParams(window.location.search)\n if (urlParams.has('change_payment_method')) {\n return\n }\n\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n\n if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n jQuery('#place_order').show();\n }\n else {\n jQuery('#place_order').hide();\n if (currentPaymentMethod === 'ppcp-gateway') {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.messages.wrapper);\n this.messages.render();\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n }\n if (currentPaymentMethod === 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper);\n }\n }\n }\n}\n\nexport default PayNowBootstrap;\n","class Renderer {\n constructor(creditCardRenderer, defaultConfig) {\n this.defaultConfig = defaultConfig;\n this.creditCardRenderer = creditCardRenderer;\n }\n\n render(wrapper, hostedFieldsWrapper, contextConfig) {\n\n this.renderButtons(wrapper, contextConfig);\n this.creditCardRenderer.render(hostedFieldsWrapper, contextConfig);\n }\n\n renderButtons(wrapper, contextConfig) {\n if (! document.querySelector(wrapper) || this.isAlreadyRendered(wrapper) || 'undefined' === typeof paypal.Buttons ) {\n return;\n }\n\n const style = wrapper === this.defaultConfig.button.wrapper ? this.defaultConfig.button.style : this.defaultConfig.button.mini_cart_style;\n paypal.Buttons({\n style,\n ...contextConfig,\n }).render(wrapper);\n }\n\n isAlreadyRendered(wrapper) {\n return document.querySelector(wrapper).hasChildNodes();\n }\n\n hideButtons(element) {\n const domElement = document.querySelector(element);\n if (! domElement ) {\n return false;\n }\n domElement.style.display = 'none';\n return true;\n }\n\n showButtons(element) {\n const domElement = document.querySelector(element);\n if (! domElement ) {\n return false;\n }\n domElement.style.display = 'block';\n return true;\n }\n}\n\nexport default Renderer;","const dccInputFactory = (original) => {\n const styles = window.getComputedStyle(original);\n const newElement = document.createElement('span');\n newElement.setAttribute('id', original.id);\n Object.values(styles).forEach( (prop) => {\n if (! styles[prop] || ! isNaN(prop) ) {\n return;\n }\n newElement.style.setProperty(prop,'' + styles[prop]);\n });\n return newElement;\n}\n\nexport default dccInputFactory;","import dccInputFactory from \"../Helper/DccInputFactory\";\n\nclass CreditCardRenderer {\n\n constructor(defaultConfig, errorHandler, spinner) {\n this.defaultConfig = defaultConfig;\n this.errorHandler = errorHandler;\n this.spinner = spinner;\n this.cardValid = false;\n }\n\n render(wrapper, contextConfig) {\n\n if (\n (\n this.defaultConfig.context !== 'checkout'\n && this.defaultConfig.context !== 'pay-now'\n )\n || wrapper === null\n || document.querySelector(wrapper) === null\n ) {\n return;\n }\n if (\n typeof paypal.HostedFields === 'undefined'\n || ! paypal.HostedFields.isEligible()\n ) {\n const wrapperElement = document.querySelector(wrapper);\n wrapperElement.parentNode.removeChild(wrapperElement);\n return;\n }\n\n const gateWayBox = document.querySelector('.payment_box.payment_method_ppcp-credit-card-gateway');\n const oldDisplayStyle = gateWayBox.style.display;\n gateWayBox.style.display = 'block';\n\n const hideDccGateway = document.querySelector('#ppcp-hide-dcc');\n if (hideDccGateway) {\n hideDccGateway.parentNode.removeChild(hideDccGateway);\n }\n\n const cardNumberField = document.querySelector('#ppcp-credit-card-gateway-card-number');\n\n const stylesRaw = window.getComputedStyle(cardNumberField);\n let styles = {};\n Object.values(stylesRaw).forEach( (prop) => {\n if (! stylesRaw[prop]) {\n return;\n }\n styles[prop] = '' + stylesRaw[prop];\n });\n\n const cardNumber = dccInputFactory(cardNumberField);\n cardNumberField.parentNode.replaceChild(cardNumber, cardNumberField);\n\n const cardExpiryField = document.querySelector('#ppcp-credit-card-gateway-card-expiry');\n const cardExpiry = dccInputFactory(cardExpiryField);\n cardExpiryField.parentNode.replaceChild(cardExpiry, cardExpiryField);\n\n const cardCodeField = document.querySelector('#ppcp-credit-card-gateway-card-cvc');\n const cardCode = dccInputFactory(cardCodeField);\n cardCodeField.parentNode.replaceChild(cardCode, cardCodeField);\n\n gateWayBox.style.display = oldDisplayStyle;\n\n const formWrapper = '.payment_box payment_method_ppcp-credit-card-gateway';\n if (\n this.defaultConfig.enforce_vault\n && document.querySelector(formWrapper + ' .ppcp-credit-card-vault')\n ) {\n document.querySelector(formWrapper + ' .ppcp-credit-card-vault').checked = true;\n document.querySelector(formWrapper + ' .ppcp-credit-card-vault').setAttribute('disabled', true);\n }\n paypal.HostedFields.render({\n createOrder: contextConfig.createOrder,\n styles: {\n 'input': styles\n },\n fields: {\n number: {\n selector: '#ppcp-credit-card-gateway-card-number',\n placeholder: this.defaultConfig.hosted_fields.labels.credit_card_number,\n },\n cvv: {\n selector: '#ppcp-credit-card-gateway-card-cvc',\n placeholder: this.defaultConfig.hosted_fields.labels.cvv,\n },\n expirationDate: {\n selector: '#ppcp-credit-card-gateway-card-expiry',\n placeholder: this.defaultConfig.hosted_fields.labels.mm_yyyy,\n }\n }\n }).then(hostedFields => {\n const submitEvent = (event) => {\n this.spinner.block();\n if (event) {\n event.preventDefault();\n }\n this.errorHandler.clear();\n const state = hostedFields.getState();\n const formValid = Object.keys(state.fields).every(function (key) {\n return state.fields[key].isValid;\n });\n\n if (formValid && this.cardValid) {\n const save_card = this.defaultConfig.save_card ? true : false;\n const vault = document.getElementById('ppcp-credit-card-vault') ?\n document.getElementById('ppcp-credit-card-vault').checked : save_card;\n hostedFields.submit({\n contingencies: ['3D_SECURE'],\n vault: vault\n }).then((payload) => {\n payload.orderID = payload.orderId;\n this.spinner.unblock();\n return contextConfig.onApprove(payload);\n }).catch(() => {\n this.errorHandler.genericError();\n this.spinner.unblock();\n });\n } else {\n this.spinner.unblock();\n const message = ! this.cardValid ? this.defaultConfig.hosted_fields.labels.card_not_supported : this.defaultConfig.hosted_fields.labels.fields_not_valid;\n this.errorHandler.message(message);\n }\n }\n hostedFields.on('inputSubmitRequest', function () {\n submitEvent(null);\n });\n hostedFields.on('cardTypeChange', (event) => {\n if ( ! event.cards.length ) {\n this.cardValid = false;\n return;\n }\n const validCards = this.defaultConfig.hosted_fields.valid_cards;\n this.cardValid = validCards.indexOf(event.cards[0].type) !== -1;\n })\n document.querySelector(wrapper + ' button').addEventListener(\n 'click',\n submitEvent\n );\n });\n\n document.querySelector('#payment_method_ppcp-credit-card-gateway').addEventListener(\n 'click',\n () => {\n document.querySelector('label[for=ppcp-credit-card-gateway-card-number]').click();\n }\n )\n }\n}\nexport default CreditCardRenderer;\n","const storageKey = 'ppcp-data-client-id';\n\nconst validateToken = (token, user) => {\n if (! token) {\n return false;\n }\n if (token.user !== user) {\n return false;\n }\n const currentTime = new Date().getTime();\n const isExpired = currentTime >= token.expiration * 1000;\n return ! isExpired;\n}\n\nconst storedTokenForUser = (user) => {\n const token = JSON.parse(sessionStorage.getItem(storageKey));\n if (validateToken(token, user)) {\n return token.token;\n }\n return null;\n}\n\nconst storeToken = (token) => {\n sessionStorage.setItem(storageKey, JSON.stringify(token));\n}\n\nconst dataClientIdAttributeHandler = (script, config) => {\n fetch(config.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: config.nonce\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n const isValid = validateToken(data, config.user);\n if (!isValid) {\n return;\n }\n storeToken(data);\n script.setAttribute('data-client-token', data.token);\n document.body.append(script);\n });\n}\n\nexport default dataClientIdAttributeHandler;\n","class MessageRenderer {\n\n constructor(config) {\n this.config = config;\n }\n\n render() {\n if (! this.shouldRender()) {\n return;\n }\n\n paypal.Messages({\n amount: this.config.amount,\n placement: this.config.placement,\n style: this.config.style\n }).render(this.config.wrapper);\n }\n\n renderWithAmount(amount) {\n\n if (! this.shouldRender()) {\n return;\n }\n\n const newWrapper = document.createElement('div');\n newWrapper.setAttribute('id', this.config.wrapper.replace('#', ''));\n\n const sibling = document.querySelector(this.config.wrapper).nextSibling;\n document.querySelector(this.config.wrapper).parentElement.removeChild(document.querySelector(this.config.wrapper));\n sibling.parentElement.insertBefore(newWrapper, sibling);\n paypal.Messages({\n amount,\n placement: this.config.placement,\n style: this.config.style\n }).render(this.config.wrapper);\n }\n\n shouldRender() {\n\n if (typeof paypal.Messages === 'undefined' || typeof this.config.wrapper === 'undefined' ) {\n return false;\n }\n if (! document.querySelector(this.config.wrapper)) {\n return false;\n }\n return true;\n }\n}\nexport default MessageRenderer;","class Spinner {\n\n constructor() {\n this.target = 'form.woocommerce-checkout';\n }\n\n setTarget(target) {\n this.target = target;\n }\n\n block() {\n\n jQuery( this.target ).block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n unblock() {\n\n jQuery( this.target ).unblock();\n }\n}\n\nexport default Spinner;\n","import MiniCartBootstap from './modules/ContextBootstrap/MiniCartBootstap';\nimport SingleProductBootstap from './modules/ContextBootstrap/SingleProductBootstap';\nimport CartBootstrap from './modules/ContextBootstrap/CartBootstap';\nimport CheckoutBootstap from './modules/ContextBootstrap/CheckoutBootstap';\nimport PayNowBootstrap from \"./modules/ContextBootstrap/PayNowBootstrap\";\nimport Renderer from './modules/Renderer/Renderer';\nimport ErrorHandler from './modules/ErrorHandler';\nimport CreditCardRenderer from \"./modules/Renderer/CreditCardRenderer\";\nimport dataClientIdAttributeHandler from \"./modules/DataClientIdAttributeHandler\";\nimport MessageRenderer from \"./modules/Renderer/MessageRenderer\";\nimport Spinner from \"./modules/Helper/Spinner\";\n\nconst bootstrap = () => {\n const errorHandler = new ErrorHandler(PayPalCommerceGateway.labels.error.generic);\n const spinner = new Spinner();\n const creditCardRenderer = new CreditCardRenderer(PayPalCommerceGateway, errorHandler, spinner);\n const renderer = new Renderer(creditCardRenderer, PayPalCommerceGateway);\n const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages);\n const context = PayPalCommerceGateway.context;\n if (context === 'mini-cart' || context === 'product') {\n const miniCartBootstrap = new MiniCartBootstap(\n PayPalCommerceGateway,\n renderer\n );\n\n miniCartBootstrap.init();\n }\n\n if (context === 'product') {\n const singleProductBootstrap = new SingleProductBootstap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n );\n\n singleProductBootstrap.init();\n }\n\n if (context === 'cart') {\n const cartBootstrap = new CartBootstrap(\n PayPalCommerceGateway,\n renderer,\n );\n\n cartBootstrap.init();\n }\n\n if (context === 'checkout') {\n const checkoutBootstap = new CheckoutBootstap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n spinner\n );\n\n checkoutBootstap.init();\n }\n\n if (context === 'pay-now' ) {\n const payNowBootstrap = new PayNowBootstrap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n spinner\n );\n payNowBootstrap.init();\n }\n\n if (context !== 'checkout') {\n messageRenderer.render();\n }\n};\ndocument.addEventListener(\n 'DOMContentLoaded',\n () => {\n if (!typeof (PayPalCommerceGateway)) {\n console.error('PayPal button could not be configured.');\n return;\n }\n const script = document.createElement('script');\n\n script.addEventListener('load', (event) => {\n bootstrap();\n });\n script.setAttribute('src', PayPalCommerceGateway.button.url);\n Object.entries(PayPalCommerceGateway.script_attributes).forEach(\n (keyValue) => {\n script.setAttribute(keyValue[0], keyValue[1]);\n }\n );\n\n if (PayPalCommerceGateway.data_client_id.set_attribute) {\n dataClientIdAttributeHandler(script, PayPalCommerceGateway.data_client_id);\n return;\n }\n\n document.body.append(script);\n },\n);\n"],"sourceRoot":""}
|
1 |
+
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./resources/js/modules/ErrorHandler.js","webpack:///./resources/js/modules/OnApproveHandler/onApproveForContinue.js","webpack:///./resources/js/modules/Helper/PayerData.js","webpack:///./resources/js/modules/ActionHandler/CartActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/MiniCartBootstap.js","webpack:///./resources/js/modules/Entity/Product.js","webpack:///./resources/js/modules/Helper/UpdateCart.js","webpack:///./resources/js/modules/Helper/ButtonsToggleListener.js","webpack:///./resources/js/modules/ActionHandler/SingleProductActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/SingleProductBootstap.js","webpack:///./resources/js/modules/ContextBootstrap/CartBootstap.js","webpack:///./resources/js/modules/OnApproveHandler/onApproveForPayNow.js","webpack:///./resources/js/modules/ActionHandler/CheckoutActionHandler.js","webpack:///./resources/js/modules/ContextBootstrap/CheckoutBootstap.js","webpack:///./resources/js/modules/ContextBootstrap/PayNowBootstrap.js","webpack:///./resources/js/modules/Renderer/Renderer.js","webpack:///./resources/js/modules/Helper/DccInputFactory.js","webpack:///./resources/js/modules/Renderer/CreditCardRenderer.js","webpack:///./resources/js/modules/DataClientIdAttributeHandler.js","webpack:///./resources/js/modules/Renderer/MessageRenderer.js","webpack:///./resources/js/modules/Helper/Spinner.js","webpack:///./resources/js/button.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","ErrorHandler","constructor","genericErrorText","this","wrapper","document","querySelector","messagesList","genericError","classList","contains","clear","message","appendPreparedErrorMessageElement","errorMessageElement","prepareMessagesList","replaceWith","text","persist","length","Error","add","remove","messageNode","prepareMessagesListItem","appendChild","jQuery","scroll_to_notices","createElement","setAttribute","li","innerHTML","sanitize","textarea","replace","innerText","onApprove","context","errorHandler","data","actions","fetch","config","ajax","approve_order","endpoint","method","body","JSON","stringify","nonce","order_id","orderID","then","res","json","success","restart","catch","err","location","href","redirect","payerData","payer","PayPalCommerceGateway","phone","phone_type","phone_number","national_number","email_address","surname","given_name","address","country_code","address_line_1","address_line_2","admin_area_1","admin_area_2","postal_code","CartActionHandler","configuration","createOrder","bnCode","bn_codes","create_order","purchase_units","bn_code","console","error","id","onError","MiniCartBootstap","gateway","renderer","actionHandler","init","labels","generic","render","on","shouldRender","button","mini_cart_wrapper","hosted_fields","Product","quantity","variations","UpdateCart","update","onResolve","products","Promise","resolve","reject","result","resolved","ButtonsToggleListener","element","showCallback","hideCallback","observer","callback","MutationObserver","observe","attributes","disconnect","SingleProductActionHandler","updateCart","showButtonCallback","hideButtonCallback","formElement","hasVariations","getProducts","isGroupedProduct","querySelectorAll","forEach","elementName","getAttribute","match","parseInt","push","qty","map","SingleProductBootstap","messages","hideButtons","change_cart","showButtons","priceText","amount","renderWithAmount","CartBootstrap","spinner","block","unblock","code","click","CheckoutActionHandler","formSelector","formValues","serialize","form","domParser","DOMParser","parseFromString","input","custom_id","append","onCancel","CheckoutBootstap","switchBetweenPayPalandOrderButton","displayPlaceOrderButtonForSavedCreditCards","cancel_wrapper","val","currentPaymentMethod","show","hide","PayNowBootstrap","URLSearchParams","window","search","has","Renderer","creditCardRenderer","defaultConfig","hostedFieldsWrapper","contextConfig","renderButtons","isAlreadyRendered","paypal","Buttons","style","mini_cart_style","hasChildNodes","domElement","display","dccInputFactory","original","styles","getComputedStyle","newElement","values","prop","isNaN","setProperty","CreditCardRenderer","cardValid","HostedFields","isEligible","wrapperElement","parentNode","removeChild","gateWayBox","oldDisplayStyle","hideDccGateway","cardNumberField","stylesRaw","cardNumber","replaceChild","cardExpiryField","cardExpiry","cardCodeField","cardCode","formWrapper","enforce_vault","checked","fields","number","selector","placeholder","credit_card_number","cvv","expirationDate","mm_yy","hostedFields","submitEvent","event","preventDefault","state","getState","keys","every","isValid","save_card","vault","getElementById","submit","contingencies","payload","orderId","fields_not_valid","card_not_supported","cards","validCards","valid_cards","indexOf","type","addEventListener","validateToken","token","user","Date","getTime","expiration","dataClientIdAttributeHandler","script","sessionStorage","setItem","MessageRenderer","Messages","placement","newWrapper","sibling","nextSibling","parentElement","insertBefore","Spinner","target","setTarget","overlayCSS","background","opacity","messageRenderer","bootstrap","url","entries","script_attributes","keyValue","data_client_id","set_attribute"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAA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ACtC,GAAgB,cAAZA,GAAuC,YAAZA,EAAuB,CACxB,IAAIuD,EAC1B3B,sBACA6B,GAGcE,OAGtB,GAAgB,YAAZ3D,EAAuB,CACQ,IAAI2G,EAC/B/E,sBACA6B,EACA6L,GAGmB3L,OAG3B,GAAgB,SAAZ3D,EAAoB,CACE,IAAImH,EACtBvF,sBACA6B,GAGUE,OAGlB,GAAgB,aAAZ3D,EAAwB,CACC,IAAIqI,EACzBzG,sBACA6B,EACA6L,EACAlI,GAGazD,OAGrB,GAAgB,YAAZ3D,EAAwB,CACA,IAAI6I,EACxBjH,sBACA6B,EACA6L,EACAlI,GAEYzD,OAGJ,aAAZ3D,GACAsP,EAAgBxL,UAaZyL,KAEJlB,EAAO7O,aAAa,MAAOoC,sBAAsBqC,OAAOuL,KACxDnT,OAAOoT,QAAQ7N,sBAAsB8N,mBAAmBvJ,QACnDwJ,IACGtB,EAAO7O,aAAamQ,EAAS,GAAIA,EAAS,MAI9C/N,sBAAsBgO,eAAeC,cACrCzB,EAA6BC,EAAQzM,sBAAsBgO,gBAI/D5R,SAAS0C,KAAKyH,OAAOkG","file":"js/button.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","class ErrorHandler {\n\n constructor(genericErrorText)\n {\n this.genericErrorText = genericErrorText;\n this.wrapper = document.querySelector('.woocommerce-notices-wrapper');\n this.messagesList = document.querySelector('ul.woocommerce-error');\n }\n\n genericError() {\n if (this.wrapper.classList.contains('ppcp-persist')) {\n return;\n }\n this.clear();\n this.message(this.genericErrorText)\n }\n\n appendPreparedErrorMessageElement(errorMessageElement)\n {\n if(this.messagesList === null) {\n this.prepareMessagesList();\n }\n\n this.messagesList.replaceWith(errorMessageElement);\n }\n\n message(text, persist = false)\n {\n if(! typeof String || text.length === 0){\n throw new Error('A new message text must be a non-empty string.');\n }\n\n if(this.messagesList === null){\n this.prepareMessagesList();\n }\n\n if (persist) {\n this.wrapper.classList.add('ppcp-persist');\n } else {\n this.wrapper.classList.remove('ppcp-persist');\n }\n\n let messageNode = this.prepareMessagesListItem(text);\n this.messagesList.appendChild(messageNode);\n\n jQuery.scroll_to_notices(jQuery('.woocommerce-notices-wrapper'))\n }\n\n prepareMessagesList()\n {\n if(this.messagesList === null){\n this.messagesList = document.createElement('ul');\n this.messagesList.setAttribute('class', 'woocommerce-error');\n this.messagesList.setAttribute('role', 'alert');\n this.wrapper.appendChild(this.messagesList);\n }\n }\n\n prepareMessagesListItem(message)\n {\n const li = document.createElement('li');\n li.innerHTML = message;\n\n return li;\n }\n\n sanitize(text)\n {\n const textarea = document.createElement('textarea');\n textarea.innerHTML = text;\n return textarea.value.replace('Error: ', '');\n }\n\n clear()\n {\n if (! this.wrapper.classList.contains('woocommerce-error')) {\n return;\n }\n this.wrapper.classList.remove('woocommerce-error');\n this.wrapper.innerText = '';\n }\n}\n\nexport default ErrorHandler;\n","const onApprove = (context, errorHandler) => {\n return (data, actions) => {\n return fetch(context.config.ajax.approve_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: context.config.ajax.approve_order.nonce,\n order_id:data.orderID\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n if (!data.success) {\n errorHandler.genericError();\n return actions.restart().catch(err => {\n errorHandler.genericError();\n });;\n }\n location.href = context.config.redirect;\n });\n\n }\n}\n\nexport default onApprove;\n","export const payerData = () => {\n const payer = PayPalCommerceGateway.payer;\n if (! payer) {\n return null;\n }\n\n const phone = (document.querySelector('#billing_phone') || typeof payer.phone !== 'undefined') ?\n {\n phone_type:\"HOME\",\n phone_number:{\n national_number : (document.querySelector('#billing_phone')) ? document.querySelector('#billing_phone').value : payer.phone.phone_number.national_number\n }\n } : null;\n const payerData = {\n email_address:(document.querySelector('#billing_email')) ? document.querySelector('#billing_email').value : payer.email_address,\n name : {\n surname: (document.querySelector('#billing_last_name')) ? document.querySelector('#billing_last_name').value : payer.name.surname,\n given_name: (document.querySelector('#billing_first_name')) ? document.querySelector('#billing_first_name').value : payer.name.given_name\n },\n address : {\n country_code : (document.querySelector('#billing_country')) ? document.querySelector('#billing_country').value : payer.address.country_code,\n address_line_1 : (document.querySelector('#billing_address_1')) ? document.querySelector('#billing_address_1').value : payer.address.address_line_1,\n address_line_2 : (document.querySelector('#billing_address_2')) ? document.querySelector('#billing_address_2').value : payer.address.address_line_2,\n admin_area_1 : (document.querySelector('#billing_state')) ? document.querySelector('#billing_state').value : payer.address.admin_area_1,\n admin_area_2 : (document.querySelector('#billing_city')) ? document.querySelector('#billing_city').value : payer.address.admin_area_2,\n postal_code : (document.querySelector('#billing_postcode')) ? document.querySelector('#billing_postcode').value : payer.address.postal_code\n }\n };\n\n if (phone) {\n payerData.phone = phone;\n }\n return payerData;\n}\n","import onApprove from '../OnApproveHandler/onApproveForContinue.js';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass CartActionHandler {\n\n constructor(config, errorHandler) {\n this.config = config;\n this.errorHandler = errorHandler;\n }\n\n configuration() {\n const createOrder = (data, actions) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n purchase_units: [],\n bn_code:bnCode,\n payer,\n context:this.config.context\n }),\n }).then(function(res) {\n return res.json();\n }).then(function(data) {\n if (!data.success) {\n console.error(data);\n throw Error(data.data.message);\n }\n return data.data.id;\n });\n };\n\n return {\n createOrder,\n onApprove: onApprove(this, this.errorHandler),\n onError: (error) => {\n this.errorHandler.genericError();\n }\n };\n }\n}\n\nexport default CartActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport CartActionHandler from '../ActionHandler/CartActionHandler';\n\nclass MiniCartBootstap {\n constructor(gateway, renderer) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.actionHandler = null;\n }\n\n init() {\n\n this.actionHandler = new CartActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n this.render();\n\n jQuery(document.body).on('wc_fragments_loaded wc_fragments_refreshed', () => {\n this.render();\n });\n }\n\n shouldRender() {\n return document.querySelector(this.gateway.button.mini_cart_wrapper) !==\n null || document.querySelector(this.gateway.hosted_fields.mini_cart_wrapper) !==\n null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n\n this.renderer.render(\n this.gateway.button.mini_cart_wrapper,\n this.gateway.hosted_fields.mini_cart_wrapper,\n this.actionHandler.configuration()\n );\n }\n}\n\nexport default MiniCartBootstap;","class Product {\n\n constructor(id, quantity, variations) {\n this.id = id;\n this.quantity = quantity;\n this.variations = variations;\n }\n\n data() {\n return {\n id:this.id,\n quantity:this.quantity,\n variations:this.variations\n }\n }\n}\n\nexport default Product;","import Product from \"../Entity/Product\";\nclass UpdateCart {\n\n constructor(endpoint, nonce)\n {\n this.endpoint = endpoint;\n this.nonce = nonce;\n }\n\n /**\n *\n * @param onResolve\n * @param {Product[]} products\n * @returns {Promise<unknown>}\n */\n update(onResolve, products)\n {\n return new Promise((resolve, reject) => {\n fetch(\n this.endpoint,\n {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.nonce,\n products,\n })\n }\n ).then(\n (result) => {\n return result.json();\n }\n ).then((result) => {\n if (! result.success) {\n reject(result.data);\n return;\n }\n\n const resolved = onResolve(result.data);\n resolve(resolved);\n })\n });\n }\n}\n\nexport default UpdateCart;","/**\n * When you can't add something to the cart, the PayPal buttons should not show.\n * Therefore we listen for changes on the add to cart button and show/hide the buttons accordingly.\n */\n\nclass ButtonsToggleListener {\n constructor(element, showCallback, hideCallback)\n {\n this.element = element;\n this.showCallback = showCallback;\n this.hideCallback = hideCallback;\n this.observer = null;\n }\n\n init()\n {\n const config = { attributes : true };\n const callback = () => {\n if (this.element.classList.contains('disabled')) {\n this.hideCallback();\n return;\n }\n this.showCallback();\n }\n this.observer = new MutationObserver(callback);\n this.observer.observe(this.element, config);\n callback();\n }\n\n disconnect()\n {\n this.observer.disconnect();\n }\n}\n\nexport default ButtonsToggleListener;","import ButtonsToggleListener from '../Helper/ButtonsToggleListener';\nimport Product from '../Entity/Product';\nimport onApprove from '../OnApproveHandler/onApproveForContinue';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass SingleProductActionHandler {\n\n constructor(\n config,\n updateCart,\n showButtonCallback,\n hideButtonCallback,\n formElement,\n errorHandler\n ) {\n this.config = config;\n this.updateCart = updateCart;\n this.showButtonCallback = showButtonCallback;\n this.hideButtonCallback = hideButtonCallback;\n this.formElement = formElement;\n this.errorHandler = errorHandler;\n }\n\n configuration()\n {\n\n if ( this.hasVariations() ) {\n const observer = new ButtonsToggleListener(\n this.formElement.querySelector('.single_add_to_cart_button'),\n this.showButtonCallback,\n this.hideButtonCallback\n );\n observer.init();\n }\n\n return {\n createOrder: this.createOrder(),\n onApprove: onApprove(this, this.errorHandler),\n onError: (error) => {\n this.errorHandler.genericError();\n }\n }\n }\n\n createOrder()\n {\n var getProducts = null;\n if (! this.isGroupedProduct() ) {\n getProducts = () => {\n const id = document.querySelector('[name=\"add-to-cart\"]').value;\n const qty = document.querySelector('[name=\"quantity\"]').value;\n const variations = this.variations();\n return [new Product(id, qty, variations)];\n }\n } else {\n getProducts = () => {\n const products = [];\n this.formElement.querySelectorAll('input[type=\"number\"]').forEach((element) => {\n if (! element.value) {\n return;\n }\n const elementName = element.getAttribute('name').match(/quantity\\[([\\d]*)\\]/);\n if (elementName.length !== 2) {\n return;\n }\n const id = parseInt(elementName[1]);\n const quantity = parseInt(element.value);\n products.push(new Product(id, quantity, null));\n })\n return products;\n }\n }\n const createOrder = (data, actions) => {\n this.errorHandler.clear();\n\n const onResolve = (purchase_units) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n purchase_units,\n payer,\n bn_code:bnCode,\n context:this.config.context\n })\n }).then(function (res) {\n return res.json();\n }).then(function (data) {\n if (!data.success) {\n console.error(data);\n throw Error(data.data.message);\n }\n return data.data.id;\n });\n };\n\n const promise = this.updateCart.update(onResolve, getProducts());\n return promise;\n };\n return createOrder;\n }\n\n variations()\n {\n\n if (! this.hasVariations()) {\n return null;\n }\n const attributes = [...this.formElement.querySelectorAll(\"[name^='attribute_']\")].map(\n (element) => {\n return {\n value:element.value,\n name:element.name\n }\n }\n );\n return attributes;\n }\n\n hasVariations()\n {\n return this.formElement.classList.contains('variations_form');\n }\n\n isGroupedProduct()\n {\n return this.formElement.classList.contains('grouped_form');\n }\n}\nexport default SingleProductActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport UpdateCart from \"../Helper/UpdateCart\";\nimport SingleProductActionHandler from \"../ActionHandler/SingleProductActionHandler\";\n\nclass SingleProductBootstap {\n constructor(gateway, renderer, messages) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n }\n\n init() {\n if (!this.shouldRender()) {\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n return;\n }\n\n this.render();\n }\n\n shouldRender() {\n if (document.querySelector('form.cart') === null) {\n return false;\n }\n\n return true;\n }\n\n render() {\n const actionHandler = new SingleProductActionHandler(\n this.gateway,\n new UpdateCart(\n this.gateway.ajax.change_cart.endpoint,\n this.gateway.ajax.change_cart.nonce,\n ),\n () => {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper);\n let priceText = \"0\";\n if (document.querySelector('form.cart ins .woocommerce-Price-amount')) {\n priceText = document.querySelector('form.cart ins .woocommerce-Price-amount').innerText;\n }\n else if (document.querySelector('form.cart .woocommerce-Price-amount')) {\n priceText = document.querySelector('form.cart .woocommerce-Price-amount').innerText;\n }\n const amount = parseInt(priceText.replace(/([^\\d,\\.\\s]*)/g, ''));\n this.messages.renderWithAmount(amount)\n },\n () => {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n },\n document.querySelector('form.cart'),\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n}\n\nexport default SingleProductBootstap;","import CartActionHandler from '../ActionHandler/CartActionHandler';\nimport ErrorHandler from '../ErrorHandler';\n\nclass CartBootstrap {\n constructor(gateway, renderer) {\n this.gateway = gateway;\n this.renderer = renderer;\n }\n\n init() {\n if (!this.shouldRender()) {\n return;\n }\n\n this.render();\n\n jQuery(document.body).on('updated_cart_totals updated_checkout', () => {\n this.render();\n });\n }\n\n shouldRender() {\n return document.querySelector(this.gateway.button.wrapper) !==\n null || document.querySelector(this.gateway.hosted_fields.wrapper) !==\n null;\n }\n\n render() {\n const actionHandler = new CartActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n}\n\nexport default CartBootstrap;","const onApprove = (context, errorHandler, spinner) => {\n return (data, actions) => {\n spinner.block();\n return fetch(context.config.ajax.approve_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: context.config.ajax.approve_order.nonce,\n order_id:data.orderID\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n spinner.unblock();\n if (!data.success) {\n if (data.data.code === 100) {\n errorHandler.message(data.data.message);\n } else {\n errorHandler.genericError();\n }\n if (typeof actions !== 'undefined' && typeof actions.restart !== 'undefined') {\n return actions.restart();\n }\n throw new Error(data.data.message);\n }\n document.querySelector('#place_order').click()\n });\n\n }\n}\n\nexport default onApprove;\n","import onApprove from '../OnApproveHandler/onApproveForPayNow.js';\nimport {payerData} from \"../Helper/PayerData\";\n\nclass CheckoutActionHandler {\n\n constructor(config, errorHandler, spinner) {\n this.config = config;\n this.errorHandler = errorHandler;\n this.spinner = spinner;\n }\n\n configuration() {\n const spinner = this.spinner;\n const createOrder = (data, actions) => {\n const payer = payerData();\n const bnCode = typeof this.config.bn_codes[this.config.context] !== 'undefined' ?\n this.config.bn_codes[this.config.context] : '';\n\n const errorHandler = this.errorHandler;\n\n const formSelector = this.config.context === 'checkout' ? 'form.checkout' : 'form#order_review';\n const formValues = jQuery(formSelector).serialize();\n\n return fetch(this.config.ajax.create_order.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: this.config.ajax.create_order.nonce,\n payer,\n bn_code:bnCode,\n context:this.config.context,\n order_id:this.config.order_id,\n form:formValues\n })\n }).then(function (res) {\n return res.json();\n }).then(function (data) {\n if (!data.success) {\n spinner.unblock();\n //handle both messages sent from Woocommerce (data.messages) and this plugin (data.data.message)\n if (typeof(data.messages) !== 'undefined' )\n {\n const domParser = new DOMParser();\n errorHandler.appendPreparedErrorMessageElement(\n domParser.parseFromString(data.messages, 'text/html')\n .querySelector('ul')\n );\n } else {\n errorHandler.message(data.data.message, true);\n }\n\n return;\n }\n const input = document.createElement('input');\n input.setAttribute('type', 'hidden');\n input.setAttribute('name', 'ppcp-resume-order');\n input.setAttribute('value', data.data.purchase_units[0].custom_id);\n document.querySelector(formSelector).append(input);\n return data.data.id;\n });\n }\n return {\n createOrder,\n onApprove:onApprove(this, this.errorHandler, this.spinner),\n onCancel: () => {\n spinner.unblock();\n },\n onError: () => {\n this.errorHandler.genericError();\n spinner.unblock();\n }\n }\n }\n}\n\nexport default CheckoutActionHandler;\n","import ErrorHandler from '../ErrorHandler';\nimport CheckoutActionHandler from '../ActionHandler/CheckoutActionHandler';\n\nclass CheckoutBootstap {\n constructor(gateway, renderer, messages, spinner) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n this.spinner = spinner;\n }\n\n init() {\n\n this.render();\n\n jQuery(document.body).on('updated_checkout', () => {\n this.render()\n });\n\n jQuery(document.body).\n on('updated_checkout payment_method_selected', () => {\n this.switchBetweenPayPalandOrderButton()\n this.displayPlaceOrderButtonForSavedCreditCards()\n\n })\n\n jQuery('#saved-credit-card').on('change', () => {\n this.displayPlaceOrderButtonForSavedCreditCards()\n })\n\n this.switchBetweenPayPalandOrderButton()\n this.displayPlaceOrderButtonForSavedCreditCards()\n }\n\n shouldRender() {\n if (document.querySelector(this.gateway.button.cancel_wrapper)) {\n return false;\n }\n\n return document.querySelector(this.gateway.button.wrapper) !== null || document.querySelector(this.gateway.hosted_fields.wrapper) !== null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n if (document.querySelector(this.gateway.hosted_fields.wrapper + '>div')) {\n document.querySelector(this.gateway.hosted_fields.wrapper + '>div').setAttribute('style', '');\n }\n const actionHandler = new CheckoutActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n this.spinner\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n\n switchBetweenPayPalandOrderButton() {\n jQuery('#saved-credit-card').val(jQuery('#saved-credit-card option:first').val());\n\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n\n if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n jQuery('#place_order').show();\n }\n else {\n jQuery('#place_order').hide();\n if (currentPaymentMethod === 'ppcp-gateway') {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.messages.wrapper);\n this.messages.render()\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)\n }\n if (currentPaymentMethod === 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper)\n }\n }\n }\n\n displayPlaceOrderButtonForSavedCreditCards() {\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n if (currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n return;\n }\n\n if (jQuery('#saved-credit-card').length && jQuery('#saved-credit-card').val() !== '') {\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper)\n jQuery('#place_order').show()\n } else {\n jQuery('#place_order').hide()\n this.renderer.hideButtons(this.gateway.button.wrapper)\n this.renderer.hideButtons(this.gateway.messages.wrapper)\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper)\n }\n }\n}\n\nexport default CheckoutBootstap\n","import ErrorHandler from '../ErrorHandler';\nimport CheckoutActionHandler from '../ActionHandler/CheckoutActionHandler';\n\nclass PayNowBootstrap {\n constructor(gateway, renderer, messages, spinner) {\n this.gateway = gateway;\n this.renderer = renderer;\n this.messages = messages;\n this.spinner = spinner;\n }\n\n init() {\n\n this.render();\n\n jQuery(document.body).on('updated_checkout', () => {\n this.render();\n });\n\n jQuery(document.body).\n on('updated_checkout payment_method_selected', () => {\n this.switchBetweenPayPalandOrderButton();\n });\n this.switchBetweenPayPalandOrderButton();\n }\n\n shouldRender() {\n if (document.querySelector(this.gateway.button.cancel_wrapper)) {\n return false;\n }\n\n return document.querySelector(this.gateway.button.wrapper) !== null || document.querySelector(this.gateway.hosted_fields.wrapper) !== null;\n }\n\n render() {\n if (!this.shouldRender()) {\n return;\n }\n if (document.querySelector(this.gateway.hosted_fields.wrapper + '>div')) {\n document.querySelector(this.gateway.hosted_fields.wrapper + '>div').setAttribute('style', '');\n }\n const actionHandler = new CheckoutActionHandler(\n PayPalCommerceGateway,\n new ErrorHandler(this.gateway.labels.error.generic),\n this.spinner\n );\n\n this.renderer.render(\n this.gateway.button.wrapper,\n this.gateway.hosted_fields.wrapper,\n actionHandler.configuration(),\n );\n }\n\n switchBetweenPayPalandOrderButton() {\n const urlParams = new URLSearchParams(window.location.search)\n if (urlParams.has('change_payment_method')) {\n return\n }\n\n const currentPaymentMethod = jQuery(\n 'input[name=\"payment_method\"]:checked').val();\n\n if (currentPaymentMethod !== 'ppcp-gateway' && currentPaymentMethod !== 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n jQuery('#place_order').show();\n }\n else {\n jQuery('#place_order').hide();\n if (currentPaymentMethod === 'ppcp-gateway') {\n this.renderer.showButtons(this.gateway.button.wrapper);\n this.renderer.showButtons(this.gateway.messages.wrapper);\n this.messages.render();\n this.renderer.hideButtons(this.gateway.hosted_fields.wrapper);\n }\n if (currentPaymentMethod === 'ppcp-credit-card-gateway') {\n this.renderer.hideButtons(this.gateway.button.wrapper);\n this.renderer.hideButtons(this.gateway.messages.wrapper);\n this.renderer.showButtons(this.gateway.hosted_fields.wrapper);\n }\n }\n }\n}\n\nexport default PayNowBootstrap;\n","class Renderer {\n constructor(creditCardRenderer, defaultConfig) {\n this.defaultConfig = defaultConfig;\n this.creditCardRenderer = creditCardRenderer;\n }\n\n render(wrapper, hostedFieldsWrapper, contextConfig) {\n\n this.renderButtons(wrapper, contextConfig);\n this.creditCardRenderer.render(hostedFieldsWrapper, contextConfig);\n }\n\n renderButtons(wrapper, contextConfig) {\n if (! document.querySelector(wrapper) || this.isAlreadyRendered(wrapper) || 'undefined' === typeof paypal.Buttons ) {\n return;\n }\n\n const style = wrapper === this.defaultConfig.button.wrapper ? this.defaultConfig.button.style : this.defaultConfig.button.mini_cart_style;\n paypal.Buttons({\n style,\n ...contextConfig,\n }).render(wrapper);\n }\n\n isAlreadyRendered(wrapper) {\n return document.querySelector(wrapper).hasChildNodes();\n }\n\n hideButtons(element) {\n const domElement = document.querySelector(element);\n if (! domElement ) {\n return false;\n }\n domElement.style.display = 'none';\n return true;\n }\n\n showButtons(element) {\n const domElement = document.querySelector(element);\n if (! domElement ) {\n return false;\n }\n domElement.style.display = 'block';\n return true;\n }\n}\n\nexport default Renderer;","const dccInputFactory = (original) => {\n const styles = window.getComputedStyle(original);\n const newElement = document.createElement('span');\n newElement.setAttribute('id', original.id);\n Object.values(styles).forEach( (prop) => {\n if (! styles[prop] || ! isNaN(prop) ) {\n return;\n }\n newElement.style.setProperty(prop,'' + styles[prop]);\n });\n return newElement;\n}\n\nexport default dccInputFactory;","import dccInputFactory from \"../Helper/DccInputFactory\";\n\nclass CreditCardRenderer {\n\n constructor(defaultConfig, errorHandler, spinner) {\n this.defaultConfig = defaultConfig;\n this.errorHandler = errorHandler;\n this.spinner = spinner;\n this.cardValid = false;\n }\n\n render(wrapper, contextConfig) {\n\n if (\n (\n this.defaultConfig.context !== 'checkout'\n && this.defaultConfig.context !== 'pay-now'\n )\n || wrapper === null\n || document.querySelector(wrapper) === null\n ) {\n return;\n }\n if (\n typeof paypal.HostedFields === 'undefined'\n || ! paypal.HostedFields.isEligible()\n ) {\n const wrapperElement = document.querySelector(wrapper);\n wrapperElement.parentNode.removeChild(wrapperElement);\n return;\n }\n\n const gateWayBox = document.querySelector('.payment_box.payment_method_ppcp-credit-card-gateway');\n const oldDisplayStyle = gateWayBox.style.display;\n gateWayBox.style.display = 'block';\n\n const hideDccGateway = document.querySelector('#ppcp-hide-dcc');\n if (hideDccGateway) {\n hideDccGateway.parentNode.removeChild(hideDccGateway);\n }\n\n const cardNumberField = document.querySelector('#ppcp-credit-card-gateway-card-number');\n\n const stylesRaw = window.getComputedStyle(cardNumberField);\n let styles = {};\n Object.values(stylesRaw).forEach( (prop) => {\n if (! stylesRaw[prop]) {\n return;\n }\n styles[prop] = '' + stylesRaw[prop];\n });\n\n const cardNumber = dccInputFactory(cardNumberField);\n cardNumberField.parentNode.replaceChild(cardNumber, cardNumberField);\n\n const cardExpiryField = document.querySelector('#ppcp-credit-card-gateway-card-expiry');\n const cardExpiry = dccInputFactory(cardExpiryField);\n cardExpiryField.parentNode.replaceChild(cardExpiry, cardExpiryField);\n\n const cardCodeField = document.querySelector('#ppcp-credit-card-gateway-card-cvc');\n const cardCode = dccInputFactory(cardCodeField);\n cardCodeField.parentNode.replaceChild(cardCode, cardCodeField);\n\n gateWayBox.style.display = oldDisplayStyle;\n\n const formWrapper = '.payment_box payment_method_ppcp-credit-card-gateway';\n if (\n this.defaultConfig.enforce_vault\n && document.querySelector(formWrapper + ' .ppcp-credit-card-vault')\n ) {\n document.querySelector(formWrapper + ' .ppcp-credit-card-vault').checked = true;\n document.querySelector(formWrapper + ' .ppcp-credit-card-vault').setAttribute('disabled', true);\n }\n paypal.HostedFields.render({\n createOrder: contextConfig.createOrder,\n styles: {\n 'input': styles\n },\n fields: {\n number: {\n selector: '#ppcp-credit-card-gateway-card-number',\n placeholder: this.defaultConfig.hosted_fields.labels.credit_card_number,\n },\n cvv: {\n selector: '#ppcp-credit-card-gateway-card-cvc',\n placeholder: this.defaultConfig.hosted_fields.labels.cvv,\n },\n expirationDate: {\n selector: '#ppcp-credit-card-gateway-card-expiry',\n placeholder: this.defaultConfig.hosted_fields.labels.mm_yy,\n }\n }\n }).then(hostedFields => {\n const submitEvent = (event) => {\n this.spinner.block();\n if (event) {\n event.preventDefault();\n }\n this.errorHandler.clear();\n const state = hostedFields.getState();\n const formValid = Object.keys(state.fields).every(function (key) {\n return state.fields[key].isValid;\n });\n\n if (formValid && this.cardValid) {\n const save_card = this.defaultConfig.save_card ? true : false;\n const vault = document.getElementById('ppcp-credit-card-vault') ?\n document.getElementById('ppcp-credit-card-vault').checked : save_card;\n hostedFields.submit({\n contingencies: ['3D_SECURE'],\n vault: vault\n }).then((payload) => {\n payload.orderID = payload.orderId;\n this.spinner.unblock();\n return contextConfig.onApprove(payload);\n }).catch(() => {\n this.errorHandler.genericError();\n this.spinner.unblock();\n });\n } else {\n this.spinner.unblock();\n const message = ! this.cardValid ? this.defaultConfig.hosted_fields.labels.card_not_supported : this.defaultConfig.hosted_fields.labels.fields_not_valid;\n this.errorHandler.message(message);\n }\n }\n hostedFields.on('inputSubmitRequest', function () {\n submitEvent(null);\n });\n hostedFields.on('cardTypeChange', (event) => {\n if ( ! event.cards.length ) {\n this.cardValid = false;\n return;\n }\n const validCards = this.defaultConfig.hosted_fields.valid_cards;\n this.cardValid = validCards.indexOf(event.cards[0].type) !== -1;\n })\n document.querySelector(wrapper + ' button').addEventListener(\n 'click',\n submitEvent\n );\n });\n\n document.querySelector('#payment_method_ppcp-credit-card-gateway').addEventListener(\n 'click',\n () => {\n document.querySelector('label[for=ppcp-credit-card-gateway-card-number]').click();\n }\n )\n }\n}\nexport default CreditCardRenderer;\n","const storageKey = 'ppcp-data-client-id';\n\nconst validateToken = (token, user) => {\n if (! token) {\n return false;\n }\n if (token.user !== user) {\n return false;\n }\n const currentTime = new Date().getTime();\n const isExpired = currentTime >= token.expiration * 1000;\n return ! isExpired;\n}\n\nconst storedTokenForUser = (user) => {\n const token = JSON.parse(sessionStorage.getItem(storageKey));\n if (validateToken(token, user)) {\n return token.token;\n }\n return null;\n}\n\nconst storeToken = (token) => {\n sessionStorage.setItem(storageKey, JSON.stringify(token));\n}\n\nconst dataClientIdAttributeHandler = (script, config) => {\n fetch(config.endpoint, {\n method: 'POST',\n body: JSON.stringify({\n nonce: config.nonce\n })\n }).then((res)=>{\n return res.json();\n }).then((data)=>{\n const isValid = validateToken(data, config.user);\n if (!isValid) {\n return;\n }\n storeToken(data);\n script.setAttribute('data-client-token', data.token);\n document.body.append(script);\n });\n}\n\nexport default dataClientIdAttributeHandler;\n","class MessageRenderer {\n\n constructor(config) {\n this.config = config;\n }\n\n render() {\n if (! this.shouldRender()) {\n return;\n }\n\n paypal.Messages({\n amount: this.config.amount,\n placement: this.config.placement,\n style: this.config.style\n }).render(this.config.wrapper);\n }\n\n renderWithAmount(amount) {\n\n if (! this.shouldRender()) {\n return;\n }\n\n const newWrapper = document.createElement('div');\n newWrapper.setAttribute('id', this.config.wrapper.replace('#', ''));\n\n const sibling = document.querySelector(this.config.wrapper).nextSibling;\n document.querySelector(this.config.wrapper).parentElement.removeChild(document.querySelector(this.config.wrapper));\n sibling.parentElement.insertBefore(newWrapper, sibling);\n paypal.Messages({\n amount,\n placement: this.config.placement,\n style: this.config.style\n }).render(this.config.wrapper);\n }\n\n shouldRender() {\n\n if (typeof paypal.Messages === 'undefined' || typeof this.config.wrapper === 'undefined' ) {\n return false;\n }\n if (! document.querySelector(this.config.wrapper)) {\n return false;\n }\n return true;\n }\n}\nexport default MessageRenderer;","class Spinner {\n\n constructor() {\n this.target = 'form.woocommerce-checkout';\n }\n\n setTarget(target) {\n this.target = target;\n }\n\n block() {\n\n jQuery( this.target ).block({\n message: null,\n overlayCSS: {\n background: '#fff',\n opacity: 0.6\n }\n });\n }\n\n unblock() {\n\n jQuery( this.target ).unblock();\n }\n}\n\nexport default Spinner;\n","import MiniCartBootstap from './modules/ContextBootstrap/MiniCartBootstap';\nimport SingleProductBootstap from './modules/ContextBootstrap/SingleProductBootstap';\nimport CartBootstrap from './modules/ContextBootstrap/CartBootstap';\nimport CheckoutBootstap from './modules/ContextBootstrap/CheckoutBootstap';\nimport PayNowBootstrap from \"./modules/ContextBootstrap/PayNowBootstrap\";\nimport Renderer from './modules/Renderer/Renderer';\nimport ErrorHandler from './modules/ErrorHandler';\nimport CreditCardRenderer from \"./modules/Renderer/CreditCardRenderer\";\nimport dataClientIdAttributeHandler from \"./modules/DataClientIdAttributeHandler\";\nimport MessageRenderer from \"./modules/Renderer/MessageRenderer\";\nimport Spinner from \"./modules/Helper/Spinner\";\n\nconst bootstrap = () => {\n const errorHandler = new ErrorHandler(PayPalCommerceGateway.labels.error.generic);\n const spinner = new Spinner();\n const creditCardRenderer = new CreditCardRenderer(PayPalCommerceGateway, errorHandler, spinner);\n const renderer = new Renderer(creditCardRenderer, PayPalCommerceGateway);\n const messageRenderer = new MessageRenderer(PayPalCommerceGateway.messages);\n const context = PayPalCommerceGateway.context;\n if (context === 'mini-cart' || context === 'product') {\n const miniCartBootstrap = new MiniCartBootstap(\n PayPalCommerceGateway,\n renderer\n );\n\n miniCartBootstrap.init();\n }\n\n if (context === 'product') {\n const singleProductBootstrap = new SingleProductBootstap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n );\n\n singleProductBootstrap.init();\n }\n\n if (context === 'cart') {\n const cartBootstrap = new CartBootstrap(\n PayPalCommerceGateway,\n renderer,\n );\n\n cartBootstrap.init();\n }\n\n if (context === 'checkout') {\n const checkoutBootstap = new CheckoutBootstap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n spinner\n );\n\n checkoutBootstap.init();\n }\n\n if (context === 'pay-now' ) {\n const payNowBootstrap = new PayNowBootstrap(\n PayPalCommerceGateway,\n renderer,\n messageRenderer,\n spinner\n );\n payNowBootstrap.init();\n }\n\n if (context !== 'checkout') {\n messageRenderer.render();\n }\n};\ndocument.addEventListener(\n 'DOMContentLoaded',\n () => {\n if (!typeof (PayPalCommerceGateway)) {\n console.error('PayPal button could not be configured.');\n return;\n }\n const script = document.createElement('script');\n\n script.addEventListener('load', (event) => {\n bootstrap();\n });\n script.setAttribute('src', PayPalCommerceGateway.button.url);\n Object.entries(PayPalCommerceGateway.script_attributes).forEach(\n (keyValue) => {\n script.setAttribute(keyValue[0], keyValue[1]);\n }\n );\n\n if (PayPalCommerceGateway.data_client_id.set_attribute) {\n dataClientIdAttributeHandler(script, PayPalCommerceGateway.data_client_id);\n return;\n }\n\n document.body.append(script);\n },\n);\n"],"sourceRoot":""}
|
modules/ppcp-button/resources/js/modules/Renderer/CreditCardRenderer.js
CHANGED
@@ -87,7 +87,7 @@ class CreditCardRenderer {
|
|
87 |
},
|
88 |
expirationDate: {
|
89 |
selector: '#ppcp-credit-card-gateway-card-expiry',
|
90 |
-
placeholder: this.defaultConfig.hosted_fields.labels.
|
91 |
}
|
92 |
}
|
93 |
}).then(hostedFields => {
|
87 |
},
|
88 |
expirationDate: {
|
89 |
selector: '#ppcp-credit-card-gateway-card-expiry',
|
90 |
+
placeholder: this.defaultConfig.hosted_fields.labels.mm_yy,
|
91 |
}
|
92 |
}
|
93 |
}).then(hostedFields => {
|
modules/ppcp-button/services.php
CHANGED
@@ -139,13 +139,15 @@ return array(
|
|
139 |
$three_d_secure = $container->get( 'button.helper.three-d-secure' );
|
140 |
$settings = $container->get( 'wcgateway.settings' );
|
141 |
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
|
|
142 |
return new ApproveOrderEndpoint(
|
143 |
$request_data,
|
144 |
$order_endpoint,
|
145 |
$session_handler,
|
146 |
$three_d_secure,
|
147 |
$settings,
|
148 |
-
$dcc_applies
|
|
|
149 |
);
|
150 |
},
|
151 |
'button.endpoint.data-client-id' => static function( $container ) : DataClientIdEndpoint {
|
139 |
$three_d_secure = $container->get( 'button.helper.three-d-secure' );
|
140 |
$settings = $container->get( 'wcgateway.settings' );
|
141 |
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
142 |
+
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
143 |
return new ApproveOrderEndpoint(
|
144 |
$request_data,
|
145 |
$order_endpoint,
|
146 |
$session_handler,
|
147 |
$three_d_secure,
|
148 |
$settings,
|
149 |
+
$dcc_applies,
|
150 |
+
$logger
|
151 |
);
|
152 |
},
|
153 |
'button.endpoint.data-client-id' => static function( $container ) : DataClientIdEndpoint {
|
modules/ppcp-button/src/Assets/class-smartbutton.php
CHANGED
@@ -9,7 +9,6 @@ declare(strict_types=1);
|
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\Button\Assets;
|
11 |
|
12 |
-
use WooCommerce\PayPalCommerce\ApiClient\Entity\PaymentToken;
|
13 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory;
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
15 |
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayeeRepository;
|
@@ -23,7 +22,7 @@ use WooCommerce\PayPalCommerce\Onboarding\Environment;
|
|
23 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
24 |
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
25 |
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
26 |
-
use WooCommerce\PayPalCommerce\WcGateway\
|
27 |
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
28 |
|
29 |
/**
|
@@ -200,18 +199,17 @@ class SmartButton implements SmartButtonInterface {
|
|
200 |
11
|
201 |
);
|
202 |
|
203 |
-
$payment_token_repository = $this->payment_token_repository;
|
204 |
add_filter(
|
205 |
'woocommerce_credit_card_form_fields',
|
206 |
-
function ( $default_fields, $id )
|
207 |
-
if ( $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) ) {
|
208 |
$default_fields['card-vault'] = sprintf(
|
209 |
'<p class="form-row form-row-wide"><label for="vault"><input class="ppcp-credit-card-vault" type="checkbox" id="ppcp-credit-card-vault" name="vault">%s</label></p>',
|
210 |
esc_html__( 'Save your Credit Card', 'woocommerce-paypal-payments' )
|
211 |
);
|
212 |
|
213 |
-
$tokens = $payment_token_repository->all_for_user_id( get_current_user_id() );
|
214 |
-
if ( $tokens && $this->tokens_contains_card( $tokens ) ) {
|
215 |
$output = sprintf(
|
216 |
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-credit-card" name="saved_credit_card"><option value="">%2$s</option>',
|
217 |
esc_html__( 'Or select a saved Credit Card payment', 'woocommerce-paypal-payments' ),
|
@@ -404,7 +402,7 @@ class SmartButton implements SmartButtonInterface {
|
|
404 |
'ppcp-smart-button',
|
405 |
$this->module_url . '/assets/js/button.js',
|
406 |
array( 'jquery' ),
|
407 |
-
'1.3.
|
408 |
true
|
409 |
);
|
410 |
|
@@ -667,7 +665,7 @@ class SmartButton implements SmartButtonInterface {
|
|
667 |
'labels' => array(
|
668 |
'credit_card_number' => '',
|
669 |
'cvv' => '',
|
670 |
-
'
|
671 |
'fields_not_valid' => __(
|
672 |
'Unfortunately, your credit card details are not valid.',
|
673 |
'woocommerce-paypal-payments'
|
@@ -726,7 +724,6 @@ class SmartButton implements SmartButtonInterface {
|
|
726 |
$params = array(
|
727 |
'client-id' => $this->client_id,
|
728 |
'currency' => get_woocommerce_currency(),
|
729 |
-
'locale' => get_user_locale(),
|
730 |
'integration-date' => PAYPAL_INTEGRATION_DATE,
|
731 |
'components' => implode( ',', $this->components() ),
|
732 |
'vault' => $this->can_save_vault_token() ?
|
@@ -942,19 +939,4 @@ class SmartButton implements SmartButtonInterface {
|
|
942 |
}
|
943 |
return (string) $value;
|
944 |
}
|
945 |
-
|
946 |
-
/**
|
947 |
-
* Check if tokens has card source.
|
948 |
-
*
|
949 |
-
* @param PaymentToken[] $tokens The tokens.
|
950 |
-
* @return bool Wether tokens contains card or not.
|
951 |
-
*/
|
952 |
-
protected function tokens_contains_card( $tokens ) {
|
953 |
-
foreach ( $tokens as $token ) {
|
954 |
-
if ( isset( $token->source()->card ) ) {
|
955 |
-
return true;
|
956 |
-
}
|
957 |
-
}
|
958 |
-
return false;
|
959 |
-
}
|
960 |
}
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\Button\Assets;
|
11 |
|
|
|
12 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory;
|
13 |
use WooCommerce\PayPalCommerce\ApiClient\Helper\DccApplies;
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Repository\PayeeRepository;
|
22 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
23 |
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
24 |
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
25 |
+
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
26 |
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
27 |
|
28 |
/**
|
199 |
11
|
200 |
);
|
201 |
|
|
|
202 |
add_filter(
|
203 |
'woocommerce_credit_card_form_fields',
|
204 |
+
function ( $default_fields, $id ) {
|
205 |
+
if ( $this->settings->has( 'vault_enabled' ) && $this->settings->get( 'vault_enabled' ) && CreditCardGateway::ID === $id ) {
|
206 |
$default_fields['card-vault'] = sprintf(
|
207 |
'<p class="form-row form-row-wide"><label for="vault"><input class="ppcp-credit-card-vault" type="checkbox" id="ppcp-credit-card-vault" name="vault">%s</label></p>',
|
208 |
esc_html__( 'Save your Credit Card', 'woocommerce-paypal-payments' )
|
209 |
);
|
210 |
|
211 |
+
$tokens = $this->payment_token_repository->all_for_user_id( get_current_user_id() );
|
212 |
+
if ( $tokens && $this->payment_token_repository->tokens_contains_card( $tokens ) ) {
|
213 |
$output = sprintf(
|
214 |
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-credit-card" name="saved_credit_card"><option value="">%2$s</option>',
|
215 |
esc_html__( 'Or select a saved Credit Card payment', 'woocommerce-paypal-payments' ),
|
402 |
'ppcp-smart-button',
|
403 |
$this->module_url . '/assets/js/button.js',
|
404 |
array( 'jquery' ),
|
405 |
+
'1.3.2',
|
406 |
true
|
407 |
);
|
408 |
|
665 |
'labels' => array(
|
666 |
'credit_card_number' => '',
|
667 |
'cvv' => '',
|
668 |
+
'mm_yy' => __( 'MM/YY', 'woocommerce-paypal-payments' ),
|
669 |
'fields_not_valid' => __(
|
670 |
'Unfortunately, your credit card details are not valid.',
|
671 |
'woocommerce-paypal-payments'
|
724 |
$params = array(
|
725 |
'client-id' => $this->client_id,
|
726 |
'currency' => get_woocommerce_currency(),
|
|
|
727 |
'integration-date' => PAYPAL_INTEGRATION_DATE,
|
728 |
'components' => implode( ',', $this->components() ),
|
729 |
'vault' => $this->can_save_vault_token() ?
|
939 |
}
|
940 |
return (string) $value;
|
941 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
942 |
}
|
modules/ppcp-button/src/Endpoint/class-approveorderendpoint.php
CHANGED
@@ -10,6 +10,7 @@ declare(strict_types=1);
|
|
10 |
|
11 |
namespace WooCommerce\PayPalCommerce\Button\Endpoint;
|
12 |
|
|
|
13 |
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
15 |
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
@@ -69,15 +70,23 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|
69 |
*/
|
70 |
private $dcc_applies;
|
71 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
/**
|
73 |
* ApproveOrderEndpoint constructor.
|
74 |
*
|
75 |
-
* @param RequestData
|
76 |
-
* @param OrderEndpoint
|
77 |
-
* @param SessionHandler
|
78 |
-
* @param ThreeDSecure
|
79 |
-
* @param Settings
|
80 |
-
* @param DccApplies
|
|
|
81 |
*/
|
82 |
public function __construct(
|
83 |
RequestData $request_data,
|
@@ -85,7 +94,8 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|
85 |
SessionHandler $session_handler,
|
86 |
ThreeDSecure $three_d_secure,
|
87 |
Settings $settings,
|
88 |
-
DccApplies $dcc_applies
|
|
|
89 |
) {
|
90 |
|
91 |
$this->request_data = $request_data;
|
@@ -94,6 +104,7 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|
94 |
$this->threed_secure = $three_d_secure;
|
95 |
$this->settings = $settings;
|
96 |
$this->dcc_applies = $dcc_applies;
|
|
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -171,13 +182,14 @@ class ApproveOrderEndpoint implements EndpointInterface {
|
|
171 |
}
|
172 |
|
173 |
if ( ! $order->status()->is( OrderStatus::APPROVED ) ) {
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$data['order_id']
|
179 |
-
)
|
180 |
);
|
|
|
|
|
|
|
181 |
}
|
182 |
|
183 |
$this->session_handler->replace_order( $order );
|
10 |
|
11 |
namespace WooCommerce\PayPalCommerce\Button\Endpoint;
|
12 |
|
13 |
+
use Psr\Log\LoggerInterface;
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\OrderEndpoint;
|
15 |
use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
16 |
use WooCommerce\PayPalCommerce\ApiClient\Exception\PayPalApiException;
|
70 |
*/
|
71 |
private $dcc_applies;
|
72 |
|
73 |
+
/**
|
74 |
+
* The logger.
|
75 |
+
*
|
76 |
+
* @var LoggerInterface
|
77 |
+
*/
|
78 |
+
protected $logger;
|
79 |
+
|
80 |
/**
|
81 |
* ApproveOrderEndpoint constructor.
|
82 |
*
|
83 |
+
* @param RequestData $request_data The request data helper.
|
84 |
+
* @param OrderEndpoint $order_endpoint The order endpoint.
|
85 |
+
* @param SessionHandler $session_handler The session handler.
|
86 |
+
* @param ThreeDSecure $three_d_secure The 3d secure helper object.
|
87 |
+
* @param Settings $settings The settings.
|
88 |
+
* @param DccApplies $dcc_applies The DCC applies object.
|
89 |
+
* @param LoggerInterface $logger The logger.
|
90 |
*/
|
91 |
public function __construct(
|
92 |
RequestData $request_data,
|
94 |
SessionHandler $session_handler,
|
95 |
ThreeDSecure $three_d_secure,
|
96 |
Settings $settings,
|
97 |
+
DccApplies $dcc_applies,
|
98 |
+
LoggerInterface $logger
|
99 |
) {
|
100 |
|
101 |
$this->request_data = $request_data;
|
104 |
$this->threed_secure = $three_d_secure;
|
105 |
$this->settings = $settings;
|
106 |
$this->dcc_applies = $dcc_applies;
|
107 |
+
$this->logger = $logger;
|
108 |
}
|
109 |
|
110 |
/**
|
182 |
}
|
183 |
|
184 |
if ( ! $order->status()->is( OrderStatus::APPROVED ) ) {
|
185 |
+
$message = sprintf(
|
186 |
+
// translators: %s is the id of the order.
|
187 |
+
__( 'Order %s is not approved yet.', 'woocommerce-paypal-payments' ),
|
188 |
+
$data['order_id']
|
|
|
|
|
189 |
);
|
190 |
+
|
191 |
+
$this->logger->log( 'error', $message );
|
192 |
+
throw new RuntimeException( $message );
|
193 |
}
|
194 |
|
195 |
$this->session_handler->replace_order( $order );
|
modules/ppcp-button/src/Helper/class-messagesdisclaimers.php
CHANGED
@@ -17,7 +17,7 @@ namespace WooCommerce\PayPalCommerce\Button\Helper;
|
|
17 |
class MessagesDisclaimers {
|
18 |
|
19 |
/**
|
20 |
-
*
|
21 |
*
|
22 |
* @var array
|
23 |
*/
|
17 |
class MessagesDisclaimers {
|
18 |
|
19 |
/**
|
20 |
+
* Disclaimers content by country.
|
21 |
*
|
22 |
* @var array
|
23 |
*/
|
modules/ppcp-onboarding/assets/js/settings.js
CHANGED
@@ -1,262 +1,297 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
}
|
11 |
-
toggleElement.addEventListener(
|
12 |
-
'change',
|
13 |
-
(event) => {
|
14 |
-
|
15 |
-
if (! event.target.checked) {
|
16 |
group.forEach( (elementToHide) => {
|
17 |
document.querySelector(elementToHide).style.display = 'none';
|
18 |
-
})
|
19 |
-
return;
|
20 |
}
|
|
|
|
|
|
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
}
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
return;
|
33 |
-
}
|
34 |
-
const value = toggleElement.value;
|
35 |
-
group.forEach( (elementToToggle) => {
|
36 |
-
const domElement = document.querySelector(elementToToggle.selector);
|
37 |
-
if (! domElement) {
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
if (value === elementToToggle.value && domElement.style.display !== 'none') {
|
41 |
-
domElement.style.display = 'table-row';
|
42 |
-
return;
|
43 |
-
}
|
44 |
-
domElement.style.display = 'none';
|
45 |
-
});
|
46 |
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
group.forEach( (elementToToggle) => {
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
55 |
return;
|
56 |
}
|
57 |
-
|
58 |
-
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
}
|
60 |
-
);
|
61 |
-
};
|
62 |
|
63 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
(
|
80 |
-
|
81 |
-
option.selected = target.querySelector('option[value="' + option.value + '"]') && target.querySelector('option[value="' + option.value + '"]').selected;
|
82 |
-
return option;
|
83 |
-
}
|
84 |
-
);
|
85 |
-
target.innerHTML = '';
|
86 |
-
selectedValidOptions.forEach(
|
87 |
-
(option) => {
|
88 |
-
target.append(option);
|
89 |
}
|
90 |
-
|
91 |
-
|
|
|
|
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
-
(
|
98 |
-
|
99 |
-
|
100 |
-
'#ppcp-button_enabled',
|
101 |
-
[
|
102 |
-
'#field-button_layout',
|
103 |
-
'#field-button_tagline',
|
104 |
-
'#field-button_label',
|
105 |
-
'#field-button_color',
|
106 |
-
'#field-button_shape',
|
107 |
-
]
|
108 |
-
);
|
109 |
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
132 |
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
);
|
144 |
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
|
|
155 |
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
groupToggle(
|
167 |
-
'#ppcp-message_cart_enabled',
|
168 |
-
[
|
169 |
-
'#field-message_cart_layout',
|
170 |
-
'#field-message_cart_logo',
|
171 |
-
'#field-message_cart_position',
|
172 |
-
'#field-message_cart_color',
|
173 |
-
'#field-message_cart_flex_color',
|
174 |
-
'#field-message_cart_flex_ratio',
|
175 |
-
]
|
176 |
-
);
|
177 |
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
selector:'#field-message_cart_logo'
|
218 |
-
},
|
219 |
-
{
|
220 |
-
value:'text',
|
221 |
-
selector:'#field-message_cart_position'
|
222 |
-
},
|
223 |
-
{
|
224 |
-
value:'text',
|
225 |
-
selector:'#field-message_cart_color'
|
226 |
-
},
|
227 |
-
{
|
228 |
-
value:'flex',
|
229 |
-
selector:'#field-message_cart_flex_ratio'
|
230 |
-
},
|
231 |
-
{
|
232 |
-
value:'flex',
|
233 |
-
selector:'#field-message_cart_flex_color'
|
234 |
-
}
|
235 |
-
]
|
236 |
-
);
|
237 |
-
groupToggleSelect(
|
238 |
-
'#ppcp-message_layout',
|
239 |
-
[
|
240 |
-
{
|
241 |
-
value:'text',
|
242 |
-
selector:'#field-message_logo'
|
243 |
-
},
|
244 |
-
{
|
245 |
-
value:'text',
|
246 |
-
selector:'#field-message_position'
|
247 |
-
},
|
248 |
-
{
|
249 |
-
value:'text',
|
250 |
-
selector:'#field-message_color'
|
251 |
-
},
|
252 |
-
{
|
253 |
-
value:'flex',
|
254 |
-
selector:'#field-message_flex_ratio'
|
255 |
-
},
|
256 |
-
{
|
257 |
-
value:'flex',
|
258 |
-
selector:'#field-message_flex_color'
|
259 |
-
}
|
260 |
-
]
|
261 |
-
);
|
262 |
-
})();
|
1 |
+
document.addEventListener(
|
2 |
+
'DOMContentLoaded',
|
3 |
+
() => {
|
4 |
+
const groupToggle = (selector, group) => {
|
5 |
+
const toggleElement = document.querySelector(selector);
|
6 |
+
if (! toggleElement) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
+
if (! toggleElement.checked) {
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
group.forEach( (elementToHide) => {
|
11 |
document.querySelector(elementToHide).style.display = 'none';
|
12 |
+
})
|
|
|
13 |
}
|
14 |
+
toggleElement.addEventListener(
|
15 |
+
'change',
|
16 |
+
(event) => {
|
17 |
|
18 |
+
if (! event.target.checked) {
|
19 |
+
group.forEach( (elementToHide) => {
|
20 |
+
document.querySelector(elementToHide).style.display = 'none';
|
21 |
+
});
|
22 |
+
return;
|
23 |
+
}
|
24 |
|
25 |
+
group.forEach( (elementToShow) => {
|
26 |
+
document.querySelector(elementToShow).style.display = 'table-row';
|
27 |
+
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
+
if('ppcp-message_enabled' === event.target.getAttribute('id')){
|
30 |
+
updateCheckoutMessageFields();
|
31 |
+
return;
|
32 |
+
}
|
33 |
+
|
34 |
+
if('ppcp-message_product_enabled' === event.target.getAttribute('id')){
|
35 |
+
updateProductMessageFields();
|
36 |
+
return;
|
37 |
+
}
|
38 |
+
|
39 |
+
if('ppcp-message_cart_enabled' === event.target.getAttribute('id')){
|
40 |
+
updateCartMessageFields();
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
44 |
+
);
|
45 |
+
};
|
46 |
+
|
47 |
+
const groupToggleSelect = (selector, group) => {
|
48 |
+
const toggleElement = document.querySelector(selector);
|
49 |
+
if (! toggleElement) {
|
50 |
+
return;
|
51 |
+
}
|
52 |
+
const value = toggleElement.value;
|
53 |
group.forEach( (elementToToggle) => {
|
54 |
+
const domElement = document.querySelector(elementToToggle.selector);
|
55 |
+
if (! domElement) {
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
if (value === elementToToggle.value && domElement.style.display !== 'none') {
|
59 |
+
domElement.style.display = 'table-row';
|
60 |
return;
|
61 |
}
|
62 |
+
domElement.style.display = 'none';
|
63 |
+
});
|
64 |
+
|
65 |
+
// We need to use jQuery here as the select might be a select2 element, which doesn't use native events.
|
66 |
+
jQuery(toggleElement).on(
|
67 |
+
'change',
|
68 |
+
(event) => {
|
69 |
+
const value = event.target.value;
|
70 |
+
group.forEach( (elementToToggle) => {
|
71 |
+
if (value === elementToToggle.value) {
|
72 |
+
document.querySelector(elementToToggle.selector).style.display = 'table-row';
|
73 |
+
return;
|
74 |
+
}
|
75 |
+
document.querySelector(elementToToggle.selector).style.display = 'none';
|
76 |
+
})
|
77 |
+
}
|
78 |
+
);
|
79 |
+
};
|
80 |
+
|
81 |
+
const updateCheckoutMessageFields = () => {
|
82 |
+
groupToggleSelect(
|
83 |
+
'#ppcp-message_layout',
|
84 |
+
[
|
85 |
+
{
|
86 |
+
value:'text',
|
87 |
+
selector:'#field-message_logo'
|
88 |
+
},
|
89 |
+
{
|
90 |
+
value:'text',
|
91 |
+
selector:'#field-message_position'
|
92 |
+
},
|
93 |
+
{
|
94 |
+
value:'text',
|
95 |
+
selector:'#field-message_color'
|
96 |
+
},
|
97 |
+
{
|
98 |
+
value:'flex',
|
99 |
+
selector:'#field-message_flex_ratio'
|
100 |
+
},
|
101 |
+
{
|
102 |
+
value:'flex',
|
103 |
+
selector:'#field-message_flex_color'
|
104 |
+
}
|
105 |
+
]
|
106 |
+
);
|
107 |
}
|
|
|
|
|
108 |
|
109 |
+
const updateProductMessageFields = () => {
|
110 |
+
groupToggleSelect(
|
111 |
+
'#ppcp-message_product_layout',
|
112 |
+
[
|
113 |
+
{
|
114 |
+
value:'text',
|
115 |
+
selector:'#field-message_product_logo'
|
116 |
+
},
|
117 |
+
{
|
118 |
+
value:'text',
|
119 |
+
selector:'#field-message_product_position'
|
120 |
+
},
|
121 |
+
{
|
122 |
+
value:'text',
|
123 |
+
selector:'#field-message_product_color'
|
124 |
+
},
|
125 |
+
{
|
126 |
+
value:'flex',
|
127 |
+
selector:'#field-message_product_flex_ratio'
|
128 |
+
},
|
129 |
+
{
|
130 |
+
value:'flex',
|
131 |
+
selector:'#field-message_product_flex_color'
|
132 |
+
}
|
133 |
+
]
|
134 |
+
);
|
135 |
+
}
|
136 |
|
137 |
+
const updateCartMessageFields = () =>
|
138 |
+
{
|
139 |
+
groupToggleSelect(
|
140 |
+
'#ppcp-message_cart_layout',
|
141 |
+
[
|
142 |
+
{
|
143 |
+
value:'text',
|
144 |
+
selector:'#field-message_cart_logo'
|
145 |
+
},
|
146 |
+
{
|
147 |
+
value:'text',
|
148 |
+
selector:'#field-message_cart_position'
|
149 |
+
},
|
150 |
+
{
|
151 |
+
value:'text',
|
152 |
+
selector:'#field-message_cart_color'
|
153 |
+
},
|
154 |
+
{
|
155 |
+
value:'flex',
|
156 |
+
selector:'#field-message_cart_flex_ratio'
|
157 |
+
},
|
158 |
+
{
|
159 |
+
value:'flex',
|
160 |
+
selector:'#field-message_cart_flex_color'
|
161 |
+
}
|
162 |
+
]
|
163 |
+
);
|
164 |
+
}
|
165 |
|
166 |
+
const disableOptions = (sourceSelector, targetSelector) => {
|
167 |
+
|
168 |
+
const source = jQuery(sourceSelector);
|
169 |
+
const target = document.querySelector(targetSelector);
|
170 |
+
if (! target) {
|
171 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
+
const allOptions = Array.from(document.querySelectorAll('select[name="ppcp[disable_cards][]"] option'));
|
174 |
+
const replace = () => {
|
175 |
+
const validOptions = allOptions.filter(
|
176 |
+
(option) => {
|
177 |
|
178 |
+
return ! option.selected
|
179 |
+
}
|
180 |
+
);
|
181 |
+
const selectedValidOptions = validOptions.map(
|
182 |
+
(option) => {
|
183 |
+
option = option.cloneNode(true);
|
184 |
+
option.selected = target.querySelector('option[value="' + option.value + '"]') && target.querySelector('option[value="' + option.value + '"]').selected;
|
185 |
+
return option;
|
186 |
+
}
|
187 |
+
);
|
188 |
+
target.innerHTML = '';
|
189 |
+
selectedValidOptions.forEach(
|
190 |
+
(option) => {
|
191 |
+
target.append(option);
|
192 |
+
}
|
193 |
+
);
|
194 |
+
};
|
195 |
|
196 |
+
source.on('change',replace);
|
197 |
+
replace();
|
198 |
+
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
|
200 |
+
(() => {
|
201 |
+
disableOptions('select[name="ppcp[disable_cards][]"]', 'select[name="ppcp[card_icons][]"]');
|
202 |
+
groupToggle(
|
203 |
+
'#ppcp-button_enabled',
|
204 |
+
[
|
205 |
+
'#field-button_layout',
|
206 |
+
'#field-button_tagline',
|
207 |
+
'#field-button_label',
|
208 |
+
'#field-button_color',
|
209 |
+
'#field-button_shape',
|
210 |
+
]
|
211 |
+
);
|
212 |
|
213 |
+
groupToggle(
|
214 |
+
'#ppcp-message_enabled',
|
215 |
+
[
|
216 |
+
'#field-message_layout',
|
217 |
+
'#field-message_logo',
|
218 |
+
'#field-message_position',
|
219 |
+
'#field-message_color',
|
220 |
+
'#field-message_flex_color',
|
221 |
+
'#field-message_flex_ratio',
|
222 |
+
]
|
223 |
+
);
|
224 |
|
225 |
+
groupToggle(
|
226 |
+
'#ppcp-button_product_enabled',
|
227 |
+
[
|
228 |
+
'#field-button_product_layout',
|
229 |
+
'#field-button_product_tagline',
|
230 |
+
'#field-button_product_label',
|
231 |
+
'#field-button_product_color',
|
232 |
+
'#field-button_product_shape',
|
233 |
+
]
|
234 |
+
);
|
|
|
235 |
|
236 |
+
groupToggle(
|
237 |
+
'#ppcp-message_product_enabled',
|
238 |
+
[
|
239 |
+
'#field-message_product_layout',
|
240 |
+
'#field-message_product_logo',
|
241 |
+
'#field-message_product_position',
|
242 |
+
'#field-message_product_color',
|
243 |
+
'#field-message_product_flex_color',
|
244 |
+
'#field-message_product_flex_ratio',
|
245 |
+
]
|
246 |
+
);
|
247 |
|
248 |
+
groupToggle(
|
249 |
+
'#ppcp-button_mini-cart_enabled',
|
250 |
+
[
|
251 |
+
'#field-button_mini-cart_layout',
|
252 |
+
'#field-button_mini-cart_tagline',
|
253 |
+
'#field-button_mini-cart_label',
|
254 |
+
'#field-button_mini-cart_color',
|
255 |
+
'#field-button_mini-cart_shape',
|
256 |
+
]
|
257 |
+
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
|
259 |
+
groupToggle(
|
260 |
+
'#ppcp-button_cart_enabled',
|
261 |
+
[
|
262 |
+
'#field-button_cart_layout',
|
263 |
+
'#field-button_cart_tagline',
|
264 |
+
'#field-button_cart_label',
|
265 |
+
'#field-button_cart_color',
|
266 |
+
'#field-button_cart_shape',
|
267 |
+
]
|
268 |
+
);
|
269 |
+
groupToggle(
|
270 |
+
'#ppcp-message_cart_enabled',
|
271 |
+
[
|
272 |
+
'#field-message_cart_layout',
|
273 |
+
'#field-message_cart_logo',
|
274 |
+
'#field-message_cart_position',
|
275 |
+
'#field-message_cart_color',
|
276 |
+
'#field-message_cart_flex_color',
|
277 |
+
'#field-message_cart_flex_ratio',
|
278 |
+
]
|
279 |
+
);
|
280 |
+
|
281 |
+
|
282 |
+
groupToggleSelect(
|
283 |
+
'#ppcp-intent',
|
284 |
+
[
|
285 |
+
{
|
286 |
+
value:'authorize',
|
287 |
+
selector:'#field-capture_for_virtual_only'
|
288 |
+
}
|
289 |
+
]
|
290 |
+
);
|
291 |
+
|
292 |
+
updateCheckoutMessageFields();
|
293 |
+
updateProductMessageFields();
|
294 |
+
updateCartMessageFields();
|
295 |
+
})();
|
296 |
+
}
|
297 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
modules/ppcp-subscription/src/Helper/class-subscriptionhelper.php
CHANGED
@@ -83,4 +83,25 @@ class SubscriptionHelper {
|
|
83 |
|
84 |
return class_exists( \WC_Subscriptions::class );
|
85 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
83 |
|
84 |
return class_exists( \WC_Subscriptions::class );
|
85 |
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* Checks if order contains subscription.
|
89 |
+
*
|
90 |
+
* @param int $order_id The order Id.
|
91 |
+
* @return boolean Whether order is a subscription or not.
|
92 |
+
*/
|
93 |
+
public function has_subscription( $order_id ): bool {
|
94 |
+
return ( function_exists( 'wcs_order_contains_subscription' ) && ( wcs_order_contains_subscription( $order_id ) || wcs_is_subscription( $order_id ) || wcs_order_contains_renewal( $order_id ) ) );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Checks if page is pay for order and change subscription payment page.
|
99 |
+
*
|
100 |
+
* @return bool Whether page is change subscription or not.
|
101 |
+
*/
|
102 |
+
public function is_subscription_change_payment(): bool {
|
103 |
+
$pay_for_order = filter_input( INPUT_GET, 'pay_for_order', FILTER_SANITIZE_STRING );
|
104 |
+
$change_payment_method = filter_input( INPUT_GET, 'change_payment_method', FILTER_SANITIZE_STRING );
|
105 |
+
return ( isset( $pay_for_order ) && isset( $change_payment_method ) );
|
106 |
+
}
|
107 |
}
|
modules/ppcp-subscription/src/Repository/class-paymenttokenrepository.php
CHANGED
@@ -101,6 +101,36 @@ class PaymentTokenRepository {
|
|
101 |
return $this->endpoint->delete_token( $token );
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
/**
|
105 |
* Fetch PaymentToken from PayPal for a user.
|
106 |
*
|
101 |
return $this->endpoint->delete_token( $token );
|
102 |
}
|
103 |
|
104 |
+
/**
|
105 |
+
* Check if tokens has card source.
|
106 |
+
*
|
107 |
+
* @param PaymentToken[] $tokens The tokens.
|
108 |
+
* @return bool Whether tokens contains card or not.
|
109 |
+
*/
|
110 |
+
public function tokens_contains_card( $tokens ): bool {
|
111 |
+
foreach ( $tokens as $token ) {
|
112 |
+
if ( isset( $token->source()->card ) ) {
|
113 |
+
return true;
|
114 |
+
}
|
115 |
+
}
|
116 |
+
return false;
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* Check if tokens has PayPal source.
|
121 |
+
*
|
122 |
+
* @param PaymentToken[] $tokens The tokens.
|
123 |
+
* @return bool Whether tokens contains card or not.
|
124 |
+
*/
|
125 |
+
public function tokens_contains_paypal( $tokens ): bool {
|
126 |
+
foreach ( $tokens as $token ) {
|
127 |
+
if ( isset( $token->source()->paypal ) ) {
|
128 |
+
return true;
|
129 |
+
}
|
130 |
+
}
|
131 |
+
return false;
|
132 |
+
}
|
133 |
+
|
134 |
/**
|
135 |
* Fetch PaymentToken from PayPal for a user.
|
136 |
*
|
modules/ppcp-subscription/src/class-renewalhandler.php
CHANGED
@@ -203,6 +203,19 @@ class RenewalHandler {
|
|
203 |
);
|
204 |
}
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
return current( $tokens );
|
207 |
}
|
208 |
|
203 |
);
|
204 |
}
|
205 |
|
206 |
+
$subscription = function_exists( 'wcs_get_subscription' ) ? wcs_get_subscription( $wc_order->get_meta( '_subscription_renewal' ) ) : null;
|
207 |
+
if ( $subscription ) {
|
208 |
+
$subscription_id = $subscription->get_id();
|
209 |
+
$token_id = get_post_meta( $subscription_id, 'payment_token_id', true );
|
210 |
+
if ( $token_id ) {
|
211 |
+
foreach ( $tokens as $token ) {
|
212 |
+
if ( $token_id === $token->id() ) {
|
213 |
+
return $token;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
return current( $tokens );
|
220 |
}
|
221 |
|
modules/ppcp-subscription/src/class-subscriptionmodule.php
CHANGED
@@ -11,12 +11,16 @@ namespace WooCommerce\PayPalCommerce\Subscription;
|
|
11 |
|
12 |
use Dhii\Container\ServiceProvider;
|
13 |
use Dhii\Modular\Module\ModuleInterface;
|
14 |
-
use
|
15 |
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|
|
|
|
16 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
17 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
18 |
use Interop\Container\ServiceProviderInterface;
|
19 |
use Psr\Container\ContainerInterface;
|
|
|
|
|
20 |
|
21 |
/**
|
22 |
* Class SubscriptionModule
|
@@ -58,6 +62,50 @@ class SubscriptionModule implements ModuleInterface {
|
|
58 |
10,
|
59 |
2
|
60 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
/**
|
@@ -77,10 +125,145 @@ class SubscriptionModule implements ModuleInterface {
|
|
77 |
}
|
78 |
|
79 |
/**
|
80 |
-
*
|
81 |
*
|
82 |
-
* @
|
|
|
|
|
83 |
*/
|
84 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
}
|
86 |
}
|
11 |
|
12 |
use Dhii\Container\ServiceProvider;
|
13 |
use Dhii\Modular\Module\ModuleInterface;
|
14 |
+
use Psr\Log\LoggerInterface;
|
15 |
use WooCommerce\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
16 |
+
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
17 |
+
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
18 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
19 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
20 |
use Interop\Container\ServiceProviderInterface;
|
21 |
use Psr\Container\ContainerInterface;
|
22 |
+
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
23 |
+
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
24 |
|
25 |
/**
|
26 |
* Class SubscriptionModule
|
62 |
10,
|
63 |
2
|
64 |
);
|
65 |
+
|
66 |
+
add_action(
|
67 |
+
'woocommerce_subscription_payment_complete',
|
68 |
+
function ( $subscription ) use ( $container ) {
|
69 |
+
$payment_token_repository = $container->get( 'subscription.repository.payment-token' );
|
70 |
+
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
71 |
+
|
72 |
+
$this->add_payment_token_id( $subscription, $payment_token_repository, $logger );
|
73 |
+
}
|
74 |
+
);
|
75 |
+
|
76 |
+
add_filter(
|
77 |
+
'woocommerce_gateway_description',
|
78 |
+
function ( $description, $id ) use ( $container ) {
|
79 |
+
$payment_token_repository = $container->get( 'subscription.repository.payment-token' );
|
80 |
+
$settings = $container->get( 'wcgateway.settings' );
|
81 |
+
$subscription_helper = $container->get( 'subscription.helper' );
|
82 |
+
|
83 |
+
return $this->display_saved_paypal_payments( $settings, $id, $payment_token_repository, $description, $subscription_helper );
|
84 |
+
},
|
85 |
+
10,
|
86 |
+
2
|
87 |
+
);
|
88 |
+
|
89 |
+
add_filter(
|
90 |
+
'woocommerce_credit_card_form_fields',
|
91 |
+
function ( $default_fields, $id ) use ( $container ) {
|
92 |
+
$payment_token_repository = $container->get( 'subscription.repository.payment-token' );
|
93 |
+
$settings = $container->get( 'wcgateway.settings' );
|
94 |
+
$subscription_helper = $container->get( 'subscription.helper' );
|
95 |
+
|
96 |
+
return $this->display_saved_credit_cards( $settings, $id, $payment_token_repository, $default_fields, $subscription_helper );
|
97 |
+
},
|
98 |
+
20,
|
99 |
+
2
|
100 |
+
);
|
101 |
+
}
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Returns the key for the module.
|
105 |
+
*
|
106 |
+
* @return string|void
|
107 |
+
*/
|
108 |
+
public function getKey() {
|
109 |
}
|
110 |
|
111 |
/**
|
125 |
}
|
126 |
|
127 |
/**
|
128 |
+
* Adds Payment token ID to subscription.
|
129 |
*
|
130 |
+
* @param \WC_Subscription $subscription The subscription.
|
131 |
+
* @param PaymentTokenRepository $payment_token_repository The payment repository.
|
132 |
+
* @param LoggerInterface $logger The logger.
|
133 |
*/
|
134 |
+
protected function add_payment_token_id(
|
135 |
+
\WC_Subscription $subscription,
|
136 |
+
PaymentTokenRepository $payment_token_repository,
|
137 |
+
LoggerInterface $logger
|
138 |
+
) {
|
139 |
+
try {
|
140 |
+
$tokens = $payment_token_repository->all_for_user_id( $subscription->get_customer_id() );
|
141 |
+
if ( $tokens ) {
|
142 |
+
$subscription_id = $subscription->get_id();
|
143 |
+
$latest_token_id = end( $tokens )->id() ? end( $tokens )->id() : '';
|
144 |
+
update_post_meta( $subscription_id, 'payment_token_id', $latest_token_id, true );
|
145 |
+
}
|
146 |
+
} catch ( RuntimeException $error ) {
|
147 |
+
$message = sprintf(
|
148 |
+
// translators: %1$s is the payment token Id, %2$s is the error message.
|
149 |
+
__(
|
150 |
+
'Could not add token Id to subscription %1$s: %2$s',
|
151 |
+
'woocommerce-paypal-payments'
|
152 |
+
),
|
153 |
+
$subscription->get_id(),
|
154 |
+
$error->getMessage()
|
155 |
+
);
|
156 |
+
|
157 |
+
$logger->log( 'warning', $message );
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Displays saved PayPal payments.
|
163 |
+
*
|
164 |
+
* @param Settings $settings The settings.
|
165 |
+
* @param string $id The payment gateway Id.
|
166 |
+
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
167 |
+
* @param string $description The payment gateway description.
|
168 |
+
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
169 |
+
* @return string
|
170 |
+
*/
|
171 |
+
protected function display_saved_paypal_payments(
|
172 |
+
Settings $settings,
|
173 |
+
string $id,
|
174 |
+
PaymentTokenRepository $payment_token_repository,
|
175 |
+
string $description,
|
176 |
+
SubscriptionHelper $subscription_helper
|
177 |
+
): string {
|
178 |
+
if ( $settings->has( 'vault_enabled' )
|
179 |
+
&& $settings->get( 'vault_enabled' )
|
180 |
+
&& PayPalGateway::ID === $id
|
181 |
+
&& $subscription_helper->is_subscription_change_payment()
|
182 |
+
) {
|
183 |
+
$tokens = $payment_token_repository->all_for_user_id( get_current_user_id() );
|
184 |
+
if ( ! $tokens || ! $payment_token_repository->tokens_contains_paypal( $tokens ) ) {
|
185 |
+
return esc_html__(
|
186 |
+
'No PayPal payments saved, in order to use a saved payment you first need to create it through a purchase.',
|
187 |
+
'woocommerce-paypal-payments'
|
188 |
+
);
|
189 |
+
}
|
190 |
+
|
191 |
+
$output = sprintf(
|
192 |
+
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-paypal-payment" name="saved_paypal_payment">',
|
193 |
+
esc_html__( 'Select a saved PayPal payment', 'woocommerce-paypal-payments' )
|
194 |
+
);
|
195 |
+
foreach ( $tokens as $token ) {
|
196 |
+
if ( isset( $token->source()->paypal ) ) {
|
197 |
+
$output .= sprintf(
|
198 |
+
'<option value="%1$s">%2$s</option>',
|
199 |
+
$token->id(),
|
200 |
+
$token->source()->paypal->payer->email_address
|
201 |
+
);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
$output .= '</select></p>';
|
205 |
+
|
206 |
+
return $output;
|
207 |
+
}
|
208 |
+
|
209 |
+
return $description;
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* Displays saved credit cards.
|
214 |
+
*
|
215 |
+
* @param Settings $settings The settings.
|
216 |
+
* @param string $id The payment gateway Id.
|
217 |
+
* @param PaymentTokenRepository $payment_token_repository The payment token repository.
|
218 |
+
* @param array $default_fields Default payment gateway fields.
|
219 |
+
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
220 |
+
* @return array|mixed|string
|
221 |
+
* @throws NotFoundException When setting was not found.
|
222 |
+
*/
|
223 |
+
protected function display_saved_credit_cards(
|
224 |
+
Settings $settings,
|
225 |
+
string $id,
|
226 |
+
PaymentTokenRepository $payment_token_repository,
|
227 |
+
array $default_fields,
|
228 |
+
SubscriptionHelper $subscription_helper
|
229 |
+
) {
|
230 |
+
|
231 |
+
if ( $settings->has( 'vault_enabled' )
|
232 |
+
&& $settings->get( 'vault_enabled' )
|
233 |
+
&& $subscription_helper->is_subscription_change_payment()
|
234 |
+
&& CreditCardGateway::ID === $id
|
235 |
+
) {
|
236 |
+
$tokens = $payment_token_repository->all_for_user_id( get_current_user_id() );
|
237 |
+
if ( ! $tokens || ! $payment_token_repository->tokens_contains_card( $tokens ) ) {
|
238 |
+
$default_fields = array();
|
239 |
+
$default_fields['saved-credit-card'] = esc_html__(
|
240 |
+
'No Credit Card saved, in order to use a saved Credit Card you first need to create it through a purchase.',
|
241 |
+
'woocommerce-paypal-payments'
|
242 |
+
);
|
243 |
+
return $default_fields;
|
244 |
+
}
|
245 |
+
|
246 |
+
$output = sprintf(
|
247 |
+
'<p class="form-row form-row-wide"><label>%1$s</label><select id="saved-credit-card" name="saved_credit_card">',
|
248 |
+
esc_html__( 'Select a saved Credit Card payment', 'woocommerce-paypal-payments' )
|
249 |
+
);
|
250 |
+
foreach ( $tokens as $token ) {
|
251 |
+
if ( isset( $token->source()->card ) ) {
|
252 |
+
$output .= sprintf(
|
253 |
+
'<option value="%1$s">%2$s ...%3$s</option>',
|
254 |
+
$token->id(),
|
255 |
+
$token->source()->card->brand,
|
256 |
+
$token->source()->card->last_digits
|
257 |
+
);
|
258 |
+
}
|
259 |
+
}
|
260 |
+
$output .= '</select></p>';
|
261 |
+
|
262 |
+
$default_fields = array();
|
263 |
+
$default_fields['saved-credit-card'] = $output;
|
264 |
+
return $default_fields;
|
265 |
+
}
|
266 |
+
|
267 |
+
return $default_fields;
|
268 |
}
|
269 |
}
|
modules/ppcp-wc-gateway/assets/js/gateway-settings.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelectorAll("#ppcp-message_enabled, #ppcp-message_cart_enabled, #ppcp-message_product_enabled"),t=document.querySelectorAll("#ppcp-vault_enabled");function n(e){return Array.prototype.slice.call(e).filter(e=>!e.disabled&&e.checked).length>0}function r(e){e.forEach(e=>e.setAttribute("disabled","true"))}function o(e){e.forEach(e=>e.removeAttribute("disabled"))}function
|
2 |
//# sourceMappingURL=gateway-settings.js.map
|
1 |
+
!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t){document.addEventListener("DOMContentLoaded",()=>{const e=document.querySelectorAll("#ppcp-message_enabled, #ppcp-message_cart_enabled, #ppcp-message_product_enabled"),t=document.querySelectorAll("#ppcp-vault_enabled");function n(e){return Array.prototype.slice.call(e).filter(e=>!e.disabled&&e.checked).length>0}function r(e){e.forEach(e=>e.setAttribute("disabled","true"))}function o(e){e.forEach(e=>e.removeAttribute("disabled"))}function a(){n(e)?r(t):o(t),n(t)?r(e):o(e),"1"!==PayPalCommerceGatewaySettings.vaulting_features_available&&r(t)}a(),e.forEach(e=>e.addEventListener("change",a)),t.forEach(e=>e.addEventListener("change",a))})}]);
|
2 |
//# sourceMappingURL=gateway-settings.js.map
|
modules/ppcp-wc-gateway/assets/js/gateway-settings.js.map
CHANGED
@@ -1 +1 @@
|
|
1 |
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./resources/js/gateway-settings.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","document","addEventListener","payLaterMessagingCheckboxes","querySelectorAll","vaultingCheckboxes","atLeastOneChecked","checkboxesNodeList","Array","slice","filter","node","disabled","checked","length","disableAll","nodeList","forEach","setAttribute","enableAll","removeAttribute","updateCheckboxes"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB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version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./resources/js/gateway-settings.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","document","addEventListener","payLaterMessagingCheckboxes","querySelectorAll","vaultingCheckboxes","atLeastOneChecked","checkboxesNodeList","Array","slice","filter","node","disabled","checked","length","disableAll","nodeList","forEach","setAttribute","enableAll","removeAttribute","updateCheckboxes","PayPalCommerceGatewaySettings","vaulting_features_available"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,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};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n",";document.addEventListener(\n 'DOMContentLoaded',\n () => {\n const payLaterMessagingCheckboxes = document.querySelectorAll(\n \"#ppcp-message_enabled, #ppcp-message_cart_enabled, #ppcp-message_product_enabled\"\n )\n\n const vaultingCheckboxes = document.querySelectorAll(\n \"#ppcp-vault_enabled\"\n )\n\n function atLeastOneChecked(checkboxesNodeList) {\n return Array.prototype.slice.call(checkboxesNodeList).filter(node => !node.disabled && node.checked).length > 0\n }\n\n function disableAll(nodeList){\n nodeList.forEach(node => node.setAttribute('disabled', 'true'))\n }\n\n function enableAll(nodeList){\n nodeList.forEach(node => node.removeAttribute('disabled'))\n }\n\n function updateCheckboxes() {\n atLeastOneChecked(payLaterMessagingCheckboxes) ? disableAll(vaultingCheckboxes) : enableAll(vaultingCheckboxes)\n atLeastOneChecked(vaultingCheckboxes) ? disableAll(payLaterMessagingCheckboxes) : enableAll(payLaterMessagingCheckboxes)\n\n if(PayPalCommerceGatewaySettings.vaulting_features_available !== '1' ) {\n disableAll(vaultingCheckboxes)\n }\n }\n\n updateCheckboxes()\n\n payLaterMessagingCheckboxes.forEach(node => node.addEventListener('change', updateCheckboxes))\n vaultingCheckboxes.forEach(node => node.addEventListener('change', updateCheckboxes));\n }\n);\n"],"sourceRoot":""}
|
modules/ppcp-wc-gateway/resources/js/gateway-settings.js
CHANGED
@@ -24,6 +24,10 @@
|
|
24 |
function updateCheckboxes() {
|
25 |
atLeastOneChecked(payLaterMessagingCheckboxes) ? disableAll(vaultingCheckboxes) : enableAll(vaultingCheckboxes)
|
26 |
atLeastOneChecked(vaultingCheckboxes) ? disableAll(payLaterMessagingCheckboxes) : enableAll(payLaterMessagingCheckboxes)
|
|
|
|
|
|
|
|
|
27 |
}
|
28 |
|
29 |
updateCheckboxes()
|
24 |
function updateCheckboxes() {
|
25 |
atLeastOneChecked(payLaterMessagingCheckboxes) ? disableAll(vaultingCheckboxes) : enableAll(vaultingCheckboxes)
|
26 |
atLeastOneChecked(vaultingCheckboxes) ? disableAll(payLaterMessagingCheckboxes) : enableAll(payLaterMessagingCheckboxes)
|
27 |
+
|
28 |
+
if(PayPalCommerceGatewaySettings.vaulting_features_available !== '1' ) {
|
29 |
+
disableAll(vaultingCheckboxes)
|
30 |
+
}
|
31 |
}
|
32 |
|
33 |
updateCheckboxes()
|
modules/ppcp-wc-gateway/services.php
CHANGED
@@ -46,7 +46,7 @@ return array(
|
|
46 |
$refund_processor = $container->get( 'wcgateway.processor.refunds' );
|
47 |
$state = $container->get( 'onboarding.state' );
|
48 |
$transaction_url_provider = $container->get( 'wcgateway.transaction-url-provider' );
|
49 |
-
|
50 |
return new PayPalGateway(
|
51 |
$settings_renderer,
|
52 |
$order_processor,
|
@@ -56,7 +56,8 @@ return array(
|
|
56 |
$session_handler,
|
57 |
$refund_processor,
|
58 |
$state,
|
59 |
-
$transaction_url_provider
|
|
|
60 |
);
|
61 |
},
|
62 |
'wcgateway.credit-card-gateway' => static function ( $container ): CreditCardGateway {
|
@@ -74,6 +75,7 @@ return array(
|
|
74 |
$purchase_unit_factory = $container->get( 'api.factory.purchase-unit' );
|
75 |
$payer_factory = $container->get( 'api.factory.payer' );
|
76 |
$order_endpoint = $container->get( 'api.endpoint.order' );
|
|
|
77 |
return new CreditCardGateway(
|
78 |
$settings_renderer,
|
79 |
$order_processor,
|
@@ -88,7 +90,8 @@ return array(
|
|
88 |
$payment_token_repository,
|
89 |
$purchase_unit_factory,
|
90 |
$payer_factory,
|
91 |
-
$order_endpoint
|
|
|
92 |
);
|
93 |
},
|
94 |
'wcgateway.disabler' => static function ( $container ): DisableGateways {
|
@@ -133,7 +136,8 @@ return array(
|
|
133 |
$webhook_registrar = $container->get( 'webhook.registrar' );
|
134 |
$state = $container->get( 'onboarding.state' );
|
135 |
$cache = new Cache( 'ppcp-paypal-bearer' );
|
136 |
-
|
|
|
137 |
},
|
138 |
'wcgateway.order-processor' => static function ( $container ): OrderProcessor {
|
139 |
|
@@ -145,7 +149,6 @@ return array(
|
|
145 |
$settings = $container->get( 'wcgateway.settings' );
|
146 |
$environment = $container->get( 'onboarding.environment' );
|
147 |
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
148 |
-
|
149 |
return new OrderProcessor(
|
150 |
$session_handler,
|
151 |
$order_endpoint,
|
@@ -182,7 +185,6 @@ return array(
|
|
182 |
'wcgateway.settings.fields' => static function ( $container ): array {
|
183 |
|
184 |
$state = $container->get( 'onboarding.state' );
|
185 |
-
$settings = $container->get( 'wcgateway.settings' );
|
186 |
$messages_disclaimers = $container->get( 'button.helper.messages-disclaimers' );
|
187 |
|
188 |
$fields = array(
|
@@ -634,8 +636,9 @@ return array(
|
|
634 |
'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ),
|
635 |
'type' => 'checkbox',
|
636 |
'desc_tip' => true,
|
637 |
-
'label'
|
638 |
-
|
|
|
639 |
'<a
|
640 |
href="https://docs.woocommerce.com/document/woocommerce-paypal-payments/#enable-vaulting-on-your-live-account"
|
641 |
target="_blank"
|
@@ -1806,7 +1809,6 @@ return array(
|
|
1806 |
unset( $fields['disable_funding']['options']['card'] );
|
1807 |
}
|
1808 |
|
1809 |
-
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
1810 |
/**
|
1811 |
* Depending on your store location, some credit cards can't be used.
|
1812 |
* Here, we filter them out.
|
@@ -1815,6 +1817,7 @@ return array(
|
|
1815 |
*
|
1816 |
* @var DccApplies $dcc_applies
|
1817 |
*/
|
|
|
1818 |
$card_options = $fields['disable_cards']['options'];
|
1819 |
foreach ( $card_options as $card => $label ) {
|
1820 |
if ( $dcc_applies->can_process_card( $card ) ) {
|
@@ -1824,6 +1827,18 @@ return array(
|
|
1824 |
}
|
1825 |
$fields['disable_cards']['options'] = $card_options;
|
1826 |
$fields['card_icons']['options'] = $card_options;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1827 |
return $fields;
|
1828 |
},
|
1829 |
|
46 |
$refund_processor = $container->get( 'wcgateway.processor.refunds' );
|
47 |
$state = $container->get( 'onboarding.state' );
|
48 |
$transaction_url_provider = $container->get( 'wcgateway.transaction-url-provider' );
|
49 |
+
$subscription_helper = $container->get( 'subscription.helper' );
|
50 |
return new PayPalGateway(
|
51 |
$settings_renderer,
|
52 |
$order_processor,
|
56 |
$session_handler,
|
57 |
$refund_processor,
|
58 |
$state,
|
59 |
+
$transaction_url_provider,
|
60 |
+
$subscription_helper
|
61 |
);
|
62 |
},
|
63 |
'wcgateway.credit-card-gateway' => static function ( $container ): CreditCardGateway {
|
75 |
$purchase_unit_factory = $container->get( 'api.factory.purchase-unit' );
|
76 |
$payer_factory = $container->get( 'api.factory.payer' );
|
77 |
$order_endpoint = $container->get( 'api.endpoint.order' );
|
78 |
+
$subscription_helper = $container->get( 'subscription.helper' );
|
79 |
return new CreditCardGateway(
|
80 |
$settings_renderer,
|
81 |
$order_processor,
|
90 |
$payment_token_repository,
|
91 |
$purchase_unit_factory,
|
92 |
$payer_factory,
|
93 |
+
$order_endpoint,
|
94 |
+
$subscription_helper
|
95 |
);
|
96 |
},
|
97 |
'wcgateway.disabler' => static function ( $container ): DisableGateways {
|
136 |
$webhook_registrar = $container->get( 'webhook.registrar' );
|
137 |
$state = $container->get( 'onboarding.state' );
|
138 |
$cache = new Cache( 'ppcp-paypal-bearer' );
|
139 |
+
$bearer = $container->get( 'api.bearer' );
|
140 |
+
return new SettingsListener( $settings, $fields, $webhook_registrar, $cache, $state, $bearer );
|
141 |
},
|
142 |
'wcgateway.order-processor' => static function ( $container ): OrderProcessor {
|
143 |
|
149 |
$settings = $container->get( 'wcgateway.settings' );
|
150 |
$environment = $container->get( 'onboarding.environment' );
|
151 |
$logger = $container->get( 'woocommerce.logger.woocommerce' );
|
|
|
152 |
return new OrderProcessor(
|
153 |
$session_handler,
|
154 |
$order_endpoint,
|
185 |
'wcgateway.settings.fields' => static function ( $container ): array {
|
186 |
|
187 |
$state = $container->get( 'onboarding.state' );
|
|
|
188 |
$messages_disclaimers = $container->get( 'button.helper.messages-disclaimers' );
|
189 |
|
190 |
$fields = array(
|
636 |
'title' => __( 'Vaulting', 'woocommerce-paypal-payments' ),
|
637 |
'type' => 'checkbox',
|
638 |
'desc_tip' => true,
|
639 |
+
'label' => sprintf(
|
640 |
+
// translators: %1$s and %2$s are the opening and closing of HTML <a> tag.
|
641 |
+
__( 'Enable saved cards and subscription features on your store. To use vaulting features, you must %1$senable vaulting on your account%2$s.', 'woocommerce-paypal-payments' ),
|
642 |
'<a
|
643 |
href="https://docs.woocommerce.com/document/woocommerce-paypal-payments/#enable-vaulting-on-your-live-account"
|
644 |
target="_blank"
|
1809 |
unset( $fields['disable_funding']['options']['card'] );
|
1810 |
}
|
1811 |
|
|
|
1812 |
/**
|
1813 |
* Depending on your store location, some credit cards can't be used.
|
1814 |
* Here, we filter them out.
|
1817 |
*
|
1818 |
* @var DccApplies $dcc_applies
|
1819 |
*/
|
1820 |
+
$dcc_applies = $container->get( 'api.helpers.dccapplies' );
|
1821 |
$card_options = $fields['disable_cards']['options'];
|
1822 |
foreach ( $card_options as $card => $label ) {
|
1823 |
if ( $dcc_applies->can_process_card( $card ) ) {
|
1827 |
}
|
1828 |
$fields['disable_cards']['options'] = $card_options;
|
1829 |
$fields['card_icons']['options'] = $card_options;
|
1830 |
+
|
1831 |
+
/**
|
1832 |
+
* Display vault message on Pay Later label if vault is enabled.
|
1833 |
+
*/
|
1834 |
+
$settings = $container->get( 'wcgateway.settings' );
|
1835 |
+
if ( $settings->has( 'vault_enabled' ) && $settings->get( 'vault_enabled' ) ) {
|
1836 |
+
$message = __( "You have PayPal vaulting enabled, that's why Pay Later Messaging options are unavailable now. You cannot use both features at the same time.", 'woocommerce-paypal-payments' );
|
1837 |
+
$fields['message_enabled']['label'] = $message;
|
1838 |
+
$fields['message_product_enabled']['label'] = $message;
|
1839 |
+
$fields['message_cart_enabled']['label'] = $message;
|
1840 |
+
}
|
1841 |
+
|
1842 |
return $fields;
|
1843 |
},
|
1844 |
|
modules/ppcp-wc-gateway/src/Assets/class-settingspageassets.php
CHANGED
@@ -9,6 +9,8 @@ declare(strict_types=1);
|
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
11 |
|
|
|
|
|
12 |
/**
|
13 |
* Class SettingsPageAssets
|
14 |
*/
|
@@ -20,6 +22,7 @@ class SettingsPageAssets {
|
|
20 |
* @var string
|
21 |
*/
|
22 |
private $module_url;
|
|
|
23 |
/**
|
24 |
* The filesystem path to the module dir.
|
25 |
*
|
@@ -27,24 +30,34 @@ class SettingsPageAssets {
|
|
27 |
*/
|
28 |
private $module_path;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Assets constructor.
|
32 |
*
|
33 |
* @param string $module_url The url of this module.
|
34 |
* @param string $module_path The filesystem path to this module.
|
|
|
35 |
*/
|
36 |
-
public function __construct( string $module_url, string $module_path ) {
|
37 |
$this->module_url = $module_url;
|
38 |
$this->module_path = $module_path;
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
42 |
* Register assets provided by this module.
|
43 |
*/
|
44 |
public function register_assets() {
|
|
|
45 |
add_action(
|
46 |
'admin_enqueue_scripts',
|
47 |
-
function() {
|
48 |
if ( ! is_admin() || is_ajax() ) {
|
49 |
return;
|
50 |
}
|
@@ -53,7 +66,7 @@ class SettingsPageAssets {
|
|
53 |
return;
|
54 |
}
|
55 |
|
56 |
-
$this->register_admin_assets();
|
57 |
}
|
58 |
);
|
59 |
|
@@ -84,8 +97,10 @@ class SettingsPageAssets {
|
|
84 |
|
85 |
/**
|
86 |
* Register assets for admin pages.
|
|
|
|
|
87 |
*/
|
88 |
-
private function register_admin_assets() {
|
89 |
$gateway_settings_script_path = trailingslashit( $this->module_path ) . 'assets/js/gateway-settings.js';
|
90 |
|
91 |
wp_enqueue_script(
|
@@ -95,5 +110,14 @@ class SettingsPageAssets {
|
|
95 |
file_exists( $gateway_settings_script_path ) ? (string) filemtime( $gateway_settings_script_path ) : null,
|
96 |
true
|
97 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
}
|
99 |
}
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\WcGateway\Assets;
|
11 |
|
12 |
+
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
13 |
+
|
14 |
/**
|
15 |
* Class SettingsPageAssets
|
16 |
*/
|
22 |
* @var string
|
23 |
*/
|
24 |
private $module_url;
|
25 |
+
|
26 |
/**
|
27 |
* The filesystem path to the module dir.
|
28 |
*
|
30 |
*/
|
31 |
private $module_path;
|
32 |
|
33 |
+
/**
|
34 |
+
* The bearer.
|
35 |
+
*
|
36 |
+
* @var Bearer
|
37 |
+
*/
|
38 |
+
private $bearer;
|
39 |
+
|
40 |
/**
|
41 |
* Assets constructor.
|
42 |
*
|
43 |
* @param string $module_url The url of this module.
|
44 |
* @param string $module_path The filesystem path to this module.
|
45 |
+
* @param Bearer $bearer The bearer.
|
46 |
*/
|
47 |
+
public function __construct( string $module_url, string $module_path, Bearer $bearer ) {
|
48 |
$this->module_url = $module_url;
|
49 |
$this->module_path = $module_path;
|
50 |
+
$this->bearer = $bearer;
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
* Register assets provided by this module.
|
55 |
*/
|
56 |
public function register_assets() {
|
57 |
+
$bearer = $this->bearer;
|
58 |
add_action(
|
59 |
'admin_enqueue_scripts',
|
60 |
+
function() use ( $bearer ) {
|
61 |
if ( ! is_admin() || is_ajax() ) {
|
62 |
return;
|
63 |
}
|
66 |
return;
|
67 |
}
|
68 |
|
69 |
+
$this->register_admin_assets( $bearer );
|
70 |
}
|
71 |
);
|
72 |
|
97 |
|
98 |
/**
|
99 |
* Register assets for admin pages.
|
100 |
+
*
|
101 |
+
* @param Bearer $bearer The bearer.
|
102 |
*/
|
103 |
+
private function register_admin_assets( Bearer $bearer ) {
|
104 |
$gateway_settings_script_path = trailingslashit( $this->module_path ) . 'assets/js/gateway-settings.js';
|
105 |
|
106 |
wp_enqueue_script(
|
110 |
file_exists( $gateway_settings_script_path ) ? (string) filemtime( $gateway_settings_script_path ) : null,
|
111 |
true
|
112 |
);
|
113 |
+
|
114 |
+
$token = $bearer->bearer();
|
115 |
+
wp_localize_script(
|
116 |
+
'ppcp-gateway-settings',
|
117 |
+
'PayPalCommerceGatewaySettings',
|
118 |
+
array(
|
119 |
+
'vaulting_features_available' => $token->vaulting_available(),
|
120 |
+
)
|
121 |
+
);
|
122 |
}
|
123 |
}
|
modules/ppcp-wc-gateway/src/Gateway/class-creditcardgateway.php
CHANGED
@@ -14,6 +14,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Factory\PayerFactory;
|
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
15 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
16 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
|
|
17 |
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
18 |
use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
19 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
@@ -38,6 +39,13 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
38 |
*/
|
39 |
protected $transaction_url_provider;
|
40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
/**
|
42 |
* The URL to the module.
|
43 |
*
|
@@ -97,6 +105,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
97 |
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
98 |
* @param PayerFactory $payer_factory The payer factory.
|
99 |
* @param OrderEndpoint $order_endpoint The order endpoint.
|
|
|
100 |
*/
|
101 |
public function __construct(
|
102 |
SettingsRenderer $settings_renderer,
|
@@ -112,7 +121,8 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
112 |
PaymentTokenRepository $payment_token_repository,
|
113 |
PurchaseUnitFactory $purchase_unit_factory,
|
114 |
PayerFactory $payer_factory,
|
115 |
-
OrderEndpoint $order_endpoint
|
|
|
116 |
) {
|
117 |
|
118 |
$this->id = self::ID;
|
@@ -179,6 +189,7 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
179 |
$this->payer_factory = $payer_factory;
|
180 |
$this->order_endpoint = $order_endpoint;
|
181 |
$this->transaction_url_provider = $transaction_url_provider;
|
|
|
182 |
}
|
183 |
|
184 |
/**
|
@@ -198,6 +209,32 @@ class CreditCardGateway extends \WC_Payment_Gateway_CC {
|
|
198 |
);
|
199 |
}
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
/**
|
202 |
* Returns the title of the gateway.
|
203 |
*
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\PurchaseUnitFactory;
|
15 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
16 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
17 |
+
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
18 |
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
19 |
use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
20 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
39 |
*/
|
40 |
protected $transaction_url_provider;
|
41 |
|
42 |
+
/**
|
43 |
+
* The subscription helper.
|
44 |
+
*
|
45 |
+
* @var SubscriptionHelper
|
46 |
+
*/
|
47 |
+
protected $subscription_helper;
|
48 |
+
|
49 |
/**
|
50 |
* The URL to the module.
|
51 |
*
|
105 |
* @param PurchaseUnitFactory $purchase_unit_factory The purchase unit factory.
|
106 |
* @param PayerFactory $payer_factory The payer factory.
|
107 |
* @param OrderEndpoint $order_endpoint The order endpoint.
|
108 |
+
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
109 |
*/
|
110 |
public function __construct(
|
111 |
SettingsRenderer $settings_renderer,
|
121 |
PaymentTokenRepository $payment_token_repository,
|
122 |
PurchaseUnitFactory $purchase_unit_factory,
|
123 |
PayerFactory $payer_factory,
|
124 |
+
OrderEndpoint $order_endpoint,
|
125 |
+
SubscriptionHelper $subscription_helper
|
126 |
) {
|
127 |
|
128 |
$this->id = self::ID;
|
189 |
$this->payer_factory = $payer_factory;
|
190 |
$this->order_endpoint = $order_endpoint;
|
191 |
$this->transaction_url_provider = $transaction_url_provider;
|
192 |
+
$this->subscription_helper = $subscription_helper;
|
193 |
}
|
194 |
|
195 |
/**
|
209 |
);
|
210 |
}
|
211 |
|
212 |
+
/**
|
213 |
+
* Render the credit card fields.
|
214 |
+
*/
|
215 |
+
public function form() {
|
216 |
+
add_action( 'gettext', array( $this, 'replace_credit_card_cvv_label' ), 10, 3 );
|
217 |
+
parent::form();
|
218 |
+
remove_action( 'gettext', 'replace_credit_card_cvv_label' );
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Replace WooCommerce credit card field label.
|
223 |
+
*
|
224 |
+
* @param string $translation Translated text.
|
225 |
+
* @param string $text Original text to translate.
|
226 |
+
* @param string $domain Text domain.
|
227 |
+
*
|
228 |
+
* @return string Translated field.
|
229 |
+
*/
|
230 |
+
public function replace_credit_card_cvv_label( string $translation, string $text, string $domain ): string {
|
231 |
+
if ( 'woocommerce' !== $domain || 'Card code' !== $text ) {
|
232 |
+
return $translation;
|
233 |
+
}
|
234 |
+
|
235 |
+
return __( 'CVV', 'woocommerce-paypal-payments' );
|
236 |
+
}
|
237 |
+
|
238 |
/**
|
239 |
* Returns the title of the gateway.
|
240 |
*
|
modules/ppcp-wc-gateway/src/Gateway/class-paypalgateway.php
CHANGED
@@ -11,6 +11,7 @@ namespace WooCommerce\PayPalCommerce\WcGateway\Gateway;
|
|
11 |
|
12 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
13 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
|
|
14 |
use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
15 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
16 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
@@ -81,6 +82,13 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
81 |
*/
|
82 |
protected $transaction_url_provider;
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* The Refund Processor.
|
86 |
*
|
@@ -100,6 +108,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
100 |
* @param RefundProcessor $refund_processor The Refund Processor.
|
101 |
* @param State $state The state.
|
102 |
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
|
|
103 |
*/
|
104 |
public function __construct(
|
105 |
SettingsRenderer $settings_renderer,
|
@@ -110,7 +119,8 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
110 |
SessionHandler $session_handler,
|
111 |
RefundProcessor $refund_processor,
|
112 |
State $state,
|
113 |
-
TransactionUrlProvider $transaction_url_provider
|
|
|
114 |
) {
|
115 |
|
116 |
$this->id = self::ID;
|
@@ -165,6 +175,7 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
165 |
'process_admin_options',
|
166 |
)
|
167 |
);
|
|
|
168 |
}
|
169 |
|
170 |
/**
|
@@ -216,10 +227,9 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
216 |
$wc_order->add_order_note(
|
217 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
218 |
);
|
219 |
-
|
220 |
-
$wc_order->set_status( 'processing' );
|
221 |
$wc_order->update_meta_data( self::CAPTURED_META_KEY, 'true' );
|
222 |
$wc_order->save();
|
|
|
223 |
return true;
|
224 |
}
|
225 |
|
@@ -228,11 +238,11 @@ class PayPalGateway extends \WC_Payment_Gateway {
|
|
228 |
$wc_order->add_order_note(
|
229 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
230 |
);
|
231 |
-
$wc_order->set_status( 'processing' );
|
232 |
}
|
233 |
|
234 |
$wc_order->update_meta_data( self::CAPTURED_META_KEY, 'true' );
|
235 |
$wc_order->save();
|
|
|
236 |
return true;
|
237 |
}
|
238 |
return false;
|
11 |
|
12 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
13 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
14 |
+
use WooCommerce\PayPalCommerce\Subscription\Helper\SubscriptionHelper;
|
15 |
use WooCommerce\PayPalCommerce\WcGateway\Notice\AuthorizeOrderActionNotice;
|
16 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\AuthorizedPaymentsProcessor;
|
17 |
use WooCommerce\PayPalCommerce\WcGateway\Processor\OrderProcessor;
|
82 |
*/
|
83 |
protected $transaction_url_provider;
|
84 |
|
85 |
+
/**
|
86 |
+
* The subscription helper.
|
87 |
+
*
|
88 |
+
* @var SubscriptionHelper
|
89 |
+
*/
|
90 |
+
protected $subscription_helper;
|
91 |
+
|
92 |
/**
|
93 |
* The Refund Processor.
|
94 |
*
|
108 |
* @param RefundProcessor $refund_processor The Refund Processor.
|
109 |
* @param State $state The state.
|
110 |
* @param TransactionUrlProvider $transaction_url_provider Service providing transaction view URL based on order.
|
111 |
+
* @param SubscriptionHelper $subscription_helper The subscription helper.
|
112 |
*/
|
113 |
public function __construct(
|
114 |
SettingsRenderer $settings_renderer,
|
119 |
SessionHandler $session_handler,
|
120 |
RefundProcessor $refund_processor,
|
121 |
State $state,
|
122 |
+
TransactionUrlProvider $transaction_url_provider,
|
123 |
+
SubscriptionHelper $subscription_helper
|
124 |
) {
|
125 |
|
126 |
$this->id = self::ID;
|
175 |
'process_admin_options',
|
176 |
)
|
177 |
);
|
178 |
+
$this->subscription_helper = $subscription_helper;
|
179 |
}
|
180 |
|
181 |
/**
|
227 |
$wc_order->add_order_note(
|
228 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
229 |
);
|
|
|
|
|
230 |
$wc_order->update_meta_data( self::CAPTURED_META_KEY, 'true' );
|
231 |
$wc_order->save();
|
232 |
+
$wc_order->payment_complete();
|
233 |
return true;
|
234 |
}
|
235 |
|
238 |
$wc_order->add_order_note(
|
239 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
240 |
);
|
|
|
241 |
}
|
242 |
|
243 |
$wc_order->update_meta_data( self::CAPTURED_META_KEY, 'true' );
|
244 |
$wc_order->save();
|
245 |
+
$wc_order->payment_complete();
|
246 |
return true;
|
247 |
}
|
248 |
return false;
|
modules/ppcp-wc-gateway/src/Gateway/class-processpaymenttrait.php
CHANGED
@@ -42,10 +42,11 @@ trait ProcessPaymentTrait {
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* If customer has
|
46 |
*/
|
47 |
$saved_credit_card = filter_input( INPUT_POST, 'saved_credit_card', FILTER_SANITIZE_STRING );
|
48 |
-
|
|
|
49 |
|
50 |
$user_id = (int) $wc_order->get_customer_id();
|
51 |
$customer = new \WC_Customer( $user_id );
|
@@ -91,6 +92,32 @@ trait ProcessPaymentTrait {
|
|
91 |
}
|
92 |
}
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
/**
|
95 |
* If the WC_Order is payed through the approved webhook.
|
96 |
*/
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
+
* If customer has chosen a saved credit card payment.
|
46 |
*/
|
47 |
$saved_credit_card = filter_input( INPUT_POST, 'saved_credit_card', FILTER_SANITIZE_STRING );
|
48 |
+
$pay_for_order = filter_input( INPUT_GET, 'pay_for_order', FILTER_SANITIZE_STRING );
|
49 |
+
if ( $saved_credit_card && ! isset( $pay_for_order ) ) {
|
50 |
|
51 |
$user_id = (int) $wc_order->get_customer_id();
|
52 |
$customer = new \WC_Customer( $user_id );
|
92 |
}
|
93 |
}
|
94 |
|
95 |
+
/**
|
96 |
+
* If customer has chosen change Subscription payment.
|
97 |
+
*/
|
98 |
+
if ( $this->subscription_helper->has_subscription( $order_id ) && $this->subscription_helper->is_subscription_change_payment() ) {
|
99 |
+
if ( 'ppcp-credit-card-gateway' === $this->id && $saved_credit_card ) {
|
100 |
+
update_post_meta( $order_id, 'payment_token_id', $saved_credit_card );
|
101 |
+
|
102 |
+
$this->session_handler->destroy_session_data();
|
103 |
+
return array(
|
104 |
+
'result' => 'success',
|
105 |
+
'redirect' => $this->get_return_url( $wc_order ),
|
106 |
+
);
|
107 |
+
}
|
108 |
+
|
109 |
+
$saved_paypal_payment = filter_input( INPUT_POST, 'saved_paypal_payment', FILTER_SANITIZE_STRING );
|
110 |
+
if ( 'ppcp-gateway' === $this->id && $saved_paypal_payment ) {
|
111 |
+
update_post_meta( $order_id, 'payment_token_id', $saved_paypal_payment );
|
112 |
+
|
113 |
+
$this->session_handler->destroy_session_data();
|
114 |
+
return array(
|
115 |
+
'result' => 'success',
|
116 |
+
'redirect' => $this->get_return_url( $wc_order ),
|
117 |
+
);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
/**
|
122 |
* If the WC_Order is payed through the approved webhook.
|
123 |
*/
|
modules/ppcp-wc-gateway/src/Processor/class-orderprocessor.php
CHANGED
@@ -16,6 +16,7 @@ use WooCommerce\PayPalCommerce\ApiClient\Entity\OrderStatus;
|
|
16 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
17 |
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
18 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
|
|
19 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
20 |
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
21 |
|
@@ -31,6 +32,13 @@ class OrderProcessor {
|
|
31 |
*/
|
32 |
protected $sandbox_mode;
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* The Session Handler.
|
36 |
*
|
@@ -176,10 +184,8 @@ class OrderProcessor {
|
|
176 |
__( 'Awaiting payment.', 'woocommerce-paypal-payments' )
|
177 |
);
|
178 |
if ( $order->status()->is( OrderStatus::COMPLETED ) && $order->intent() === 'CAPTURE' ) {
|
179 |
-
|
180 |
-
|
181 |
-
__( 'Payment received.', 'woocommerce-paypal-payments' )
|
182 |
-
);
|
183 |
}
|
184 |
|
185 |
if ( $this->capture_authorized_downloads( $order ) && $this->authorized_payments_processor->process( $wc_order ) ) {
|
16 |
use WooCommerce\PayPalCommerce\ApiClient\Factory\OrderFactory;
|
17 |
use WooCommerce\PayPalCommerce\Button\Helper\ThreeDSecure;
|
18 |
use WooCommerce\PayPalCommerce\Session\SessionHandler;
|
19 |
+
use WooCommerce\PayPalCommerce\Subscription\Repository\PaymentTokenRepository;
|
20 |
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
21 |
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
22 |
|
32 |
*/
|
33 |
protected $sandbox_mode;
|
34 |
|
35 |
+
/**
|
36 |
+
* The payment token repository.
|
37 |
+
*
|
38 |
+
* @var PaymentTokenRepository
|
39 |
+
*/
|
40 |
+
protected $payment_token_repository;
|
41 |
+
|
42 |
/**
|
43 |
* The Session Handler.
|
44 |
*
|
184 |
__( 'Awaiting payment.', 'woocommerce-paypal-payments' )
|
185 |
);
|
186 |
if ( $order->status()->is( OrderStatus::COMPLETED ) && $order->intent() === 'CAPTURE' ) {
|
187 |
+
|
188 |
+
$wc_order->payment_complete();
|
|
|
|
|
189 |
}
|
190 |
|
191 |
if ( $this->capture_authorized_downloads( $order ) && $this->authorized_payments_processor->process( $wc_order ) ) {
|
modules/ppcp-wc-gateway/src/Settings/class-settingslistener.php
CHANGED
@@ -9,6 +9,7 @@ declare(strict_types=1);
|
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
11 |
|
|
|
12 |
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
13 |
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
14 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
@@ -21,7 +22,6 @@ use WooCommerce\PayPalCommerce\Webhooks\WebhookRegistrar;
|
|
21 |
*/
|
22 |
class SettingsListener {
|
23 |
|
24 |
-
|
25 |
const NONCE = 'ppcp-settings';
|
26 |
|
27 |
/**
|
@@ -59,6 +59,13 @@ class SettingsListener {
|
|
59 |
*/
|
60 |
private $state;
|
61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
/**
|
63 |
* SettingsListener constructor.
|
64 |
*
|
@@ -67,13 +74,15 @@ class SettingsListener {
|
|
67 |
* @param WebhookRegistrar $webhook_registrar The Webhook Registrar.
|
68 |
* @param Cache $cache The Cache.
|
69 |
* @param State $state The state.
|
|
|
70 |
*/
|
71 |
public function __construct(
|
72 |
Settings $settings,
|
73 |
array $setting_fields,
|
74 |
WebhookRegistrar $webhook_registrar,
|
75 |
Cache $cache,
|
76 |
-
State $state
|
|
|
77 |
) {
|
78 |
|
79 |
$this->settings = $settings;
|
@@ -81,6 +90,7 @@ class SettingsListener {
|
|
81 |
$this->webhook_registrar = $webhook_registrar;
|
82 |
$this->cache = $cache;
|
83 |
$this->state = $state;
|
|
|
84 |
}
|
85 |
|
86 |
/**
|
@@ -137,6 +147,13 @@ class SettingsListener {
|
|
137 |
return;
|
138 |
}
|
139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
/**
|
141 |
* No need to verify nonce here.
|
142 |
*
|
9 |
|
10 |
namespace WooCommerce\PayPalCommerce\WcGateway\Settings;
|
11 |
|
12 |
+
use WooCommerce\PayPalCommerce\ApiClient\Authentication\Bearer;
|
13 |
use WooCommerce\PayPalCommerce\ApiClient\Authentication\PayPalBearer;
|
14 |
use WooCommerce\PayPalCommerce\ApiClient\Helper\Cache;
|
15 |
use WooCommerce\PayPalCommerce\Onboarding\State;
|
22 |
*/
|
23 |
class SettingsListener {
|
24 |
|
|
|
25 |
const NONCE = 'ppcp-settings';
|
26 |
|
27 |
/**
|
59 |
*/
|
60 |
private $state;
|
61 |
|
62 |
+
/**
|
63 |
+
* The Bearer.
|
64 |
+
*
|
65 |
+
* @var Bearer
|
66 |
+
*/
|
67 |
+
private $bearer;
|
68 |
+
|
69 |
/**
|
70 |
* SettingsListener constructor.
|
71 |
*
|
74 |
* @param WebhookRegistrar $webhook_registrar The Webhook Registrar.
|
75 |
* @param Cache $cache The Cache.
|
76 |
* @param State $state The state.
|
77 |
+
* @param Bearer $bearer The bearer.
|
78 |
*/
|
79 |
public function __construct(
|
80 |
Settings $settings,
|
81 |
array $setting_fields,
|
82 |
WebhookRegistrar $webhook_registrar,
|
83 |
Cache $cache,
|
84 |
+
State $state,
|
85 |
+
Bearer $bearer
|
86 |
) {
|
87 |
|
88 |
$this->settings = $settings;
|
90 |
$this->webhook_registrar = $webhook_registrar;
|
91 |
$this->cache = $cache;
|
92 |
$this->state = $state;
|
93 |
+
$this->bearer = $bearer;
|
94 |
}
|
95 |
|
96 |
/**
|
147 |
return;
|
148 |
}
|
149 |
|
150 |
+
$token = $this->bearer->bearer();
|
151 |
+
if ( ! $token->vaulting_available() ) {
|
152 |
+
$this->settings->set( 'vault_enabled', false );
|
153 |
+
$this->settings->persist();
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
/**
|
158 |
* No need to verify nonce here.
|
159 |
*
|
modules/ppcp-wc-gateway/src/class-wcgatewaymodule.php
CHANGED
@@ -76,7 +76,8 @@ class WcGatewayModule implements ModuleInterface {
|
|
76 |
if ( $container->has( 'wcgateway.url' ) ) {
|
77 |
$assets = new SettingsPageAssets(
|
78 |
$container->get( 'wcgateway.url' ),
|
79 |
-
$container->get( 'wcgateway.absolute-path' )
|
|
|
80 |
);
|
81 |
$assets->register_assets();
|
82 |
}
|
76 |
if ( $container->has( 'wcgateway.url' ) ) {
|
77 |
$assets = new SettingsPageAssets(
|
78 |
$container->get( 'wcgateway.url' ),
|
79 |
+
$container->get( 'wcgateway.absolute-path' ),
|
80 |
+
$container->get( 'api.bearer' )
|
81 |
);
|
82 |
$assets->register_assets();
|
83 |
}
|
modules/ppcp-webhooks/src/Handler/class-paymentcapturecompleted.php
CHANGED
@@ -117,7 +117,7 @@ class PaymentCaptureCompleted implements RequestHandler {
|
|
117 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
118 |
);
|
119 |
|
120 |
-
$wc_order->
|
121 |
$wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'true' );
|
122 |
$wc_order->save();
|
123 |
$this->logger->log(
|
117 |
__( 'Payment successfully captured.', 'woocommerce-paypal-payments' )
|
118 |
);
|
119 |
|
120 |
+
$wc_order->payment_complete();
|
121 |
$wc_order->update_meta_data( PayPalGateway::CAPTURED_META_KEY, 'true' );
|
122 |
$wc_order->save();
|
123 |
$this->logger->log(
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: woocommerce, paypal, payments, ecommerce, e-commerce, store, sales, sell,
|
|
4 |
Requires at least: 5.3
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 7.1
|
7 |
-
Stable tag: 1.3.
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -58,6 +58,17 @@ Follow the steps below to connect the plugin to your PayPal account:
|
|
58 |
|
59 |
== Changelog ==
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
= 1.3.1 =
|
62 |
* Fix - Fix Credit Card fields for non logged-in users. #152
|
63 |
|
4 |
Requires at least: 5.3
|
5 |
Tested up to: 5.7
|
6 |
Requires PHP: 7.1
|
7 |
+
Stable tag: 1.3.2
|
8 |
License: GPLv2
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
58 |
|
59 |
== Changelog ==
|
60 |
|
61 |
+
= 1.3.2 =
|
62 |
+
* Fix - Improve Subscription plugin support. #161
|
63 |
+
* Fix - Disable vault setting if vaulting feature is not available. #150
|
64 |
+
* Fix - Cast item get_quantity into int. #168
|
65 |
+
* Fix - Fix Credit Card form fields placeholder and label. #146
|
66 |
+
* Fix - Filter PayPal-supported language codes. #154
|
67 |
+
* Fix - Wrong order status for orders with contain only products which are both virtual and downloadable. #145
|
68 |
+
* Fix - Use order_number instead of internal id when creating invoice Id. #163
|
69 |
+
* Fix - Fix pay later messaging options. #141
|
70 |
+
* Fix - UI/UX for vaulting settings. #166
|
71 |
+
|
72 |
= 1.3.1 =
|
73 |
* Fix - Fix Credit Card fields for non logged-in users. #152
|
74 |
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit676d4bb90dad167891cc9fe8fa075f37::getLoader();
|
vendor/composer/ClassLoader.php
CHANGED
@@ -338,7 +338,7 @@ class ClassLoader
|
|
338 |
* Loads the given class or interface.
|
339 |
*
|
340 |
* @param string $class The name of the class
|
341 |
-
* @return
|
342 |
*/
|
343 |
public function loadClass($class)
|
344 |
{
|
@@ -347,6 +347,8 @@ class ClassLoader
|
|
347 |
|
348 |
return true;
|
349 |
}
|
|
|
|
|
350 |
}
|
351 |
|
352 |
/**
|
338 |
* Loads the given class or interface.
|
339 |
*
|
340 |
* @param string $class The name of the class
|
341 |
+
* @return true|null True if loaded, null otherwise
|
342 |
*/
|
343 |
public function loadClass($class)
|
344 |
{
|
347 |
|
348 |
return true;
|
349 |
}
|
350 |
+
|
351 |
+
return null;
|
352 |
}
|
353 |
|
354 |
/**
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -1,402 +1,325 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
|
13 |
namespace Composer;
|
14 |
|
15 |
use Composer\Autoload\ClassLoader;
|
16 |
use Composer\Semver\VersionParser;
|
17 |
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
class InstalledVersions
|
26 |
{
|
27 |
-
private static $installed
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
);
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
return $
|
186 |
-
}
|
187 |
-
|
188 |
-
|
189 |
-
}
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
if (isset($installed['versions'][$packageName])) {
|
203 |
-
return
|
204 |
-
}
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
}
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
if (
|
252 |
-
|
253 |
-
}
|
254 |
-
|
255 |
-
|
256 |
-
}
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
return
|
262 |
-
}
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
if (
|
300 |
-
|
301 |
-
}
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
}
|
326 |
-
|
327 |
-
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
328 |
-
}
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
public static function getRootPackage()
|
335 |
-
{
|
336 |
-
$installed = self::getInstalled();
|
337 |
-
|
338 |
-
return $installed[0]['root'];
|
339 |
-
}
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
public static function getRawData()
|
348 |
-
{
|
349 |
-
return self::$installed;
|
350 |
-
}
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
public static function reload($data)
|
371 |
-
{
|
372 |
-
self::$installed = $data;
|
373 |
-
self::$installedByVendor = array();
|
374 |
-
}
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
private static function getInstalled()
|
381 |
-
{
|
382 |
-
if (null === self::$canGetVendors) {
|
383 |
-
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
384 |
-
}
|
385 |
-
|
386 |
-
$installed = array();
|
387 |
-
|
388 |
-
if (self::$canGetVendors) {
|
389 |
-
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
390 |
-
if (isset(self::$installedByVendor[$vendorDir])) {
|
391 |
-
$installed[] = self::$installedByVendor[$vendorDir];
|
392 |
-
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
393 |
-
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
394 |
-
}
|
395 |
-
}
|
396 |
-
}
|
397 |
-
|
398 |
-
$installed[] = self::$installed;
|
399 |
-
|
400 |
-
return $installed;
|
401 |
-
}
|
402 |
}
|
1 |
<?php
|
2 |
|
3 |
+
/*
|
4 |
+
* This file is part of Composer.
|
5 |
+
*
|
6 |
+
* (c) Nils Adermann <naderman@naderman.de>
|
7 |
+
* Jordi Boggiano <j.boggiano@seld.be>
|
8 |
+
*
|
9 |
+
* For the full copyright and license information, please view the LICENSE
|
10 |
+
* file that was distributed with this source code.
|
11 |
+
*/
|
12 |
|
13 |
namespace Composer;
|
14 |
|
15 |
use Composer\Autoload\ClassLoader;
|
16 |
use Composer\Semver\VersionParser;
|
17 |
|
18 |
+
/**
|
19 |
+
* This class is copied in every Composer installed project and available to all
|
20 |
+
*
|
21 |
+
* See also https://getcomposer.org/doc/07-runtime.md#installed-versions
|
22 |
+
*
|
23 |
+
* To require it's presence, you can require `composer-runtime-api ^2.0`
|
24 |
+
*/
|
25 |
class InstalledVersions
|
26 |
{
|
27 |
+
private static $installed;
|
28 |
+
private static $canGetVendors;
|
29 |
+
private static $installedByVendor = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Returns a list of all package names which are present, either by being installed, replaced or provided
|
33 |
+
*
|
34 |
+
* @return string[]
|
35 |
+
* @psalm-return list<string>
|
36 |
+
*/
|
37 |
+
public static function getInstalledPackages()
|
38 |
+
{
|
39 |
+
$packages = array();
|
40 |
+
foreach (self::getInstalled() as $installed) {
|
41 |
+
$packages[] = array_keys($installed['versions']);
|
42 |
+
}
|
43 |
+
|
44 |
+
if (1 === \count($packages)) {
|
45 |
+
return $packages[0];
|
46 |
+
}
|
47 |
+
|
48 |
+
return array_keys(array_flip(\call_user_func_array('array_merge', $packages)));
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Returns a list of all package names with a specific type e.g. 'library'
|
53 |
+
*
|
54 |
+
* @param string $type
|
55 |
+
* @return string[]
|
56 |
+
* @psalm-return list<string>
|
57 |
+
*/
|
58 |
+
public static function getInstalledPackagesByType($type)
|
59 |
+
{
|
60 |
+
$packagesByType = array();
|
61 |
+
|
62 |
+
foreach (self::getInstalled() as $installed) {
|
63 |
+
foreach ($installed['versions'] as $name => $package) {
|
64 |
+
if (isset($package['type']) && $package['type'] === $type) {
|
65 |
+
$packagesByType[] = $name;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
|
70 |
+
return $packagesByType;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Checks whether the given package is installed
|
75 |
+
*
|
76 |
+
* This also returns true if the package name is provided or replaced by another package
|
77 |
+
*
|
78 |
+
* @param string $packageName
|
79 |
+
* @param bool $includeDevRequirements
|
80 |
+
* @return bool
|
81 |
+
*/
|
82 |
+
public static function isInstalled($packageName, $includeDevRequirements = true)
|
83 |
+
{
|
84 |
+
foreach (self::getInstalled() as $installed) {
|
85 |
+
if (isset($installed['versions'][$packageName])) {
|
86 |
+
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return false;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Checks whether the given package satisfies a version constraint
|
95 |
+
*
|
96 |
+
* e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call:
|
97 |
+
*
|
98 |
+
* Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3')
|
99 |
+
*
|
100 |
+
* @param VersionParser $parser Install composer/semver to have access to this class and functionality
|
101 |
+
* @param string $packageName
|
102 |
+
* @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package
|
103 |
+
* @return bool
|
104 |
+
*/
|
105 |
+
public static function satisfies(VersionParser $parser, $packageName, $constraint)
|
106 |
+
{
|
107 |
+
$constraint = $parser->parseConstraints($constraint);
|
108 |
+
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
|
109 |
+
|
110 |
+
return $provided->matches($constraint);
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* Returns a version constraint representing all the range(s) which are installed for a given package
|
115 |
+
*
|
116 |
+
* It is easier to use this via isInstalled() with the $constraint argument if you need to check
|
117 |
+
* whether a given version of a package is installed, and not just whether it exists
|
118 |
+
*
|
119 |
+
* @param string $packageName
|
120 |
+
* @return string Version constraint usable with composer/semver
|
121 |
+
*/
|
122 |
+
public static function getVersionRanges($packageName)
|
123 |
+
{
|
124 |
+
foreach (self::getInstalled() as $installed) {
|
125 |
+
if (!isset($installed['versions'][$packageName])) {
|
126 |
+
continue;
|
127 |
+
}
|
128 |
+
|
129 |
+
$ranges = array();
|
130 |
+
if (isset($installed['versions'][$packageName]['pretty_version'])) {
|
131 |
+
$ranges[] = $installed['versions'][$packageName]['pretty_version'];
|
132 |
+
}
|
133 |
+
if (array_key_exists('aliases', $installed['versions'][$packageName])) {
|
134 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']);
|
135 |
+
}
|
136 |
+
if (array_key_exists('replaced', $installed['versions'][$packageName])) {
|
137 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']);
|
138 |
+
}
|
139 |
+
if (array_key_exists('provided', $installed['versions'][$packageName])) {
|
140 |
+
$ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']);
|
141 |
+
}
|
142 |
+
|
143 |
+
return implode(' || ', $ranges);
|
144 |
+
}
|
145 |
+
|
146 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* @param string $packageName
|
151 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
152 |
+
*/
|
153 |
+
public static function getVersion($packageName)
|
154 |
+
{
|
155 |
+
foreach (self::getInstalled() as $installed) {
|
156 |
+
if (!isset($installed['versions'][$packageName])) {
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
|
160 |
+
if (!isset($installed['versions'][$packageName]['version'])) {
|
161 |
+
return null;
|
162 |
+
}
|
163 |
+
|
164 |
+
return $installed['versions'][$packageName]['version'];
|
165 |
+
}
|
166 |
+
|
167 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @param string $packageName
|
172 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present
|
173 |
+
*/
|
174 |
+
public static function getPrettyVersion($packageName)
|
175 |
+
{
|
176 |
+
foreach (self::getInstalled() as $installed) {
|
177 |
+
if (!isset($installed['versions'][$packageName])) {
|
178 |
+
continue;
|
179 |
+
}
|
180 |
+
|
181 |
+
if (!isset($installed['versions'][$packageName]['pretty_version'])) {
|
182 |
+
return null;
|
183 |
+
}
|
184 |
+
|
185 |
+
return $installed['versions'][$packageName]['pretty_version'];
|
186 |
+
}
|
187 |
+
|
188 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* @param string $packageName
|
193 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference
|
194 |
+
*/
|
195 |
+
public static function getReference($packageName)
|
196 |
+
{
|
197 |
+
foreach (self::getInstalled() as $installed) {
|
198 |
+
if (!isset($installed['versions'][$packageName])) {
|
199 |
+
continue;
|
200 |
+
}
|
201 |
+
|
202 |
+
if (!isset($installed['versions'][$packageName]['reference'])) {
|
203 |
+
return null;
|
204 |
+
}
|
205 |
+
|
206 |
+
return $installed['versions'][$packageName]['reference'];
|
207 |
+
}
|
208 |
+
|
209 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
210 |
+
}
|
211 |
+
|
212 |
+
/**
|
213 |
+
* @param string $packageName
|
214 |
+
* @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path.
|
215 |
+
*/
|
216 |
+
public static function getInstallPath($packageName)
|
217 |
+
{
|
218 |
+
foreach (self::getInstalled() as $installed) {
|
219 |
+
if (!isset($installed['versions'][$packageName])) {
|
220 |
+
continue;
|
221 |
+
}
|
222 |
+
|
223 |
+
return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null;
|
224 |
+
}
|
225 |
+
|
226 |
+
throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed');
|
227 |
+
}
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @return array
|
231 |
+
* @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}
|
232 |
+
*/
|
233 |
+
public static function getRootPackage()
|
234 |
+
{
|
235 |
+
$installed = self::getInstalled();
|
236 |
+
|
237 |
+
return $installed[0]['root'];
|
238 |
+
}
|
239 |
+
|
240 |
+
/**
|
241 |
+
* Returns the raw installed.php data for custom implementations
|
242 |
+
*
|
243 |
+
* @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect.
|
244 |
+
* @return array[]
|
245 |
+
* @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}
|
246 |
+
*/
|
247 |
+
public static function getRawData()
|
248 |
+
{
|
249 |
+
@trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED);
|
250 |
+
|
251 |
+
if (null === self::$installed) {
|
252 |
+
self::$installed = include __DIR__ . '/installed.php';
|
253 |
+
}
|
254 |
+
|
255 |
+
return self::$installed;
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Returns the raw data of all installed.php which are currently loaded for custom implementations
|
260 |
+
*
|
261 |
+
* @return array[]
|
262 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
263 |
+
*/
|
264 |
+
public static function getAllRawData()
|
265 |
+
{
|
266 |
+
return self::getInstalled();
|
267 |
+
}
|
268 |
+
|
269 |
+
/**
|
270 |
+
* Lets you reload the static array from another file
|
271 |
+
*
|
272 |
+
* This is only useful for complex integrations in which a project needs to use
|
273 |
+
* this class but then also needs to execute another project's autoloader in process,
|
274 |
+
* and wants to ensure both projects have access to their version of installed.php.
|
275 |
+
*
|
276 |
+
* A typical case would be PHPUnit, where it would need to make sure it reads all
|
277 |
+
* the data it needs from this class, then call reload() with
|
278 |
+
* `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure
|
279 |
+
* the project in which it runs can then also use this class safely, without
|
280 |
+
* interference between PHPUnit's dependencies and the project's dependencies.
|
281 |
+
*
|
282 |
+
* @param array[] $data A vendor/composer/installed.php data set
|
283 |
+
* @return void
|
284 |
+
*
|
285 |
+
* @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>} $data
|
286 |
+
*/
|
287 |
+
public static function reload($data)
|
288 |
+
{
|
289 |
+
self::$installed = $data;
|
290 |
+
self::$installedByVendor = array();
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @return array[]
|
295 |
+
* @psalm-return list<array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[], dev: bool, install_path: string}, versions: array<string, array{dev_requirement: bool, pretty_version?: string, version?: string, aliases?: string[], reference?: string, replaced?: string[], provided?: string[], install_path?: string}>}>
|
296 |
+
*/
|
297 |
+
private static function getInstalled()
|
298 |
+
{
|
299 |
+
if (null === self::$canGetVendors) {
|
300 |
+
self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders');
|
301 |
+
}
|
302 |
+
|
303 |
+
$installed = array();
|
304 |
+
|
305 |
+
if (self::$canGetVendors) {
|
306 |
+
foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
|
307 |
+
if (isset(self::$installedByVendor[$vendorDir])) {
|
308 |
+
$installed[] = self::$installedByVendor[$vendorDir];
|
309 |
+
} elseif (is_file($vendorDir.'/composer/installed.php')) {
|
310 |
+
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
|
311 |
+
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
|
312 |
+
self::$installed = $installed[count($installed) - 1];
|
313 |
+
}
|
314 |
+
}
|
315 |
+
}
|
316 |
+
}
|
317 |
+
|
318 |
+
if (null === self::$installed) {
|
319 |
+
self::$installed = require __DIR__ . '/installed.php';
|
320 |
+
}
|
321 |
+
$installed[] = self::$installed;
|
322 |
+
|
323 |
+
return $installed;
|
324 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
325 |
}
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -24,15 +24,15 @@ class ComposerAutoloaderInit652ffd0f2996d93258e9b59ad0a5a779
|
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
-
spl_autoload_register(array('
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
-
spl_autoload_unregister(array('
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
-
call_user_func(\Composer\Autoload\
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
@@ -53,19 +53,19 @@ class ComposerAutoloaderInit652ffd0f2996d93258e9b59ad0a5a779
|
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
-
$includeFiles = Composer\Autoload\
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
-
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
function
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit676d4bb90dad167891cc9fe8fa075f37
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
+
spl_autoload_register(array('ComposerAutoloaderInit676d4bb90dad167891cc9fe8fa075f37', 'loadClassLoader'), true, true);
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
29 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit676d4bb90dad167891cc9fe8fa075f37', 'loadClassLoader'));
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37::getInitializer($loader));
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37::$files;
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
+
composerRequire676d4bb90dad167891cc9fe8fa075f37($fileIdentifier, $file);
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
function composerRequire676d4bb90dad167891cc9fe8fa075f37($fileIdentifier, $file)
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
@@ -240,9 +240,9 @@ class ComposerStaticInit652ffd0f2996d93258e9b59ad0a5a779
|
|
240 |
public static function getInitializer(ClassLoader $loader)
|
241 |
{
|
242 |
return \Closure::bind(function () use ($loader) {
|
243 |
-
$loader->prefixLengthsPsr4 =
|
244 |
-
$loader->prefixDirsPsr4 =
|
245 |
-
$loader->classMap =
|
246 |
|
247 |
}, null, ClassLoader::class);
|
248 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
|
240 |
public static function getInitializer(ClassLoader $loader)
|
241 |
{
|
242 |
return \Closure::bind(function () use ($loader) {
|
243 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37::$prefixLengthsPsr4;
|
244 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37::$prefixDirsPsr4;
|
245 |
+
$loader->classMap = ComposerStaticInit676d4bb90dad167891cc9fe8fa075f37::$classMap;
|
246 |
|
247 |
}, null, ClassLoader::class);
|
248 |
}
|
vendor/composer/installed.json
CHANGED
@@ -610,23 +610,23 @@
|
|
610 |
},
|
611 |
{
|
612 |
"name": "psr/log",
|
613 |
-
"version": "1.1.
|
614 |
-
"version_normalized": "1.1.
|
615 |
"source": {
|
616 |
"type": "git",
|
617 |
"url": "https://github.com/php-fig/log.git",
|
618 |
-
"reference": "
|
619 |
},
|
620 |
"dist": {
|
621 |
"type": "zip",
|
622 |
-
"url": "https://api.github.com/repos/php-fig/log/zipball/
|
623 |
-
"reference": "
|
624 |
"shasum": ""
|
625 |
},
|
626 |
"require": {
|
627 |
"php": ">=5.3.0"
|
628 |
},
|
629 |
-
"time": "
|
630 |
"type": "library",
|
631 |
"extra": {
|
632 |
"branch-alias": {
|
@@ -646,7 +646,7 @@
|
|
646 |
"authors": [
|
647 |
{
|
648 |
"name": "PHP-FIG",
|
649 |
-
"homepage": "
|
650 |
}
|
651 |
],
|
652 |
"description": "Common interface for logging libraries",
|
@@ -657,7 +657,7 @@
|
|
657 |
"psr-3"
|
658 |
],
|
659 |
"support": {
|
660 |
-
"source": "https://github.com/php-fig/log/tree/1.1.
|
661 |
},
|
662 |
"install-path": "../psr/log"
|
663 |
},
|
610 |
},
|
611 |
{
|
612 |
"name": "psr/log",
|
613 |
+
"version": "1.1.4",
|
614 |
+
"version_normalized": "1.1.4.0",
|
615 |
"source": {
|
616 |
"type": "git",
|
617 |
"url": "https://github.com/php-fig/log.git",
|
618 |
+
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
|
619 |
},
|
620 |
"dist": {
|
621 |
"type": "zip",
|
622 |
+
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
|
623 |
+
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
|
624 |
"shasum": ""
|
625 |
},
|
626 |
"require": {
|
627 |
"php": ">=5.3.0"
|
628 |
},
|
629 |
+
"time": "2021-05-03T11:20:27+00:00",
|
630 |
"type": "library",
|
631 |
"extra": {
|
632 |
"branch-alias": {
|
646 |
"authors": [
|
647 |
{
|
648 |
"name": "PHP-FIG",
|
649 |
+
"homepage": "https://www.php-fig.org/"
|
650 |
}
|
651 |
],
|
652 |
"description": "Common interface for logging libraries",
|
657 |
"psr-3"
|
658 |
],
|
659 |
"support": {
|
660 |
+
"source": "https://github.com/php-fig/log/tree/1.1.4"
|
661 |
},
|
662 |
"install-path": "../psr/log"
|
663 |
},
|
vendor/composer/installed.php
CHANGED
@@ -1,141 +1,140 @@
|
|
1 |
-
<?php return array
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
8 |
),
|
9 |
-
'
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
),
|
23 |
-
'dhii/collections-interface' =>
|
24 |
-
array (
|
25 |
-
'pretty_version' => 'v0.3.0-alpha4',
|
26 |
-
'version' => '0.3.0.0-alpha4',
|
27 |
-
'aliases' =>
|
28 |
-
array (
|
29 |
-
),
|
30 |
-
'reference' => 'da334f75f6477ef7eecaf28df1d5253fe05684ee',
|
31 |
-
),
|
32 |
-
'dhii/containers' =>
|
33 |
-
array (
|
34 |
-
'pretty_version' => 'v0.1.0-alpha1',
|
35 |
-
'version' => '0.1.0.0-alpha1',
|
36 |
-
'aliases' =>
|
37 |
-
array (
|
38 |
-
),
|
39 |
-
'reference' => '73eed5422e106006c81ca1fa8b7213c6be33efbc',
|
40 |
-
),
|
41 |
-
'dhii/data-container-interface' =>
|
42 |
-
array (
|
43 |
-
'pretty_version' => 'v0.2.1-alpha1',
|
44 |
-
'version' => '0.2.1.0-alpha1',
|
45 |
-
'aliases' =>
|
46 |
-
array (
|
47 |
-
),
|
48 |
-
'reference' => '6be46e427184b95785d9dd563d6acf2e0700cc31',
|
49 |
-
),
|
50 |
-
'dhii/data-key-value-aware-interface' =>
|
51 |
-
array (
|
52 |
-
'pretty_version' => 'v0.1',
|
53 |
-
'version' => '0.1.0.0',
|
54 |
-
'aliases' =>
|
55 |
-
array (
|
56 |
-
),
|
57 |
-
'reference' => '220232bc9040fab78a6c039f5a4a5f9542317bdc',
|
58 |
-
),
|
59 |
-
'dhii/exception-interface' =>
|
60 |
-
array (
|
61 |
-
'pretty_version' => 'v0.2',
|
62 |
-
'version' => '0.2.0.0',
|
63 |
-
'aliases' =>
|
64 |
-
array (
|
65 |
-
),
|
66 |
-
'reference' => 'b69feebf7cb2879cd43977a03342e2393b73f7fb',
|
67 |
-
),
|
68 |
-
'dhii/factory-interface' =>
|
69 |
-
array (
|
70 |
-
'pretty_version' => 'v0.1',
|
71 |
-
'version' => '0.1.0.0',
|
72 |
-
'aliases' =>
|
73 |
-
array (
|
74 |
-
),
|
75 |
-
'reference' => 'b8d217aec8838e64ccaa770cb03dc164bf6f0515',
|
76 |
-
),
|
77 |
-
'dhii/module-interface' =>
|
78 |
-
array (
|
79 |
-
'pretty_version' => 'v0.1',
|
80 |
-
'version' => '0.1.0.0',
|
81 |
-
'aliases' =>
|
82 |
-
array (
|
83 |
-
),
|
84 |
-
'reference' => 'a4271f2040e54f81cb7c4d5b3f18cb4a7532c277',
|
85 |
-
),
|
86 |
-
'dhii/stringable-interface' =>
|
87 |
-
array (
|
88 |
-
'pretty_version' => 'v0.1',
|
89 |
-
'version' => '0.1.0.0',
|
90 |
-
'aliases' =>
|
91 |
-
array (
|
92 |
-
),
|
93 |
-
'reference' => 'b6653905eef2ebf377749feb80a6d18abbe913ef',
|
94 |
-
),
|
95 |
-
'dhii/wp-containers' =>
|
96 |
-
array (
|
97 |
-
'pretty_version' => 'v0.1.0-alpha1',
|
98 |
-
'version' => '0.1.0.0-alpha1',
|
99 |
-
'aliases' =>
|
100 |
-
array (
|
101 |
-
),
|
102 |
-
'reference' => 'e91a6f741622770ed724a2b594145fa917811f0c',
|
103 |
-
),
|
104 |
-
'psr/container' =>
|
105 |
-
array (
|
106 |
-
'pretty_version' => '1.0.0',
|
107 |
-
'version' => '1.0.0.0',
|
108 |
-
'aliases' =>
|
109 |
-
array (
|
110 |
-
),
|
111 |
-
'reference' => 'b7ce3b176482dbbc1245ebf52b181af44c2cf55f',
|
112 |
-
),
|
113 |
-
'psr/log' =>
|
114 |
-
array (
|
115 |
-
'pretty_version' => '1.1.3',
|
116 |
-
'version' => '1.1.3.0',
|
117 |
-
'aliases' =>
|
118 |
-
array (
|
119 |
-
),
|
120 |
-
'reference' => '0f73288fd15629204f9d42b7055f72dacbe811fc',
|
121 |
-
),
|
122 |
-
'ralouphie/getallheaders' =>
|
123 |
-
array (
|
124 |
-
'pretty_version' => '3.0.3',
|
125 |
-
'version' => '3.0.3.0',
|
126 |
-
'aliases' =>
|
127 |
-
array (
|
128 |
-
),
|
129 |
-
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
130 |
-
),
|
131 |
-
'woocommerce/woocommerce-paypal-payments' =>
|
132 |
-
array (
|
133 |
-
'pretty_version' => 'dev-trunk',
|
134 |
-
'version' => 'dev-trunk',
|
135 |
-
'aliases' =>
|
136 |
-
array (
|
137 |
-
),
|
138 |
-
'reference' => 'e13dfad27c862c64d6d85ce86d03b51c7e72465f',
|
139 |
-
),
|
140 |
-
),
|
141 |
);
|
1 |
+
<?php return array(
|
2 |
+
'root' => array(
|
3 |
+
'pretty_version' => 'dev-trunk',
|
4 |
+
'version' => 'dev-trunk',
|
5 |
+
'type' => 'wordpress-plugin',
|
6 |
+
'install_path' => __DIR__ . '/../../',
|
7 |
+
'aliases' => array(),
|
8 |
+
'reference' => 'f1555d4db44ff78e5d2c6c3b46849bce93fe15e6',
|
9 |
+
'name' => 'woocommerce/woocommerce-paypal-payments',
|
10 |
+
'dev' => false,
|
11 |
),
|
12 |
+
'versions' => array(
|
13 |
+
'container-interop/service-provider' => array(
|
14 |
+
'pretty_version' => 'v0.4.0',
|
15 |
+
'version' => '0.4.0.0',
|
16 |
+
'type' => 'library',
|
17 |
+
'install_path' => __DIR__ . '/../container-interop/service-provider',
|
18 |
+
'aliases' => array(),
|
19 |
+
'reference' => '4969b9e49460690b7430b3f1a87cab07be61418a',
|
20 |
+
'dev_requirement' => false,
|
21 |
+
),
|
22 |
+
'dhii/collections-interface' => array(
|
23 |
+
'pretty_version' => 'v0.3.0-alpha4',
|
24 |
+
'version' => '0.3.0.0-alpha4',
|
25 |
+
'type' => 'library',
|
26 |
+
'install_path' => __DIR__ . '/../dhii/collections-interface',
|
27 |
+
'aliases' => array(),
|
28 |
+
'reference' => 'da334f75f6477ef7eecaf28df1d5253fe05684ee',
|
29 |
+
'dev_requirement' => false,
|
30 |
+
),
|
31 |
+
'dhii/containers' => array(
|
32 |
+
'pretty_version' => 'v0.1.0-alpha1',
|
33 |
+
'version' => '0.1.0.0-alpha1',
|
34 |
+
'type' => 'library',
|
35 |
+
'install_path' => __DIR__ . '/../dhii/containers',
|
36 |
+
'aliases' => array(),
|
37 |
+
'reference' => '73eed5422e106006c81ca1fa8b7213c6be33efbc',
|
38 |
+
'dev_requirement' => false,
|
39 |
+
),
|
40 |
+
'dhii/data-container-interface' => array(
|
41 |
+
'pretty_version' => 'v0.2.1-alpha1',
|
42 |
+
'version' => '0.2.1.0-alpha1',
|
43 |
+
'type' => 'library',
|
44 |
+
'install_path' => __DIR__ . '/../dhii/data-container-interface',
|
45 |
+
'aliases' => array(),
|
46 |
+
'reference' => '6be46e427184b95785d9dd563d6acf2e0700cc31',
|
47 |
+
'dev_requirement' => false,
|
48 |
+
),
|
49 |
+
'dhii/data-key-value-aware-interface' => array(
|
50 |
+
'pretty_version' => 'v0.1',
|
51 |
+
'version' => '0.1.0.0',
|
52 |
+
'type' => 'library',
|
53 |
+
'install_path' => __DIR__ . '/../dhii/data-key-value-aware-interface',
|
54 |
+
'aliases' => array(),
|
55 |
+
'reference' => '220232bc9040fab78a6c039f5a4a5f9542317bdc',
|
56 |
+
'dev_requirement' => false,
|
57 |
+
),
|
58 |
+
'dhii/exception-interface' => array(
|
59 |
+
'pretty_version' => 'v0.2',
|
60 |
+
'version' => '0.2.0.0',
|
61 |
+
'type' => 'library',
|
62 |
+
'install_path' => __DIR__ . '/../dhii/exception-interface',
|
63 |
+
'aliases' => array(),
|
64 |
+
'reference' => 'b69feebf7cb2879cd43977a03342e2393b73f7fb',
|
65 |
+
'dev_requirement' => false,
|
66 |
+
),
|
67 |
+
'dhii/factory-interface' => array(
|
68 |
+
'pretty_version' => 'v0.1',
|
69 |
+
'version' => '0.1.0.0',
|
70 |
+
'type' => 'library',
|
71 |
+
'install_path' => __DIR__ . '/../dhii/factory-interface',
|
72 |
+
'aliases' => array(),
|
73 |
+
'reference' => 'b8d217aec8838e64ccaa770cb03dc164bf6f0515',
|
74 |
+
'dev_requirement' => false,
|
75 |
+
),
|
76 |
+
'dhii/module-interface' => array(
|
77 |
+
'pretty_version' => 'v0.1',
|
78 |
+
'version' => '0.1.0.0',
|
79 |
+
'type' => 'library',
|
80 |
+
'install_path' => __DIR__ . '/../dhii/module-interface',
|
81 |
+
'aliases' => array(),
|
82 |
+
'reference' => 'a4271f2040e54f81cb7c4d5b3f18cb4a7532c277',
|
83 |
+
'dev_requirement' => false,
|
84 |
+
),
|
85 |
+
'dhii/stringable-interface' => array(
|
86 |
+
'pretty_version' => 'v0.1',
|
87 |
+
'version' => '0.1.0.0',
|
88 |
+
'type' => 'library',
|
89 |
+
'install_path' => __DIR__ . '/../dhii/stringable-interface',
|
90 |
+
'aliases' => array(),
|
91 |
+
'reference' => 'b6653905eef2ebf377749feb80a6d18abbe913ef',
|
92 |
+
'dev_requirement' => false,
|
93 |
+
),
|
94 |
+
'dhii/wp-containers' => array(
|
95 |
+
'pretty_version' => 'v0.1.0-alpha1',
|
96 |
+
'version' => '0.1.0.0-alpha1',
|
97 |
+
'type' => 'library',
|
98 |
+
'install_path' => __DIR__ . '/../dhii/wp-containers',
|
99 |
+
'aliases' => array(),
|
100 |
+
'reference' => 'e91a6f741622770ed724a2b594145fa917811f0c',
|
101 |
+
'dev_requirement' => false,
|
102 |
+
),
|
103 |
+
'psr/container' => array(
|
104 |
+
'pretty_version' => '1.0.0',
|
105 |
+
'version' => '1.0.0.0',
|
106 |
+
'type' => 'library',
|
107 |
+
'install_path' => __DIR__ . '/../psr/container',
|
108 |
+
'aliases' => array(),
|
109 |
+
'reference' => 'b7ce3b176482dbbc1245ebf52b181af44c2cf55f',
|
110 |
+
'dev_requirement' => false,
|
111 |
+
),
|
112 |
+
'psr/log' => array(
|
113 |
+
'pretty_version' => '1.1.4',
|
114 |
+
'version' => '1.1.4.0',
|
115 |
+
'type' => 'library',
|
116 |
+
'install_path' => __DIR__ . '/../psr/log',
|
117 |
+
'aliases' => array(),
|
118 |
+
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
|
119 |
+
'dev_requirement' => false,
|
120 |
+
),
|
121 |
+
'ralouphie/getallheaders' => array(
|
122 |
+
'pretty_version' => '3.0.3',
|
123 |
+
'version' => '3.0.3.0',
|
124 |
+
'type' => 'library',
|
125 |
+
'install_path' => __DIR__ . '/../ralouphie/getallheaders',
|
126 |
+
'aliases' => array(),
|
127 |
+
'reference' => '120b605dfeb996808c31b6477290a714d356e822',
|
128 |
+
'dev_requirement' => false,
|
129 |
+
),
|
130 |
+
'woocommerce/woocommerce-paypal-payments' => array(
|
131 |
+
'pretty_version' => 'dev-trunk',
|
132 |
+
'version' => 'dev-trunk',
|
133 |
+
'type' => 'wordpress-plugin',
|
134 |
+
'install_path' => __DIR__ . '/../../',
|
135 |
+
'aliases' => array(),
|
136 |
+
'reference' => 'f1555d4db44ff78e5d2c6c3b46849bce93fe15e6',
|
137 |
+
'dev_requirement' => false,
|
138 |
+
),
|
139 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
);
|
vendor/psr/log/Psr/Log/AbstractLogger.php
CHANGED
@@ -14,8 +14,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
14 |
/**
|
15 |
* System is unusable.
|
16 |
*
|
17 |
-
* @param string
|
18 |
-
* @param
|
19 |
*
|
20 |
* @return void
|
21 |
*/
|
@@ -30,8 +30,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
30 |
* Example: Entire website down, database unavailable, etc. This should
|
31 |
* trigger the SMS alerts and wake you up.
|
32 |
*
|
33 |
-
* @param string
|
34 |
-
* @param
|
35 |
*
|
36 |
* @return void
|
37 |
*/
|
@@ -45,8 +45,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
45 |
*
|
46 |
* Example: Application component unavailable, unexpected exception.
|
47 |
*
|
48 |
-
* @param string
|
49 |
-
* @param
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
@@ -59,8 +59,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
59 |
* Runtime errors that do not require immediate action but should typically
|
60 |
* be logged and monitored.
|
61 |
*
|
62 |
-
* @param string
|
63 |
-
* @param
|
64 |
*
|
65 |
* @return void
|
66 |
*/
|
@@ -75,8 +75,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
75 |
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
76 |
* that are not necessarily wrong.
|
77 |
*
|
78 |
-
* @param string
|
79 |
-
* @param
|
80 |
*
|
81 |
* @return void
|
82 |
*/
|
@@ -88,8 +88,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
88 |
/**
|
89 |
* Normal but significant events.
|
90 |
*
|
91 |
-
* @param string
|
92 |
-
* @param
|
93 |
*
|
94 |
* @return void
|
95 |
*/
|
@@ -103,8 +103,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
103 |
*
|
104 |
* Example: User logs in, SQL logs.
|
105 |
*
|
106 |
-
* @param string
|
107 |
-
* @param
|
108 |
*
|
109 |
* @return void
|
110 |
*/
|
@@ -116,8 +116,8 @@ abstract class AbstractLogger implements LoggerInterface
|
|
116 |
/**
|
117 |
* Detailed debug information.
|
118 |
*
|
119 |
-
* @param string
|
120 |
-
* @param
|
121 |
*
|
122 |
* @return void
|
123 |
*/
|
14 |
/**
|
15 |
* System is unusable.
|
16 |
*
|
17 |
+
* @param string $message
|
18 |
+
* @param mixed[] $context
|
19 |
*
|
20 |
* @return void
|
21 |
*/
|
30 |
* Example: Entire website down, database unavailable, etc. This should
|
31 |
* trigger the SMS alerts and wake you up.
|
32 |
*
|
33 |
+
* @param string $message
|
34 |
+
* @param mixed[] $context
|
35 |
*
|
36 |
* @return void
|
37 |
*/
|
45 |
*
|
46 |
* Example: Application component unavailable, unexpected exception.
|
47 |
*
|
48 |
+
* @param string $message
|
49 |
+
* @param mixed[] $context
|
50 |
*
|
51 |
* @return void
|
52 |
*/
|
59 |
* Runtime errors that do not require immediate action but should typically
|
60 |
* be logged and monitored.
|
61 |
*
|
62 |
+
* @param string $message
|
63 |
+
* @param mixed[] $context
|
64 |
*
|
65 |
* @return void
|
66 |
*/
|
75 |
* Example: Use of deprecated APIs, poor use of an API, undesirable things
|
76 |
* that are not necessarily wrong.
|
77 |
*
|
78 |
+
* @param string $message
|
79 |
+
* @param mixed[] $context
|
80 |
*
|
81 |
* @return void
|
82 |
*/
|
88 |
/**
|
89 |
* Normal but significant events.
|
90 |
*
|
91 |
+
* @param string $message
|
92 |
+
* @param mixed[] $context
|
93 |
*
|
94 |
* @return void
|
95 |
*/
|
103 |
*
|
104 |
* Example: User logs in, SQL logs.
|
105 |
*
|
106 |
+
* @param string $message
|
107 |
+
* @param mixed[] $context
|
108 |
*
|
109 |
* @return void
|
110 |
*/
|
116 |
/**
|
117 |
* Detailed debug information.
|
118 |
*
|
119 |
+
* @param string $message
|
120 |
+
* @param mixed[] $context
|
121 |
*
|
122 |
* @return void
|
123 |
*/
|
vendor/psr/log/Psr/Log/LoggerAwareTrait.php
CHANGED
@@ -10,7 +10,7 @@ trait LoggerAwareTrait
|
|
10 |
/**
|
11 |
* The logger instance.
|
12 |
*
|
13 |
-
* @var LoggerInterface
|
14 |
*/
|
15 |
protected $logger;
|
16 |
|
10 |
/**
|
11 |
* The logger instance.
|
12 |
*
|
13 |
+
* @var LoggerInterface|null
|
14 |
*/
|
15 |
protected $logger;
|
16 |
|
vendor/psr/log/composer.json
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
"authors": [
|
8 |
{
|
9 |
"name": "PHP-FIG",
|
10 |
-
"homepage": "
|
11 |
}
|
12 |
],
|
13 |
"require": {
|
7 |
"authors": [
|
8 |
{
|
9 |
"name": "PHP-FIG",
|
10 |
+
"homepage": "https://www.php-fig.org/"
|
11 |
}
|
12 |
],
|
13 |
"require": {
|
woocommerce-paypal-payments.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: WooCommerce PayPal Payments
|
4 |
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
|
5 |
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
|
6 |
-
* Version: 1.3.
|
7 |
* Author: WooCommerce
|
8 |
* Author URI: https://woocommerce.com/
|
9 |
* License: GPL-2.0
|
3 |
* Plugin Name: WooCommerce PayPal Payments
|
4 |
* Plugin URI: https://woocommerce.com/products/woocommerce-paypal-payments/
|
5 |
* Description: PayPal's latest complete payments processing solution. Accept PayPal, Pay Later, credit/debit cards, alternative digital wallets local payment types and bank accounts. Turn on only PayPal options or process a full suite of payment methods. Enable global transaction with extensive currency and country coverage.
|
6 |
+
* Version: 1.3.2
|
7 |
* Author: WooCommerce
|
8 |
* Author URI: https://woocommerce.com/
|
9 |
* License: GPL-2.0
|