diff --git a/assets/javascripts/front/checkout/model/payment/card.js b/assets/javascripts/front/checkout/model/payment/card.js index f844e801..c7fa6f6e 100644 --- a/assets/javascripts/front/checkout/model/payment/card.js +++ b/assets/javascripts/front/checkout/model/payment/card.js @@ -98,7 +98,7 @@ let pagarmeCard = { }, checkTokenCard: function (event) { let allResult = []; - event.each(async function () { + event.each(function () { if (pagarmeCard.hasSelectedWallet(this)) { allResult.push(true); return; @@ -115,12 +115,7 @@ let pagarmeCard = { }, checkToken: function (event) { event = this.formatEventToJQuery(event); - return !!event.find(this.tokenElement).length && this.checkTokenExpirationDate(event.find(this.tokenElement)); - }, - checkTokenExpirationDate: function (event) { - const expirationDateTimeAttribute = event.attr(this.tokenExpirationAttribute); - const expirationDate = new Date(expirationDateTimeAttribute); - return expirationDate > new Date(); + return !!event.find(this.tokenElement).length; }, getCardDataContingency: async function (cardNumber) { let oldPrefix = '', @@ -412,9 +407,10 @@ let pagarmeCard = { return output; }, execute: async function (event) { + this.showLoader(event); try { for (let i = 1; !pagarmeCard.isTokenized() && i <= this.limitTokenize; i++) { - if (i === this.limit) { + if (i === this.limitTokenize) { this.removeLoader(event); throw new Error("Tokenize timeout"); } @@ -426,7 +422,9 @@ let pagarmeCard = { } let formCheckout = this.formatEventToJQuery(event); formCheckout.submit(); + formCheckout.find(pagarmeCard.tokenElement).remove(); } catch (er) { + this.removeLoader(event); if (typeof er === 'string') { this.showError(er); } else { @@ -436,6 +434,7 @@ let pagarmeCard = { }, canExecute: function (event) { const checkoutPaymentElement = pagarmeCard.getCheckoutPaymentElement(); + const cardBrand = checkoutPaymentElement.parents('.pagarme-card-number-row') .find(this.brandTarget); if (cardBrand?.val()?.length === 0 || wc_pagarme_checkout.errorTokenize === true) { diff --git a/assets/javascripts/front/checkout/model/payment/googlepay.js b/assets/javascripts/front/checkout/model/payment/googlepay.js new file mode 100644 index 00000000..bb193f74 --- /dev/null +++ b/assets/javascripts/front/checkout/model/payment/googlepay.js @@ -0,0 +1,187 @@ +/* globals wc_pagarme_checkout */ +/* jshint esversion: 11 */ +let pagarmeGooglePay = { + woocommercePaymentMethods: 'input[name="payment_method"]', + googlePayAllowedBrands: ["AMEX", "ELO", "MASTERCARD", "VISA"], + pagarmeAllowedBrands: wc_pagarme_googlepay.allowedCcFlags, + woocommercePaymentId: "#payment_method_woo-pagarme-payments-credit_card", + + getGooglePaymentsClient: function () { + let environment = "TEST"; + if (parseInt(wc_pagarme_googlepay.isSandboxMode, 10) !== 1) { + environment = "PRODUCTION"; + } + + return new google.payments.api.PaymentsClient({ + environment: environment, + }); + }, + + addGooglePayButton: function () { + if (jQuery('#pagarme-googlepay button').length > 0) { + return; + } + + let paymentsClient = this.getGooglePaymentsClient(); + const button = paymentsClient.createButton({ + buttonColor: "default", + buttonType: "pay", + buttonRadius: 5, + buttonLocale: "pt", + buttonSizeMode: "fill", + onClick: this.onGooglePaymentButtonClicked + }); + jQuery('#pagarme-googlepay').append(button); + }, + + onPaymentAuthorized: function (paymentData) { + return new Promise(function (resolve, reject) { + processPayment(paymentData) + .then(function () { + resolve({ transactionState: "SUCCESS" }); + }) + .catch(function () { + resolve({ + transactionState: "ERROR", + error: { + intent: "PAYMENT_AUTHORIZATION", + message: "Insufficient funds", + reason: "PAYMENT_DATA_INVALID", + }, + }); + }); + }); + }, + + getGooglePaymentDataRequest: function () { + const baseRequest = { + apiVersion: 2, + apiVersionMinor: 0, + }; + + const tokenizationSpecification = { + type: "PAYMENT_GATEWAY", + parameters: { + gateway: "pagarme", + gatewayMerchantId: wc_pagarme_googlepay.accountId, + }, + }; + + const baseCardPaymentMethod = { + type: "CARD", + parameters: { + allowedAuthMethods: ["PAN_ONLY"], + allowedCardNetworks: this.getAllowedCardNetworks(), + }, + }; + + const cardPaymentMethod = Object.assign({}, baseCardPaymentMethod, { + tokenizationSpecification: tokenizationSpecification, + }); + + const paymentDataRequest = Object.assign({}, baseRequest); + paymentDataRequest.allowedPaymentMethods = [cardPaymentMethod]; + paymentDataRequest.transactionInfo = + this.getGoogleTransactionInfo(); + paymentDataRequest.merchantInfo = { + merchantId: wc_pagarme_googlepay.merchantId, + merchantName: wc_pagarme_googlepay.merchantName, + }; + + return paymentDataRequest; + }, + + getAllowedCardNetworks: function() { + const self = this; + let allowedCardNetworks = []; + + jQuery.each(this.googlePayAllowedBrands, function(key, value) { + const index = jQuery.inArray(value.toLowerCase(), self.pagarmeAllowedBrands); + if(index !== -1) { + allowedCardNetworks.push(value.toUpperCase()); + } + }); + + return allowedCardNetworks; + }, + + onGooglePaymentButtonClicked: function () { + const self = this; + const paymentDataRequest = pagarmeGooglePay.getGooglePaymentDataRequest(); + paymentDataRequest.transactionInfo = pagarmeGooglePay.getGoogleTransactionInfo(); + + const paymentsClient = pagarmeGooglePay.getGooglePaymentsClient(); + paymentsClient + .loadPaymentData(paymentDataRequest) + .then(function (paymentData) { + pagarmeGooglePay.processPayment(paymentData, self); + }) + .catch(function (err) { + jQuery(pagarmeGooglePay.woocommercePaymentId ).val("woo-pagarme-payments-credit_card"); + if (err.statusCode === "CANCELED") { + return; + } + console.error(err); + }); + }, + + getGoogleTransactionInfo: function () { + return { + countryCode: "BR", + currencyCode: "BRL", + totalPriceStatus: "FINAL", + totalPrice: cartTotal.toString(), + }; + }, + + prefetchGooglePaymentData: function () { + const paymentDataRequest = this.getGooglePaymentDataRequest(); + paymentDataRequest.transactionInfo = { + totalPriceStatus: "NOT_CURRENTLY_KNOWN", + currencyCode: "BRL", + }; + const paymentsClient = this.getGooglePaymentsClient(); + paymentsClient.prefetchPaymentData(paymentDataRequest); + }, + + + processPayment: function(paymentData) { + let checkoutPaymentElement = pagarmeGooglePay.getCheckoutPaymentElement(); + let inputName = 'pagarme[googlepay][googlepay][payload]'; + let input = jQuery(document.createElement('input')); + if (!(checkoutPaymentElement instanceof jQuery)) { + checkoutPaymentElement = jQuery(checkoutPaymentElement); + } + input.attr('type', 'hidden') + .attr('name', inputName) + .attr('id', "googlepaytoken") + .attr('value', paymentData.paymentMethodData.tokenizationData.token); + checkoutPaymentElement.append(input); + jQuery(pagarmeGooglePay.woocommercePaymentId ).val("woo-pagarme-payments-googlepay"); + checkoutPaymentElement.submit(); + jQuery('form#order_review').submit(); + jQuery(pagarmeGooglePay.woocommercePaymentId ).val("woo-pagarme-payments-credit_card"); + }, + + getCheckoutPaymentElement: function () { + const value = jQuery('form .payment_methods input[name="payment_method"]:checked').val(); + return jQuery('.wc_payment_method.payment_method_' + value); + }, + + addEventListener: function () { + jQuery(document.body).on('updated_checkout payment_method_selected', function () { + pagarmeGooglePay.addGooglePayButton(); + }); + + jQuery(`${this.fieldsetCardElements} input`).on('change', function () { + pagarmeGooglePay.clearErrorMessages(); + }); + + }, + + start: function () { + this.addEventListener(); + } +}; + +pagarmeGooglePay.start(); diff --git a/assets/javascripts/front/reactCheckout/payments/CreditCard/index.js b/assets/javascripts/front/reactCheckout/payments/CreditCard/index.js index 2010b09f..1d46321f 100644 --- a/assets/javascripts/front/reactCheckout/payments/CreditCard/index.js +++ b/assets/javascripts/front/reactCheckout/payments/CreditCard/index.js @@ -10,7 +10,6 @@ const backendConfig = wc.wcSettings.getSetting( const PagarmeCreditCardComponent = (props) => { const { emitResponse, eventRegistration } = props; - useCreditCard(backendConfig, emitResponse, eventRegistration); return ( diff --git a/assets/javascripts/front/reactCheckout/payments/GooglePay/index.js b/assets/javascripts/front/reactCheckout/payments/GooglePay/index.js new file mode 100644 index 00000000..c4c7f577 --- /dev/null +++ b/assets/javascripts/front/reactCheckout/payments/GooglePay/index.js @@ -0,0 +1,95 @@ +import PropTypes from "prop-types"; +import GooglePayButton from "@google-pay/button-react"; +import useGooglepay from "./useGooglepay"; +import { useDispatch, useSelect } from "@wordpress/data"; +import pagarmeTokenStore from "../store/googlepay" + +const { registerPaymentMethod } = window.wc.wcBlocksRegistry; + +const backendConfig = wc.wcSettings.getSetting( + "woo-pagarme-payments-googlepay_data", +); + +const environment = backendConfig.isSandboxMode ? "TEST" : "PRODUCTION"; + +const PagarmeGooglePayComponent = (props) => { + const { emitResponse, eventRegistration } = props; + + useGooglepay(emitResponse, eventRegistration, backendConfig); + + const { + setToken + } = useDispatch(pagarmeTokenStore); + + return ( + + { + let googleToken = paymentRequest.paymentMethodData.tokenizationData.token; + setToken(googleToken); + jQuery(".wc-block-components-checkout-place-order-button").click(); + }} + /> + ); + +}; + +const PagarmeGooglePayLabel = ({ components }) => { + const { PaymentMethodLabel } = components; + return ; +}; + +PagarmeGooglePayComponent.propTypes = { + emitResponse: PropTypes.object, + eventRegistration: PropTypes.object, +}; + +PagarmeGooglePayLabel.propTypes = { + components: PropTypes.object, +}; + + +const pagarmeGooglePayPaymentMethod = { + name: backendConfig.name, + label: , + content: , + edit: , + canMakePayment: () => true, + ariaLabel: backendConfig.ariaLabel, +}; + +registerPaymentMethod(pagarmeGooglePayPaymentMethod); diff --git a/assets/javascripts/front/reactCheckout/payments/GooglePay/useGooglepay.js b/assets/javascripts/front/reactCheckout/payments/GooglePay/useGooglepay.js new file mode 100644 index 00000000..95b9a615 --- /dev/null +++ b/assets/javascripts/front/reactCheckout/payments/GooglePay/useGooglepay.js @@ -0,0 +1,39 @@ +/* jshint esversion: 9 */ +import pagarmeTokenStore from "../store/googlepay"; +import { useEffect } from "@wordpress/element"; +import { useDispatch, useSelect } from "@wordpress/data"; + +const useGooglepay = ( + emitResponse, + eventRegistration, + backendConfig +) => { + const { reset } = useDispatch(pagarmeTokenStore); + + const { onPaymentSetup } = eventRegistration; + + const cards = useSelect((select) => { + return select(pagarmeTokenStore).getToken(); + }); + + useEffect(() => { + return onPaymentSetup(() => { + const paymentMethodData = { + payment_method: backendConfig.key, + }; + + return { + type: emitResponse.responseTypes.SUCCESS, + meta: { + paymentMethodData: { + pagarme: JSON.stringify({ + [backendConfig.key]: {[backendConfig.key]: {['payload']: cards}} + }), + payment_method: backendConfig.key, + }, + }, + }; + }); + }, [onPaymentSetup, cards, backendConfig]); +}; +export default useGooglepay; diff --git a/assets/javascripts/front/reactCheckout/payments/store/googlepay.js b/assets/javascripts/front/reactCheckout/payments/store/googlepay.js new file mode 100644 index 00000000..15b9996c --- /dev/null +++ b/assets/javascripts/front/reactCheckout/payments/store/googlepay.js @@ -0,0 +1,70 @@ +// pagarmeTokenStore.js + +import { createReduxStore, register } from "@wordpress/data"; + +const DEFAULT_CARD = { + token: "", + errors: {} +}; + +const DEFAULT_STATE = { + ...DEFAULT_CARD +}; + +const actions = { + setToken(token) { + return { + type: "SET_PROPERTY_VALUE", + value: token, + propertyName: "token", + }; + }, + + setErrors(errors){ + return { + type: "SET_PROPERTY_VALUE", + value: errors, + propertyName: "errors", + }; + }, + reset() { + return { + type: "RESET", + }; + } +}; + +const pagarmeTokenStore = createReduxStore("pagarme-googlepay", { + reducer(state = DEFAULT_STATE, action) { + switch (action.type) { + case "SET_PROPERTY_VALUE": + // console.log(action); + if (!action.propertyName) { + return state; + } + return { + ...state, + [action.propertyName]: action.value, + }; + case "RESET": + return DEFAULT_STATE; + default: + return state; + } + }, + + actions, + + selectors: { + getToken(state) { + return state.token; + }, + getErrors(state) { + return state.errors; + }, + }, +}); + +register(pagarmeTokenStore); + +export default pagarmeTokenStore; \ No newline at end of file diff --git a/assets/stylesheets/front/style.css b/assets/stylesheets/front/style.css index 2c41d187..f6bbd4c3 100644 --- a/assets/stylesheets/front/style.css +++ b/assets/stylesheets/front/style.css @@ -94,6 +94,29 @@ font-style: italic; } +#payment .pagarme_creditcard_divider { + margin: 1em 0 0; +} + +#payment .pagarme_creditcard_divider p { + display: flex; + flex-direction: row; +} + +#payment .pagarme_creditcard_divider p:after , +#payment .pagarme_creditcard_divider p:before { + content: ""; + flex: 1 1; + border-bottom: 1px solid; + margin: auto; +} +#payment .pagarme_creditcard_divider p:after { + margin-left: 0.5em; +} +#payment .pagarme_creditcard_divider p:before { + margin-right: 0.5em; +} + .woocommerce-order .woocommerce-message .pagarme-response p:last-child { margin-bottom: 0; } diff --git a/build/billet.asset.php b/build/billet.asset.php index 95cb61dc..0accc965 100644 --- a/build/billet.asset.php +++ b/build/billet.asset.php @@ -1 +1 @@ - array('react', 'wp-element'), 'version' => '5db2459c135ada8a97a0'); + array('wp-element'), 'version' => '1bed6d714eb3c90d3af1'); diff --git a/build/billet.js b/build/billet.js index e111b209..cb326cb3 100644 --- a/build/billet.js +++ b/build/billet.js @@ -1 +1 @@ -(()=>{var e={694:(e,t,n)=>{"use strict";var a=n(925);function r(){}function o(){}o.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,o,s){if(s!==a){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:r};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React;var t=n(556),a=n.n(t);const r=window.wp.element,o=({emitResponse:t,eventRegistration:n,backendConfig:a})=>(((e,t,n)=>{const{onPaymentSetup:a}=t;(0,r.useEffect)((()=>a((()=>{const t={payment_method:n.key};return{type:e.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}))),[a,n])})(t,n,a),(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"pagarme-payment-method-instructions"},a.instructions),(0,e.createElement)("p",{className:"pagarme-payment-method-logo"},(0,e.createElement)("img",{className:"logo",src:a.logo,alt:a.label,title:a.label}))));o.propTypes={emitResponse:a().object.isRequired,eventRegistration:a().object.isRequired,backendConfig:a().object.isRequired};const s=o,{registerPaymentMethod:c}=window.wc.wcBlocksRegistry,i=wc.wcSettings.getSetting("woo-pagarme-payments-billet_data"),p=t=>(0,e.createElement)(s,{...t,backendConfig:i}),l=({components:t})=>{const{PaymentMethodLabel:n}=t;return(0,e.createElement)(n,{text:i.label})};l.propTypes={components:a().object},c({name:i.name,label:(0,e.createElement)(l,null),content:(0,e.createElement)(p,null),edit:(0,e.createElement)(p,null),canMakePayment:()=>!0,ariaLabel:i.ariaLabel})})()})(); \ No newline at end of file +(()=>{var e={694:(e,t,n)=>{"use strict";var r=n(925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,s){if(s!==r){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t(((e,n,r)=>{const{onPaymentSetup:a}=n;(0,t.useEffect)((()=>a((()=>{const t={payment_method:r.key};return{type:e.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}))),[a,r])})(e,n,r),(0,t.createElement)(t.Fragment,null,(0,t.createElement)("p",{className:"pagarme-payment-method-instructions"},r.instructions),(0,t.createElement)("p",{className:"pagarme-payment-method-logo"},(0,t.createElement)("img",{className:"logo",src:r.logo,alt:r.label,title:r.label}))));o.propTypes={emitResponse:a().object.isRequired,eventRegistration:a().object.isRequired,backendConfig:a().object.isRequired};const s=o,{registerPaymentMethod:c}=window.wc.wcBlocksRegistry,i=wc.wcSettings.getSetting("woo-pagarme-payments-billet_data"),l=n=>(0,t.createElement)(s,e({},n,{backendConfig:i})),p=({components:e})=>{const{PaymentMethodLabel:n}=e;return(0,t.createElement)(n,{text:i.label})};p.propTypes={components:a().object},c({name:i.name,label:(0,t.createElement)(p,null),content:(0,t.createElement)(l,null),edit:(0,t.createElement)(l,null),canMakePayment:()=>!0,ariaLabel:i.ariaLabel})})()})(); \ No newline at end of file diff --git a/build/credit_card.asset.php b/build/credit_card.asset.php index b01e5c8c..1b7a08af 100644 --- a/build/credit_card.asset.php +++ b/build/credit_card.asset.php @@ -1 +1 @@ - array('react', 'react-dom', 'wp-data', 'wp-element'), 'version' => '52029d5e612bf4f12f79'); + array('react', 'react-dom', 'wp-data', 'wp-element'), 'version' => '568464aca724c57656dd'); diff --git a/build/credit_card.js b/build/credit_card.js index ffd9d8e2..7adc2ef7 100644 --- a/build/credit_card.js +++ b/build/credit_card.js @@ -1 +1 @@ -(()=>{var e={694:(e,t,n)=>{"use strict";var r=n(925);function a(){}function s(){}s.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,s,o){if(o!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:a};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},844:(e,t,n)=>{e.exports=n(200)},200:(e,t,n)=>{"use strict";var r,a=(r=n(609))&&"object"==typeof r&&"default"in r?r.default:r,s=n(795);function o(){return(o=Object.assign||function(e){for(var t=1;tr.length&&p(e,t.length-1);)t=t.slice(0,t.length-1);return t.length}for(var a=r.length,s=t.length;s>=r.length;s--){var o=t[s];if(!p(e,s)&&m(e,s,o)){a=s+1;break}}return a}function h(e,t){return f(e,t)===e.mask.length}function g(e,t){var n=e.maskChar,r=e.mask,a=e.prefix;if(!n){for((t=b(e,"",t,0)).lengtht.length&&(t+=a.slice(t.length,r)),l.every((function(n){for(;c=n,p(e,u=r)&&c!==a[u];){if(r>=t.length&&(t+=a[r]),l=n,s&&p(e,r)&&l===s)return!0;if(++r>=a.length)return!1}var l,u,c;return!m(e,r,n)&&n!==s||(ra.start?d=(c=function(e,t,n,r){var a=e.mask,s=e.maskChar,o=n.split(""),l=r;return o.every((function(t){for(;o=t,p(e,n=r)&&o!==a[n];)if(++r>=a.length)return!1;var n,o;return(m(e,r,t)||t===s)&&r++,r=s.length?v=s.length:v=o.length&&v{"use strict";e.exports=window.React},795:e=>{"use strict";e.exports=window.ReactDOM}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";var e=n(609),t=n(556),r=n.n(t);const a=window.wp.element,{formatPrice:s}=window.wc.priceFormat,o=({optionLabel:e,finalPrice:t,value:n,extraText:r,installmentPrice:a})=>{const o=s(a),l=s(t);return 1===n?`${e} (${o})`:`${n}x ${e} ${o} (${l}) ${r}`.trim()},l=e=>e.map((e=>({label:o(e),value:e.value}))),i=(e,t,n,r,s,o,i)=>{const[u,c]=(0,a.useState)(l(e)),d=(e=>{const t=(0,a.useRef)();return(0,a.useEffect)((()=>{t.current=e})),t.current})(r);return(0,a.useEffect)((()=>{(async()=>{if(2===t&&!n||1===t&&(!d||d===r))return;o(!0);const e=parseFloat(r/100).toFixed(2).replace(".",",");try{const t=await fetch("/wp-admin/admin-ajax.php?"+new URLSearchParams({action:"xqRhBHJ5sW",flag:n,total:e}),{headers:{"X-Request-Type":"Ajax"}});if(!t.ok)return void o(!1);const r=await t.json();if(!r?.installments?.length)return void o(!1);c(l(r.installments)),s(i,1),o(!1)}catch(e){return void o(!1)}})()}),[n,r,t,c,l,s,i]),(0,a.useEffect)((()=>{2===t&&c([{label:"...",value:""}])}),[t,c]),{installmentsOptions:u,filterHandler:e=>{u.filter((t=>t.label.toLowerCase().startsWith(e.toLowerCase())))},installmentsChangeHandler:e=>{s(i,e)}}},{ComboboxControl:u}=wp.components,c=({label:t,installments:n,installmentsType:r,selectedInstallment:a,setSelectedInstallment:s,brand:o,cartTotal:l,setIsLoading:c,cardIndex:d})=>{const{installmentsOptions:p,filterHandler:m,installmentsChangeHandler:v}=i(n,r,o,l,s,c,d);return(0,e.createElement)("div",{className:"wc-block-components-select-input pagarme-installments-combobox"},(0,e.createElement)("div",{className:"wc-block-components-combobox is-active"},(0,e.createElement)(u,{className:"wc-block-components-combobox-control",label:t,onChange:v,value:a,options:p,onFilterValueChange:m,allowReset:!1,autoComplete:"off"})))};c.propTypes={label:r().string.isRequired,installments:r().array.isRequired,installmentsType:r().number.isRequired,selectedInstallment:r().oneOfType([r().string,r().number]).isRequired,setSelectedInstallment:r().func.isRequired,brand:r().string.isRequired,cartTotal:r().number.isRequired,setIsLoading:r().func.isRequired,cardIndex:r().number.isRequired};const d=c;function p(e){return e.replace(/\s/g,"").split("/")}const m=(e,t,n,r)=>{const a=(e,t)=>(delete t.inputHolderName,e.length>0||(t.inputHolderName=r.holderName),t),s=(e,t)=>(delete t.inputNumber,16===(e=e.replace(/(\D)/g,"")).length||(t.inputNumber=r.cardNumber),t),o=(e,t)=>{if(delete t.inputExpiry,0===e.length)return t.inputExpiry=r.emptyExpiry,t;const[n,a]=p(e),s=new Date(`20${a}`,n-1);let o=new Date;return o=new Date(o.getFullYear(),o.getMonth()),n>=1&&n<=12||(t.inputExpiry=r.invalidExpiryMonth),!a.includes("_")||(t.inputExpiry=r.invalidExpiryYear),s(delete t.inputCvv,0===(e=e.replace(/(\D)/g,"")).length?(t.inputCvv=r.emptyCvv,t):(3===e.length||4===e.length||(t.inputCvv=r.invalidCvv),t));return{validateInputHolderName:r=>{const s=a(r,t);return n(e,{...s}),!!s.inputHolderName},validateInputNumber:r=>{const a=s(r,t);return n(e,{...a}),!!a.inputNumber},validateInputExpiry:r=>{const a=o(r,t);return n(e,{...a}),!!a.inputExpiry},validateInputCvv:r=>{const a=l(r,t);return n(e,{...a}),!!a.inputCvv},validateAllFields:(r,i,u,c)=>{let d={...t};return d=a(r,d),d=s(i,d),d=o(u,d),d=l(c,d),n(e,{...d}),0===Object.keys(d).length}}},v=({id:t,label:n,inputValue:r,setInputValue:s,cardIndex:o,errors:l,setErrors:i,fieldErrors:u})=>{const{setIsActive:c,cssClasses:d,inputChangeHandler:p,inputBlurHandler:v}=((e,t,n,r,s,o)=>{const{validateInputHolderName:l}=m(n,r,s,o);let i="wc-block-components-text-input";const[u,c]=(0,a.useState)(!1);return(u||e.length)&&(i+=" is-active"),r.hasOwnProperty("inputHolderName")&&(i+=" has-error"),{setIsActive:c,cssClasses:i,inputChangeHandler:e=>{const r=e.target.value.replace(/[^a-z ]/gi,"");t(n,r)},inputBlurHandler:e=>{l(e.target.value),c(!1)}}})(r,s,o,l,i,u);return(0,e.createElement)("div",{className:d},(0,e.createElement)("label",{htmlFor:t},n),(0,e.createElement)("input",{type:"text",id:t,value:r,onChange:p,onFocus:()=>c(!0),onBlur:v}),l.inputHolderName&&(0,e.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,e.createElement)("p",null,l.inputHolderName)))};v.propTypes={id:r().string.isRequired,label:r().string.isRequired,inputValue:r().string.isRequired,setInputValue:r().func.isRequired,cardIndex:r().number.isRequired,errors:r().object.isRequired,setErrors:r().func.isRequired,fieldErrors:r().object.isRequired};const f=v;var h=n(844),g=n.n(h);function b(e){return e.replace(/\s|•/g,"")}const E=(e,t,n,r,s,o,l,i,u)=>{const{validateInputNumber:c}=m(o,l,i,u),[d,p]=(0,a.useState)("");let v="wc-block-components-text-input pagarme-credit-card-number-container";const[f,h]=(0,a.useState)(!1);(f||e.length)&&(v+=" is-active"),l.hasOwnProperty("inputNumber")&&(v+=" has-error");const g=()=>{r(o,""),p("")};return{setIsActive:h,cssClasses:v,brandImageSrc:d,inputChangeHandler:e=>{n(o,e.target.value)},inputBlurHandler:n=>{c(n.target.value),(async()=>{const n=b(e);if(16!==n.length)return void g();s(!0);const a=n.substring(0,6),l=`https://api.pagar.me/bin/v1/${a}`;try{const e=await fetch(l),n=await e.json();let i=n.brand;if(e.ok&&void 0!==n.brandName||(i=(e=>{let n="",r=null;for(const[a,s]of Object.entries(t))for(const t of s.prefixes){const s=t.toString();0===e.indexOf(s)&&n.length{const{setIsActive:m,cssClasses:v,brandImageSrc:f,inputChangeHandler:h,inputBlurHandler:b}=E(r,l,a,o,i,u,c,d,p);return(0,e.createElement)("div",{className:v},(0,e.createElement)("label",{htmlFor:t},n),(0,e.createElement)(g(),{className:"pagarme-card-form-card-number",type:"text",id:t,mask:"9999 9999 9999 9999",maskChar:"•",onFocus:()=>m(!0),onChange:h,value:r,onBlur:b}),f&&(0,e.createElement)("img",{src:f,alt:s}),c.inputNumber&&(0,e.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,e.createElement)("p",null,c.inputNumber)))};C.propTypes={id:r().string.isRequired,label:r().string.isRequired,inputValue:r().string.isRequired,setInputValue:r().func.isRequired,brand:r().string.isRequired,setBrand:r().func.isRequired,brands:r().object.isRequired,setIsLoading:r().func.isRequired,cardIndex:r().number.isRequired,errors:r().object.isRequired,setErrors:r().func.isRequired,fieldErrors:r().object.isRequired};const I=C,k=({id:t,label:n,inputValue:r,setInputValue:s,cardIndex:o,validate:l,validateIndex:i,mask:u,maskChar:c=null,errors:d})=>{const{setIsActive:p,cssClasses:m,inputChangeHandler:v,inputBlurHandler:f}=((e,t,n,r,s,o)=>{let l="wc-block-components-text-input";const[i,u]=(0,a.useState)(!1);return(i||e.length)&&(l+=" is-active"),o.hasOwnProperty(s)&&(l+=" has-error"),{setIsActive:u,cssClasses:l,inputChangeHandler:e=>{t(n,e.target.value)},inputBlurHandler:e=>{r(e.target.value),u(!1)}}})(r,s,o,l,i,d);return(0,e.createElement)("div",{className:m},(0,e.createElement)("label",{htmlFor:t},n),(0,e.createElement)(g(),{type:"text",id:t,mask:u,maskChar:c,onChange:v,value:r,onFocus:()=>p(!0),onBlur:f}))};k.propTypes={id:r().string.isRequired,label:r().string.isRequired,inputValue:r().string.isRequired,setInputValue:r().func.isRequired,cardIndex:r().number.isRequired,mask:r().string.isRequired,maskChar:r().string,validate:r().func.isRequired,validateIndex:r().string.isRequired,errors:r().object.isRequired};const w=k,y=({id:t,label:n,cardIndex:r,inputValue:a,setInputValue:s,errors:o,setErrors:l,fieldErrors:i})=>{const{validateInputExpiry:u}=m(r,o,l,i);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(w,{id:t,label:n,mask:"99/99",maskChar:"_",inputValue:a,setInputValue:s,cardIndex:r,validate:u,validateIndex:"inputExpiry",errors:o}),o.inputExpiry&&(0,e.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,e.createElement)("p",null,o.inputExpiry)))};y.propTypes={id:r().string.isRequired,label:r().string.isRequired,cardIndex:r().number.isRequired,inputValue:r().string.isRequired,setInputValue:r().func.isRequired,errors:r().object.isRequired,setErrors:r().func.isRequired,fieldErrors:r().object.isRequired};const R=y,x=({id:t,label:n,cardIndex:r,inputValue:a,setInputValue:s,errors:o,setErrors:l,fieldErrors:i})=>{const{validateInputCvv:u}=m(r,o,l,i);return(0,e.createElement)(e.Fragment,null,(0,e.createElement)(w,{id:t,label:n,mask:"9999",inputValue:a,setInputValue:s,cardIndex:r,validate:u,validateIndex:"inputCvv",errors:o}),o.inputCvv&&(0,e.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,e.createElement)("p",null,o.inputCvv)))};x.propTypes={id:r().string.isRequired,label:r().string.isRequired,cardIndex:r().number.isRequired,inputValue:r().string.isRequired,setInputValue:r().func.isRequired,errors:r().object.isRequired,setErrors:r().func.isRequired,fieldErrors:r().object.isRequired};const S=x,{ComboboxControl:O}=wp.components,N=({cards:t,label:n,cardIndex:r,selectedCard:a,setSelectCard:s,setBrand:o})=>{const{filterHandler:l,cardChangeHandler:i}=((e,t,n,r)=>({filterHandler:t=>{e.filter((e=>e.label.toLowerCase().startsWith(t.toLowerCase())))},cardChangeHandler:a=>{if(n(t,a),!e)return;const s=e.find((e=>e.value===a));r(t,s?s.brand:"")}}))(t,r,s,o);return(0,e.createElement)("div",{className:"wc-block-components-select-input pagarme-installments-combobox"},(0,e.createElement)("div",{className:"wc-block-components-combobox is-active"},(0,e.createElement)(O,{className:"wc-block-components-combobox-control",label:n,onChange:i,value:a,options:t,onFilterValueChange:l,allowReset:!1,autoComplete:"off"})))};N.propTypes={cards:r().array.isRequired,label:r().string.isRequired,cardIndex:r().number.isRequired,selectedCard:r().string.isRequired,setSelectCard:r().func.isRequired,setBrand:r().func.isRequired};const V=N,q=window.wp.data,T={holderName:"",number:"",expirationDate:"",installment:1,brand:"",cvv:"",saveCard:!1,walletId:"",errors:{}},P={cards:{1:{...T},2:{...T}}},D=(0,q.createReduxStore)("pagarme-cards",{reducer(e=P,t){switch(t.type){case"SET_PROPERTY_VALUE":return 0===t.propertyName?.length?e:{...e,cards:{...e.cards,[t.cardIndex]:{...e.cards[t.cardIndex],[t.propertyName]:t.value}}};case"RESET":return P}return e},actions:{setHolderName:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"holderName"}),setNumber:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"number"}),setExpirationDate:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"expirationDate"}),setInstallment:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"installment"}),setBrand:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"brand"}),setCvv:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"cvv"}),setSaveCard:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"saveCard"}),setWalletId:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"walletId"}),setErrors:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"errors"}),reset:()=>({type:"RESET"})},selectors:{getHolderName:(e,t)=>e.cards[t].holderName,getNumber:(e,t)=>e.cards[t].number,getExpirationDate:(e,t)=>e.cards[t].expirationDate,getInstallment:(e,t)=>e.cards[t].installment,getBrand:(e,t)=>e.cards[t].brand,getCvv:(e,t)=>e.cards[t].cvv,getSaveCard:(e,t)=>e.cards[t].saveCard,getWalletId:(e,t)=>e.cards[t].walletId,getCards:e=>e.cards,getErrors:(e,t)=>e.cards[t].errors}});(0,q.register)(D);const L=D,{CheckboxControl:M}=window.wc.blocksComponents,_=({billing:t,components:n,backendConfig:r,cardIndex:s,eventRegistration:o})=>{const{LoadingMask:l}=n,{holderNameLabel:i,numberLabel:u,expiryLabel:c,cvvLabel:p,installmentsLabel:v,saveCardLabel:h,walletLabel:g}=r.fieldsLabels,{isLoading:b,setIsLoading:E,setHolderName:C,setNumber:k,setExpirationDate:w,setInstallment:y,setBrand:x,setCvv:O,setWalletId:N,setErrors:T,saveCardChangeHandler:P,formatFieldId:D,holderName:_,number:j,expirationDate:H,selectedInstallment:B,brand:F,cvv:A,saveCard:U,walletId:Y,errors:$}=((e,t,n)=>{const[r,s]=(0,a.useState)(!1),{setHolderName:o,setNumber:l,setExpirationDate:i,setInstallment:u,setBrand:c,setCvv:d,setSaveCard:p,setWalletId:v,setErrors:f}=(0,q.useDispatch)(L),h=(0,q.useSelect)((t=>t(L).getHolderName(e)),[e]),g=(0,q.useSelect)((t=>t(L).getNumber(e)),[e]),b=(0,q.useSelect)((t=>t(L).getExpirationDate(e)),[e]),E=(0,q.useSelect)((t=>t(L).getInstallment(e)),[e]),C=(0,q.useSelect)((t=>t(L).getBrand(e)),[e]),I=(0,q.useSelect)((t=>t(L).getCvv(e)),[e]),k=(0,q.useSelect)((t=>t(L).getSaveCard(e)),[e]),w=(0,q.useSelect)((t=>t(L).getWalletId(e)),[e]),y=(0,q.useSelect)((t=>t(L).getErrors(e)),[e]),{validateAllFields:R}=m(e,y,f,n.fieldErrors),{onCheckoutValidation:x}=t;return(0,a.useEffect)((()=>x((()=>(w.length>0||R(h,g,b,I),!0)))),[x,h,g,b,I,n,w]),{isLoading:r,setIsLoading:s,setHolderName:o,setNumber:l,setExpirationDate:i,setInstallment:u,setBrand:c,setCvv:d,setWalletId:v,setErrors:f,saveCardChangeHandler:t=>{p(e,t)},formatFieldId:t=>`pagarme_credit_card_${e}_${t}`,holderName:h,number:g,expirationDate:b,selectedInstallment:E,brand:C,cvv:I,saveCard:k,walletId:w,errors:y}})(s,o,r);return(0,e.createElement)(l,{isLoading:b},(0,e.createElement)("div",{className:"wc-block-components-form"},r?.walletEnabled&&r?.cards?.length>0&&(0,e.createElement)(V,{label:g,selectedCard:Y,cards:r.cards,cardIndex:s,setSelectCard:N,setBrand:x}),0===Y.length&&(0,e.createElement)(e.Fragment,null,(0,e.createElement)(f,{id:D("holder_name"),label:i,inputValue:_,setInputValue:C,cardIndex:s,errors:$,setErrors:T,fieldErrors:r?.fieldErrors}),(0,e.createElement)(I,{id:D("number"),label:u,inputValue:j,setInputValue:k,brand:F,setBrand:x,brands:r?.brands,setIsLoading:E,cardIndex:s,errors:$,setErrors:T,fieldErrors:r?.fieldErrors}),(0,e.createElement)(R,{id:D("expiry"),label:c,inputValue:H,setInputValue:w,cardIndex:s,errors:$,setErrors:T,fieldErrors:r?.fieldErrors}),(0,e.createElement)(S,{id:D("cvv"),label:p,inputValue:A,setInputValue:O,cardIndex:s,errors:$,setErrors:T,fieldErrors:r?.fieldErrors})),(0,e.createElement)(d,{label:v,installments:r?.installments,installmentsType:r?.installmentsType,selectedInstallment:B,setSelectedInstallment:y,brand:F,cartTotal:t.cartTotal.value,setIsLoading:E,cardIndex:s}),0===Y.length&&r?.walletEnabled&&(0,e.createElement)(M,{label:h,checked:U,onChange:P})))};_.propType={billing:r().object.isRequired,components:r().object.isRequired,backendConfig:r().object.isRequired,cardIndex:r().number.isRequired,eventRegistration:r().object.isRequired};const j=_;class H extends Error{constructor(e){super(e),this.name=this.constructor.name}}const B=(e,t,n)=>{const r=`${e.replace("request.","").replace("card.","")}: ${t}`;return n.hasOwnProperty(r)?n[r]:""};async function F(e,t,n,r,a,s){const[o,l]=p(n),i={card:{holder_name:t,number:b(e),exp_month:o,exp_year:l,cvv:r}};try{const e=`https://api.pagar.me/core/v5/tokens?appId=${a}`,t=await fetch(e,{method:"POST",body:JSON.stringify(i)});if(!t.ok){const e=await t.text();if(0===e.length)return{errorMessage:s.serviceUnavailable};const n=((e,t)=>{let n="";for(const r in e.errors)for(const a of e.errors[r]||[]){const e=B(r,a,t);0!==e.length&&(n+=`${e}
`)}return n})(JSON.parse(e),s);return{errorMessage:n}}return{token:(await t.json()).id}}catch(e){return{errorMessage:s.serviceUnavailable}}}const A=(e,t,n)=>{const{reset:r}=(0,q.useDispatch)(L),{onPaymentSetup:s}=n,o=(0,q.useSelect)((e=>e(L).getCards()));(0,a.useEffect)((()=>{r()}),[]),(0,a.useEffect)((()=>s((async()=>{try{let n=!1;if("object"==typeof o&&(n=Object.values(o).some((e=>Object.keys(e.errors).length>0))),n)return{type:t.responseTypes.ERROR,message:e.errorMessages.creditCardFormHasErrors};const r=await(async(e,t,n)=>{const r=[];for(let a=1;a0){r[a]={"wallet-id":d,brand:i,installment:u};continue}const p=await F(s,t,o,l,n.appId,n.errorMessages);if(p.errorMessage)throw new H(p.errorMessage);r[a]={token:p.token,brand:i,installment:u},c&&(r[a]["save-card"]=c)}return r})(o,1,e);return{type:t.responseTypes.SUCCESS,meta:{paymentMethodData:{pagarme:JSON.stringify({[e.key]:{cards:{...r}}}),payment_method:e.key}}}}catch(n){let r=e.errorMessages.serviceUnavailable;return n instanceof H&&(r=n.message),{type:t.responseTypes.ERROR,message:r}}}))),[s,o,e])},{registerPaymentMethod:U}=window.wc.wcBlocksRegistry,Y=wc.wcSettings.getSetting("woo-pagarme-payments-credit_card_data"),$=t=>{const{emitResponse:n,eventRegistration:r}=t;return A(Y,n,r),(0,e.createElement)(j,{...t,backendConfig:Y,cardIndex:1})},W=({components:t})=>{const{PaymentMethodLabel:n}=t;return(0,e.createElement)(n,{text:Y.label})};$.propTypes={emitResponse:r().object,eventRegistration:r().object},W.propTypes={components:r().object},U({name:Y.name,label:(0,e.createElement)(W,null),content:(0,e.createElement)($,null),edit:(0,e.createElement)($,null),canMakePayment:()=>!0,ariaLabel:Y.ariaLabel})})()})(); \ No newline at end of file +(()=>{var e={694:(e,t,n)=>{"use strict";var r=n(925);function a(){}function s(){}s.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,s,o){if(o!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:a};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},844:(e,t,n)=>{e.exports=n(200)},200:(e,t,n)=>{"use strict";var r,a=(r=n(609))&&"object"==typeof r&&"default"in r?r.default:r,s=n(795);function o(){return(o=Object.assign||function(e){for(var t=1;tr.length&&p(e,t.length-1);)t=t.slice(0,t.length-1);return t.length}for(var a=r.length,s=t.length;s>=r.length;s--){var o=t[s];if(!p(e,s)&&m(e,s,o)){a=s+1;break}}return a}function h(e,t){return f(e,t)===e.mask.length}function g(e,t){var n=e.maskChar,r=e.mask,a=e.prefix;if(!n){for((t=b(e,"",t,0)).lengtht.length&&(t+=a.slice(t.length,r)),l.every((function(n){for(;c=n,p(e,u=r)&&c!==a[u];){if(r>=t.length&&(t+=a[r]),l=n,s&&p(e,r)&&l===s)return!0;if(++r>=a.length)return!1}var l,u,c;return!m(e,r,n)&&n!==s||(ra.start?d=(c=function(e,t,n,r){var a=e.mask,s=e.maskChar,o=n.split(""),l=r;return o.every((function(t){for(;o=t,p(e,n=r)&&o!==a[n];)if(++r>=a.length)return!1;var n,o;return(m(e,r,t)||t===s)&&r++,r=s.length?v=s.length:v=o.length&&v{"use strict";e.exports=window.React},795:e=>{"use strict";e.exports=window.ReactDOM}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t{const o=s(a),l=s(t);return 1===n?`${e} (${o})`:`${n}x ${e} ${o} (${l}) ${r}`.trim()},l=e=>e.map((e=>({label:o(e),value:e.value}))),i=(e,n,r,a,s,o,i)=>{const[u,c]=(0,t.useState)(l(e)),d=(e=>{const n=(0,t.useRef)();return(0,t.useEffect)((()=>{n.current=e})),n.current})(a);return(0,t.useEffect)((()=>{(async()=>{if(2===n&&!r||1===n&&(!d||d===a))return;o(!0);const e=parseFloat(a/100).toFixed(2).replace(".",",");try{const t=await fetch("/wp-admin/admin-ajax.php?"+new URLSearchParams({action:"xqRhBHJ5sW",flag:r,total:e}),{headers:{"X-Request-Type":"Ajax"}});if(!t.ok)return void o(!1);const n=await t.json();if(!n?.installments?.length)return void o(!1);c(l(n.installments)),s(i,1),o(!1)}catch(e){return void o(!1)}})()}),[r,a,n,c,l,s,i]),(0,t.useEffect)((()=>{2===n&&c([{label:"...",value:""}])}),[n,c]),{installmentsOptions:u,filterHandler:e=>{u.filter((t=>t.label.toLowerCase().startsWith(e.toLowerCase())))},installmentsChangeHandler:e=>{s(i,e)}}},{ComboboxControl:u}=wp.components,c=({label:e,installments:n,installmentsType:r,selectedInstallment:a,setSelectedInstallment:s,brand:o,cartTotal:l,setIsLoading:c,cardIndex:d})=>{const{installmentsOptions:p,filterHandler:m,installmentsChangeHandler:v}=i(n,r,o,l,s,c,d);return(0,t.createElement)("div",{className:"wc-block-components-select-input pagarme-installments-combobox"},(0,t.createElement)("div",{className:"wc-block-components-combobox is-active"},(0,t.createElement)(u,{className:"wc-block-components-combobox-control",label:e,onChange:v,value:a,options:p,onFilterValueChange:m,allowReset:!1,autoComplete:"off"})))};c.propTypes={label:a().string.isRequired,installments:a().array.isRequired,installmentsType:a().number.isRequired,selectedInstallment:a().oneOfType([a().string,a().number]).isRequired,setSelectedInstallment:a().func.isRequired,brand:a().string.isRequired,cartTotal:a().number.isRequired,setIsLoading:a().func.isRequired,cardIndex:a().number.isRequired};const d=c;function p(e){return e.replace(/\s/g,"").split("/")}const m=(e,t,n,r)=>{const a=(e,t)=>(delete t.inputHolderName,e.length>0||(t.inputHolderName=r.holderName),t),s=(e,t)=>(delete t.inputNumber,16===(e=e.replace(/(\D)/g,"")).length||(t.inputNumber=r.cardNumber),t),o=(e,t)=>{if(delete t.inputExpiry,0===e.length)return t.inputExpiry=r.emptyExpiry,t;const[n,a]=p(e),s=new Date(`20${a}`,n-1);let o=new Date;return o=new Date(o.getFullYear(),o.getMonth()),n>=1&&n<=12||(t.inputExpiry=r.invalidExpiryMonth),!a.includes("_")||(t.inputExpiry=r.invalidExpiryYear),s(delete t.inputCvv,0===(e=e.replace(/(\D)/g,"")).length?(t.inputCvv=r.emptyCvv,t):(3===e.length||4===e.length||(t.inputCvv=r.invalidCvv),t));return{validateInputHolderName:r=>{const s=a(r,t);return n(e,{...s}),!!s.inputHolderName},validateInputNumber:r=>{const a=s(r,t);return n(e,{...a}),!!a.inputNumber},validateInputExpiry:r=>{const a=o(r,t);return n(e,{...a}),!!a.inputExpiry},validateInputCvv:r=>{const a=l(r,t);return n(e,{...a}),!!a.inputCvv},validateAllFields:(r,i,u,c)=>{let d={...t};return d=a(r,d),d=s(i,d),d=o(u,d),d=l(c,d),n(e,{...d}),0===Object.keys(d).length}}},v=({id:e,label:n,inputValue:r,setInputValue:a,cardIndex:s,errors:o,setErrors:l,fieldErrors:i})=>{const{setIsActive:u,cssClasses:c,inputChangeHandler:d,inputBlurHandler:p}=((e,n,r,a,s,o)=>{const{validateInputHolderName:l}=m(r,a,s,o);let i="wc-block-components-text-input";const[u,c]=(0,t.useState)(!1);return(u||e.length)&&(i+=" is-active"),a.hasOwnProperty("inputHolderName")&&(i+=" has-error"),{setIsActive:c,cssClasses:i,inputChangeHandler:e=>{const t=e.target.value.replace(/[^a-z ]/gi,"");n(r,t)},inputBlurHandler:e=>{l(e.target.value),c(!1)}}})(r,a,s,o,l,i);return(0,t.createElement)("div",{className:c},(0,t.createElement)("label",{htmlFor:e},n),(0,t.createElement)("input",{type:"text",id:e,value:r,onChange:d,onFocus:()=>u(!0),onBlur:p}),o.inputHolderName&&(0,t.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,t.createElement)("p",null,o.inputHolderName)))};v.propTypes={id:a().string.isRequired,label:a().string.isRequired,inputValue:a().string.isRequired,setInputValue:a().func.isRequired,cardIndex:a().number.isRequired,errors:a().object.isRequired,setErrors:a().func.isRequired,fieldErrors:a().object.isRequired};const f=v;var h=n(844),g=n.n(h);function b(e){return e.replace(/\s|•/g,"")}const E=(e,n,r,a,s,o,l,i,u)=>{const{validateInputNumber:c}=m(o,l,i,u),[d,p]=(0,t.useState)("");let v="wc-block-components-text-input pagarme-credit-card-number-container";const[f,h]=(0,t.useState)(!1);(f||e.length)&&(v+=" is-active"),l.hasOwnProperty("inputNumber")&&(v+=" has-error");const g=()=>{a(o,""),p("")};return{setIsActive:h,cssClasses:v,brandImageSrc:d,inputChangeHandler:e=>{r(o,e.target.value)},inputBlurHandler:t=>{c(t.target.value),(async()=>{const t=b(e);if(16!==t.length)return void g();s(!0);const r=t.substring(0,6),l=`https://api.pagar.me/bin/v1/${r}`;try{const e=await fetch(l),t=await e.json();let i=t.brand;if(e.ok&&void 0!==t.brandName||(i=(e=>{let t="",r=null;for(const[a,s]of Object.entries(n))for(const n of s.prefixes){const s=n.toString();0===e.indexOf(s)&&t.length{const{setIsActive:m,cssClasses:v,brandImageSrc:f,inputChangeHandler:h,inputBlurHandler:b}=E(r,l,a,o,i,u,c,d,p);return(0,t.createElement)("div",{className:v},(0,t.createElement)("label",{htmlFor:e},n),(0,t.createElement)(g(),{className:"pagarme-card-form-card-number",type:"text",id:e,mask:"9999 9999 9999 9999",maskChar:"•",onFocus:()=>m(!0),onChange:h,value:r,onBlur:b}),f&&(0,t.createElement)("img",{src:f,alt:s}),c.inputNumber&&(0,t.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,t.createElement)("p",null,c.inputNumber)))};C.propTypes={id:a().string.isRequired,label:a().string.isRequired,inputValue:a().string.isRequired,setInputValue:a().func.isRequired,brand:a().string.isRequired,setBrand:a().func.isRequired,brands:a().object.isRequired,setIsLoading:a().func.isRequired,cardIndex:a().number.isRequired,errors:a().object.isRequired,setErrors:a().func.isRequired,fieldErrors:a().object.isRequired};const I=C,k=({id:e,label:n,inputValue:r,setInputValue:a,cardIndex:s,validate:o,validateIndex:l,mask:i,maskChar:u=null,errors:c})=>{const{setIsActive:d,cssClasses:p,inputChangeHandler:m,inputBlurHandler:v}=((e,n,r,a,s,o)=>{let l="wc-block-components-text-input";const[i,u]=(0,t.useState)(!1);return(i||e.length)&&(l+=" is-active"),o.hasOwnProperty(s)&&(l+=" has-error"),{setIsActive:u,cssClasses:l,inputChangeHandler:e=>{n(r,e.target.value)},inputBlurHandler:e=>{a(e.target.value),u(!1)}}})(r,a,s,o,l,c);return(0,t.createElement)("div",{className:p},(0,t.createElement)("label",{htmlFor:e},n),(0,t.createElement)(g(),{type:"text",id:e,mask:i,maskChar:u,onChange:m,value:r,onFocus:()=>d(!0),onBlur:v}))};k.propTypes={id:a().string.isRequired,label:a().string.isRequired,inputValue:a().string.isRequired,setInputValue:a().func.isRequired,cardIndex:a().number.isRequired,mask:a().string.isRequired,maskChar:a().string,validate:a().func.isRequired,validateIndex:a().string.isRequired,errors:a().object.isRequired};const w=k,y=({id:e,label:n,cardIndex:r,inputValue:a,setInputValue:s,errors:o,setErrors:l,fieldErrors:i})=>{const{validateInputExpiry:u}=m(r,o,l,i);return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(w,{id:e,label:n,mask:"99/99",maskChar:"_",inputValue:a,setInputValue:s,cardIndex:r,validate:u,validateIndex:"inputExpiry",errors:o}),o.inputExpiry&&(0,t.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,t.createElement)("p",null,o.inputExpiry)))};y.propTypes={id:a().string.isRequired,label:a().string.isRequired,cardIndex:a().number.isRequired,inputValue:a().string.isRequired,setInputValue:a().func.isRequired,errors:a().object.isRequired,setErrors:a().func.isRequired,fieldErrors:a().object.isRequired};const R=y,x=({id:e,label:n,cardIndex:r,inputValue:a,setInputValue:s,errors:o,setErrors:l,fieldErrors:i})=>{const{validateInputCvv:u}=m(r,o,l,i);return(0,t.createElement)(t.Fragment,null,(0,t.createElement)(w,{id:e,label:n,mask:"9999",inputValue:a,setInputValue:s,cardIndex:r,validate:u,validateIndex:"inputCvv",errors:o}),o.inputCvv&&(0,t.createElement)("div",{className:"wc-block-components-validation-error",role:"alert"},(0,t.createElement)("p",null,o.inputCvv)))};x.propTypes={id:a().string.isRequired,label:a().string.isRequired,cardIndex:a().number.isRequired,inputValue:a().string.isRequired,setInputValue:a().func.isRequired,errors:a().object.isRequired,setErrors:a().func.isRequired,fieldErrors:a().object.isRequired};const S=x,{ComboboxControl:O}=wp.components,N=({cards:e,label:n,cardIndex:r,selectedCard:a,setSelectCard:s,setBrand:o})=>{const{filterHandler:l,cardChangeHandler:i}=((e,t,n,r)=>({filterHandler:t=>{e.filter((e=>e.label.toLowerCase().startsWith(t.toLowerCase())))},cardChangeHandler:a=>{if(n(t,a),!e)return;const s=e.find((e=>e.value===a));r(t,s?s.brand:"")}}))(e,r,s,o);return(0,t.createElement)("div",{className:"wc-block-components-select-input pagarme-installments-combobox"},(0,t.createElement)("div",{className:"wc-block-components-combobox is-active"},(0,t.createElement)(O,{className:"wc-block-components-combobox-control",label:n,onChange:i,value:a,options:e,onFilterValueChange:l,allowReset:!1,autoComplete:"off"})))};N.propTypes={cards:a().array.isRequired,label:a().string.isRequired,cardIndex:a().number.isRequired,selectedCard:a().string.isRequired,setSelectCard:a().func.isRequired,setBrand:a().func.isRequired};const V=N,q=window.wp.data,T={holderName:"",number:"",expirationDate:"",installment:1,brand:"",cvv:"",saveCard:!1,walletId:"",errors:{}},P={cards:{1:{...T},2:{...T}}},D=(0,q.createReduxStore)("pagarme-cards",{reducer(e=P,t){switch(t.type){case"SET_PROPERTY_VALUE":return 0===t.propertyName?.length?e:{...e,cards:{...e.cards,[t.cardIndex]:{...e.cards[t.cardIndex],[t.propertyName]:t.value}}};case"RESET":return P}return e},actions:{setHolderName:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"holderName"}),setNumber:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"number"}),setExpirationDate:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"expirationDate"}),setInstallment:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"installment"}),setBrand:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"brand"}),setCvv:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"cvv"}),setSaveCard:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"saveCard"}),setWalletId:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"walletId"}),setErrors:(e,t)=>({type:"SET_PROPERTY_VALUE",cardIndex:e,value:t,propertyName:"errors"}),reset:()=>({type:"RESET"})},selectors:{getHolderName:(e,t)=>e.cards[t].holderName,getNumber:(e,t)=>e.cards[t].number,getExpirationDate:(e,t)=>e.cards[t].expirationDate,getInstallment:(e,t)=>e.cards[t].installment,getBrand:(e,t)=>e.cards[t].brand,getCvv:(e,t)=>e.cards[t].cvv,getSaveCard:(e,t)=>e.cards[t].saveCard,getWalletId:(e,t)=>e.cards[t].walletId,getCards:e=>e.cards,getErrors:(e,t)=>e.cards[t].errors}});(0,q.register)(D);const L=D,{CheckboxControl:M}=window.wc.blocksComponents,_=({billing:e,components:n,backendConfig:r,cardIndex:a,eventRegistration:s})=>{const{LoadingMask:o}=n,{holderNameLabel:l,numberLabel:i,expiryLabel:u,cvvLabel:c,installmentsLabel:p,saveCardLabel:v,walletLabel:h}=r.fieldsLabels,{isLoading:g,setIsLoading:b,setHolderName:E,setNumber:C,setExpirationDate:k,setInstallment:w,setBrand:y,setCvv:x,setWalletId:O,setErrors:N,saveCardChangeHandler:T,formatFieldId:P,holderName:D,number:_,expirationDate:j,selectedInstallment:H,brand:B,cvv:F,saveCard:A,walletId:U,errors:Y}=((e,n,r)=>{const[a,s]=(0,t.useState)(!1),{setHolderName:o,setNumber:l,setExpirationDate:i,setInstallment:u,setBrand:c,setCvv:d,setSaveCard:p,setWalletId:v,setErrors:f}=(0,q.useDispatch)(L),h=(0,q.useSelect)((t=>t(L).getHolderName(e)),[e]),g=(0,q.useSelect)((t=>t(L).getNumber(e)),[e]),b=(0,q.useSelect)((t=>t(L).getExpirationDate(e)),[e]),E=(0,q.useSelect)((t=>t(L).getInstallment(e)),[e]),C=(0,q.useSelect)((t=>t(L).getBrand(e)),[e]),I=(0,q.useSelect)((t=>t(L).getCvv(e)),[e]),k=(0,q.useSelect)((t=>t(L).getSaveCard(e)),[e]),w=(0,q.useSelect)((t=>t(L).getWalletId(e)),[e]),y=(0,q.useSelect)((t=>t(L).getErrors(e)),[e]),{validateAllFields:R}=m(e,y,f,r.fieldErrors),{onCheckoutValidation:x}=n;return(0,t.useEffect)((()=>x((()=>(0===w.length&&R(h,g,b,I),!0)))),[x,h,g,b,I,r,w]),{isLoading:a,setIsLoading:s,setHolderName:o,setNumber:l,setExpirationDate:i,setInstallment:u,setBrand:c,setCvv:d,setWalletId:v,setErrors:f,saveCardChangeHandler:t=>{p(e,t)},formatFieldId:t=>`pagarme_credit_card_${e}_${t}`,holderName:h,number:g,expirationDate:b,selectedInstallment:E,brand:C,cvv:I,saveCard:k,walletId:w,errors:y}})(a,s,r);return(0,t.createElement)(o,{isLoading:g},(0,t.createElement)("div",{className:"wc-block-components-form"},r?.walletEnabled&&r?.cards?.length>0&&(0,t.createElement)(V,{label:h,selectedCard:U,cards:r.cards,cardIndex:a,setSelectCard:O,setBrand:y}),0===U.length&&(0,t.createElement)(t.Fragment,null,(0,t.createElement)(f,{id:P("holder_name"),label:l,inputValue:D,setInputValue:E,cardIndex:a,errors:Y,setErrors:N,fieldErrors:r?.fieldErrors}),(0,t.createElement)(I,{id:P("number"),label:i,inputValue:_,setInputValue:C,brand:B,setBrand:y,brands:r?.brands,setIsLoading:b,cardIndex:a,errors:Y,setErrors:N,fieldErrors:r?.fieldErrors}),(0,t.createElement)(R,{id:P("expiry"),label:u,inputValue:j,setInputValue:k,cardIndex:a,errors:Y,setErrors:N,fieldErrors:r?.fieldErrors}),(0,t.createElement)(S,{id:P("cvv"),label:c,inputValue:F,setInputValue:x,cardIndex:a,errors:Y,setErrors:N,fieldErrors:r?.fieldErrors})),(0,t.createElement)(d,{label:p,installments:r?.installments,installmentsType:r?.installmentsType,selectedInstallment:H,setSelectedInstallment:w,brand:B,cartTotal:e.cartTotal.value,setIsLoading:b,cardIndex:a}),0===U.length&&r?.walletEnabled&&(0,t.createElement)(M,{label:v,checked:A,onChange:T})))};_.propType={billing:a().object.isRequired,components:a().object.isRequired,backendConfig:a().object.isRequired,cardIndex:a().number.isRequired,eventRegistration:a().object.isRequired};const j=_;class H extends Error{constructor(e){super(e),this.name=this.constructor.name}}const B=(e,t,n)=>{const r=`${e.replace("request.","").replace("card.","")}: ${t}`;return n.hasOwnProperty(r)?n[r]:""};async function F(e,t,n,r,a,s){const[o,l]=p(n),i={card:{holder_name:t,number:b(e),exp_month:o,exp_year:l,cvv:r}};try{const e=`https://api.pagar.me/core/v5/tokens?appId=${a}`,t=await fetch(e,{method:"POST",body:JSON.stringify(i)});if(!t.ok){const e=await t.text();if(0===e.length)return{errorMessage:s.serviceUnavailable};const n=((e,t)=>{let n="";for(const r in e.errors)for(const a of e.errors[r]||[]){const e=B(r,a,t);0!==e.length&&(n+=`${e}
`)}return n})(JSON.parse(e),s);return{errorMessage:n}}return{token:(await t.json()).id}}catch(e){return{errorMessage:s.serviceUnavailable}}}const A=(e,n,r)=>{const{reset:a}=(0,q.useDispatch)(L),{onPaymentSetup:s}=r,o=(0,q.useSelect)((e=>e(L).getCards()));(0,t.useEffect)((()=>{a()}),[]),(0,t.useEffect)((()=>s((async()=>{try{let t=!1;if("object"==typeof o&&(t=Object.values(o).some((e=>Object.keys(e.errors).length>0))),t)return{type:n.responseTypes.ERROR,message:e.errorMessages.creditCardFormHasErrors};const r=await(async(e,t,n)=>{const r=[];for(let a=1;a0){r[a]={"wallet-id":d,brand:i,installment:u};continue}const p=await F(s,t,o,l,n.appId,n.errorMessages);if(p.errorMessage)throw new H(p.errorMessage);r[a]={token:p.token,brand:i,installment:u},c&&(r[a]["save-card"]=c)}return r})(o,1,e);return{type:n.responseTypes.SUCCESS,meta:{paymentMethodData:{pagarme:JSON.stringify({[e.key]:{cards:{...r}}}),payment_method:e.key}}}}catch(t){let r=e.errorMessages.serviceUnavailable;return t instanceof H&&(r=t.message),{type:n.responseTypes.ERROR,message:r}}}))),[s,o,e])},{registerPaymentMethod:U}=window.wc.wcBlocksRegistry,Y=wc.wcSettings.getSetting("woo-pagarme-payments-credit_card_data"),$=n=>{const{emitResponse:r,eventRegistration:a}=n;return A(Y,r,a),(0,t.createElement)(j,e({},n,{backendConfig:Y,cardIndex:1}))},W=({components:e})=>{const{PaymentMethodLabel:n}=e;return(0,t.createElement)(n,{text:Y.label})};$.propTypes={emitResponse:a().object,eventRegistration:a().object},W.propTypes={components:a().object},U({name:Y.name,label:(0,t.createElement)(W,null),content:(0,t.createElement)($,null),edit:(0,t.createElement)($,null),canMakePayment:()=>!0,ariaLabel:Y.ariaLabel})})()})(); \ No newline at end of file diff --git a/build/pix.asset.php b/build/pix.asset.php index 94dbeb43..5ef4b2ab 100644 --- a/build/pix.asset.php +++ b/build/pix.asset.php @@ -1 +1 @@ - array('react', 'wp-element'), 'version' => 'a0e020f30508fa5c3387'); + array('wp-element'), 'version' => 'a3f43fdf4425ecacd25d'); diff --git a/build/pix.js b/build/pix.js index ed46f2d1..b6bb255d 100644 --- a/build/pix.js +++ b/build/pix.js @@ -1 +1 @@ -(()=>{var e={694:(e,t,n)=>{"use strict";var a=n(925);function r(){}function o(){}o.resetWarningCache=r,e.exports=function(){function e(e,t,n,r,o,s){if(s!==a){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:r};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(a){var r=t[a];if(void 0!==r)return r.exports;var o=t[a]={exports:{}};return e[a](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var a in t)n.o(t,a)&&!n.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React;var t=n(556),a=n.n(t);const r=window.wp.element,o=({emitResponse:t,eventRegistration:n,backendConfig:a})=>(((e,t,n)=>{const{onPaymentSetup:a}=t;(0,r.useEffect)((()=>a((()=>{const t={payment_method:n.key};return{type:e.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}))),[a,n])})(t,n,a),(0,e.createElement)(e.Fragment,null,(0,e.createElement)("p",{className:"pagarme-payment-method-instructions"},a.instructions),(0,e.createElement)("p",{className:"pagarme-payment-method-logo"},(0,e.createElement)("img",{className:"logo",src:a.logo,alt:a.label,title:a.label}))));o.propTypes={emitResponse:a().object.isRequired,eventRegistration:a().object.isRequired,backendConfig:a().object.isRequired};const s=o,{registerPaymentMethod:c}=window.wc.wcBlocksRegistry,i=wc.wcSettings.getSetting("woo-pagarme-payments-pix_data"),p=t=>(0,e.createElement)(s,{...t,backendConfig:i}),l=({components:t})=>{const{PaymentMethodLabel:n}=t;return(0,e.createElement)(n,{text:i.label})};l.propTypes={components:a().object},c({name:i.name,label:(0,e.createElement)(l,null),content:(0,e.createElement)(p,null),edit:(0,e.createElement)(p,null),canMakePayment:()=>!0,ariaLabel:i.ariaLabel})})()})(); \ No newline at end of file +(()=>{var e={694:(e,t,n)=>{"use strict";var r=n(925);function a(){}function o(){}o.resetWarningCache=a,e.exports=function(){function e(e,t,n,a,o,s){if(s!==r){var c=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw c.name="Invariant Violation",c}}function t(){return e}e.isRequired=e;var n={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:o,resetWarningCache:a};return n.PropTypes=n,n}},556:(e,t,n)=>{e.exports=n(694)()},925:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"}},t={};function n(r){var a=t[r];if(void 0!==a)return a.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,n),o.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";function e(){return e=Object.assign?Object.assign.bind():function(e){for(var t=1;t(((e,n,r)=>{const{onPaymentSetup:a}=n;(0,t.useEffect)((()=>a((()=>{const t={payment_method:r.key};return{type:e.responseTypes.SUCCESS,meta:{paymentMethodData:t}}}))),[a,r])})(e,n,r),(0,t.createElement)(t.Fragment,null,(0,t.createElement)("p",{className:"pagarme-payment-method-instructions"},r.instructions),(0,t.createElement)("p",{className:"pagarme-payment-method-logo"},(0,t.createElement)("img",{className:"logo",src:r.logo,alt:r.label,title:r.label}))));o.propTypes={emitResponse:a().object.isRequired,eventRegistration:a().object.isRequired,backendConfig:a().object.isRequired};const s=o,{registerPaymentMethod:c}=window.wc.wcBlocksRegistry,i=wc.wcSettings.getSetting("woo-pagarme-payments-pix_data"),p=n=>(0,t.createElement)(s,e({},n,{backendConfig:i})),l=({components:e})=>{const{PaymentMethodLabel:n}=e;return(0,t.createElement)(n,{text:i.label})};l.propTypes={components:a().object},c({name:i.name,label:(0,t.createElement)(l,null),content:(0,t.createElement)(p,null),edit:(0,t.createElement)(p,null),canMakePayment:()=>!0,ariaLabel:i.ariaLabel})})()})(); \ No newline at end of file diff --git a/composer.json b/composer.json index 81571d8b..877f8fe5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "pagarme/woocommerce-pagarme-payments", "description": "Pagar.me module for Woocommerce", "type": "wordpress-plugin", - "version": "3.3.3", + "version": "3.4.0", "license": "GPL", "autoload": { "psr-4": { @@ -22,7 +22,7 @@ ], "require": { "mashape/unirest-php": "^3.0", - "pagarme/ecommerce-module-core": "~2.4.1", + "pagarme/ecommerce-module-core": "2.6.0", "psr/log": "1.1.4", "monolog/monolog": "<2", "haydenpierce/class-finder": "^0.5.3" diff --git a/constants.php b/constants.php index 446aa791..afeea9f2 100644 --- a/constants.php +++ b/constants.php @@ -12,7 +12,7 @@ function wc_pagarme_define($name, $value) wc_pagarme_define('WCMP_SLUG', 'woo-pagarme-payments'); wc_pagarme_define('WCMP_PREFIX', 'pagarme'); -wc_pagarme_define('WCMP_VERSION', '3.3.3'); +wc_pagarme_define('WCMP_VERSION', '3.4.0'); wc_pagarme_define('WCMP_ROOT_PATH', dirname(__FILE__) . '/'); wc_pagarme_define('WCMP_ROOT_SRC', WCMP_ROOT_PATH . 'src/'); wc_pagarme_define('WCMP_ROOT_FILE', WCMP_ROOT_PATH . WCMP_SLUG . '.php'); diff --git a/languages/woo-pagarme-payments-pt_BR.mo b/languages/woo-pagarme-payments-pt_BR.mo index 39322a66..0ac64586 100644 Binary files a/languages/woo-pagarme-payments-pt_BR.mo and b/languages/woo-pagarme-payments-pt_BR.mo differ diff --git a/languages/woo-pagarme-payments-pt_BR.po b/languages/woo-pagarme-payments-pt_BR.po index 73c1cfcf..03a5be28 100644 --- a/languages/woo-pagarme-payments-pt_BR.po +++ b/languages/woo-pagarme-payments-pt_BR.po @@ -5,7 +5,7 @@ msgstr "" "Project-Id-Version: WooCommerce Pagar.me Payments 1.0\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/woo-pagarme-payments\n" "POT-Creation-Date: 2018-06-22 13:58-0300\n" -"PO-Revision-Date: 2024-07-03 15:55-0300\n" +"PO-Revision-Date: 2024-10-01 09:55-0300\n" "Last-Translator: Pagar.me\n" "Language-Team: \n" "Language: pt_BR\n" @@ -13,7 +13,7 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Generator: Poedit 3.4.3\n" +"X-Generator: Poedit 3.5\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:1,2;_x:1,2c;_ex:1,2c;" "_nx:4c,1,2;_nx_noop:4c,1,2\n" @@ -1124,14 +1124,17 @@ msgstr "Cartão de Crédito" msgid "2 Cards" msgstr "2 Cartões" +msgid "Googlepay" +msgstr "Google Pay" + msgid "Amount" msgstr "Total" msgid "Billet And Card" msgstr "Boleto e Cartão" -msgid "Pagar.me - Capture/Cancellation" -msgstr "Pagar.me - Captura/Cancelamento" +msgid "Pagar.me - Charges" +msgstr "Pagar.me - Cobranças" msgid "Last Four Digits" msgstr "Últimos quatro dígitos" @@ -1142,9 +1145,18 @@ msgstr "Titular" msgid "No records found." msgstr "Nenhum registro foi encontrado." +msgid "Created At" +msgstr "Criado Em" + +msgid "Charge ID" +msgstr "ID da Cobrança" + msgid "Refunded" msgstr "Reembolsado" +msgid "Capture" +msgstr "Capturar" + msgid "Captured" msgstr "Capturado" @@ -1464,13 +1476,6 @@ msgstr "O mês de expiração do cartão deve estar entre 01 e 12." msgid "Pagar.me: Payment failed." msgstr "Pagar.me: Pagamento falhou." -msgid "" -"Attention! It is now possible to use Woocommerce's automatic refund flow. Soon, this button will be " -"dedicated to manual capture only." -msgstr "" -"Atenção! Já é possível utilizar o fluxo de reembolso automático do Woocommerce. Em breve, este botão " -"será dedicado somente a captura manual." - msgid "There was a problem attempting to refund: %1$s" msgstr "Ocorreu um problema ao tentar reembolsar: %1$s" @@ -1482,3 +1487,31 @@ msgstr "A cobrança %s foi totalmente reembolsada." msgid "Charge %1$s was partially refunded. Amount: %2$s" msgstr "A cobrança %1$s foi parcialmente reembolsada. Valor: %2$s" + +msgid "" +"

You may have filled in one or more details incorrectly.

Try to fill in the details exactly as they appear on " +"your card or bank app to complete the payment." +msgstr "" +"

Você pode ter preenchido um ou mais dados incorretamente.

Tente preencher os dados exatamente como aparecem no " +"cartão ou app do banco para conclusão do pagamento." + +msgid "Error processing payment. Please try again later." +msgstr "Erro ao processar o pagamento. Por favor tente novamente mais tarde." + +msgid "Or pay with card" +msgstr "Ou pague com cartão" + +msgid "Check the Pagar.me Dashboard at: Settings → Keys → Account ID" +msgstr "Consulte na Dashboard Pagar.me em: Configurações → Chaves → ID da Conta" + +msgid "Google Merchant Identifier, get yours here." +msgstr "Identificador de comerciante do Google, adquira o seu aqui" + +msgid "Your store name that will be displayed to the customer while purchasing through Google Pay." +msgstr "Nome da sua loja que será exibido ao cliente enquanto compra através do Google Pay." + +msgid "Store name on Google Pay" +msgstr "Nome da loja na Google Pay" + +msgid "Pagar.me account ID" +msgstr "ID da conta Pagar.me" diff --git a/package.json b/package.json index 9bf92dce..3632d998 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "woo-pagarme-payments", - "version": "3.3.3", + "version": "3.4.0", "description": "Pagar.me module for Woocommerce", "main": "woo-pagarme-payments.php", "devDependencies": { - "@woocommerce/dependency-extraction-webpack-plugin": "^2.3.0", + "@woocommerce/dependency-extraction-webpack-plugin": "*", "@wordpress/components": "^26.0.0", "@wordpress/data": "^9.22.0", "@wordpress/i18n": "^4.55.0", - "@wordpress/scripts": "^27.1.0", + "@wordpress/scripts": "^19.2.4", "grunt": "^1.0.1", "grunt-concurrent": "^2.3.1", "grunt-contrib-concat": "^1.0.1", @@ -16,7 +16,7 @@ "grunt-contrib-uglify": "^3.1.0", "grunt-contrib-watch": "^1.0.0", "grunt-wp-i18n": "^1.0.0", - "load-grunt-config": "^0.19.2", + "load-grunt-config": "^4.0.1", "load-grunt-tasks": "^3.5.2", "node-wp-i18n": "^1.2.0", "prop-types": "^15.8.1", @@ -27,5 +27,8 @@ "makepot": "yarn wpi18n makepot --exclude=node_modules,vendor", "build": "wp-scripts build", "start": "wp-scripts start" + }, + "dependencies": { + "@google-pay/button-react": "^3.1.0" } } diff --git a/readme.txt b/readme.txt index 2adbb501..fdc61ca6 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: payment, pagarme, ecommerce, brasil, woocommerce Requires at least: 4.1 Tested up to: 6.5.5 Requires PHP: 7.1 -Stable tag: 3.3.3 +Stable tag: 3.4.0 License: MIT License URI: https://github.com/pagarme/woocommerce/blob/master/LICENSE @@ -25,6 +25,21 @@ Nosso processo de instalação é simples e bem detalhado: == Changelog == Lançamos versões regularmente com melhorias, correções e atualizações. += 3.4.0 (01/10/2024) = +Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.4.0) + +* **Novas funcionalidades:** + * Meio de pagamento Google Pay. + +* **Melhorias:** + * Passando pedido e meio de pagamento para o cálculo do split; + * Checkout assincrono; + + +* **Correções:** + * Link para desintregar chamando endpoint incorretamente + * Problemas com tokenização + = 3.3.3 (14/08/2024) = Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.3.3) @@ -34,11 +49,6 @@ Você pode conferir essas atualizações aqui: [Github](https://github.com/pagar * **Correções:** * Perdendo informação de bandeira ao trocar meios de pagamento no checkout -= 3.3.2 (03/07/2024) = -Você pode conferir essas atualizações aqui: [Github](https://github.com/pagarme/woocommerce/releases/tag/3.3.2) - -* **Correções:** - * Exibe uma parcela (à vista) quando o valor do carrinho é menor que a configuração de valor mínimo de parcelas == Upgrade Notice == -Nosso plugin agora é compatível com Woocommerce Subscriptions +Agora é possível transacionar Via Google Pay diff --git a/src/Action/OrderActions.php b/src/Action/OrderActions.php index 8700f285..254e6fe6 100644 --- a/src/Action/OrderActions.php +++ b/src/Action/OrderActions.php @@ -11,6 +11,7 @@ public function run() { add_filter('woocommerce_get_order_item_totals', array($this, 'showInstallmentFeesToCustomer'), 10, 3); add_action('woocommerce_admin_order_totals_after_tax', array($this, 'showInstallmentFeesAdmin')); + add_action( 'woocommerce_available_payment_gateways', array($this, 'removeGooglepayOnlyWhenNotProcessPaymentAction') ); } public function showInstallmentFeesAdmin($orderId) { @@ -51,4 +52,14 @@ public function showInstallmentFeesToCustomer($total_rows, $order, $tax_display) } return $total_rows; } + + public function removeGooglepayOnlyWhenNotProcessPaymentAction( $gateways ) { + if ( isset($_POST['payment_method']) && $_POST['payment_method'] == 'woo-pagarme-payments-googlepay') { + return $gateways; + } + if(isset($gateways[ "woo-pagarme-payments-googlepay" ])) { + unset( $gateways[ "woo-pagarme-payments-googlepay" ] ); + } + return $gateways; + } } diff --git a/src/Block/AbstractBlock.php b/src/Block/AbstractBlock.php index f2de7db0..1245b3c6 100644 --- a/src/Block/AbstractBlock.php +++ b/src/Block/AbstractBlock.php @@ -116,11 +116,17 @@ public function enqueue_scripts($scripts = null, $deps = []) public function getScriptUrl($jsFileName) { + if(filter_var($jsFileName, FILTER_VALIDATE_URL)) { + return $jsFileName; + } return Core::plugins_url('assets/javascripts/' . $this->areaCode . '/' . $jsFileName . '.js'); } public function getScriptVer($jsFileName) { + if(filter_var($jsFileName, FILTER_VALIDATE_URL)) { + return date("Ymd"); + } return Core::filemtime('assets/javascripts/' . $this->areaCode . '/' . $jsFileName . '.js'); } } diff --git a/src/Block/Adminhtml/Sales/Order/MetaBox/ChargeActions.php b/src/Block/Adminhtml/Sales/Order/MetaBox/ChargeActions.php index 8dd09b1e..e1c2b710 100644 --- a/src/Block/Adminhtml/Sales/Order/MetaBox/ChargeActions.php +++ b/src/Block/Adminhtml/Sales/Order/MetaBox/ChargeActions.php @@ -11,10 +11,13 @@ namespace Woocommerce\Pagarme\Block\Adminhtml\Sales\Order\MetaBox; +use Exception; use Pagarme\Core\Kernel\Aggregates\Charge; +use Pagarme\Core\Kernel\Services\ChargeService; use Woocommerce\Pagarme\Block\Adminhtml\Sales\Order\AbstractMetaBox; use Woocommerce\Pagarme\Block\Adminhtml\Sales\Order\MetaBoxInterface; use Woocommerce\Pagarme\Helper\Utils; +use Woocommerce\Pagarme\Model\Config; use Woocommerce\Pagarme\Model\Order; use Woocommerce\Pagarme\Model\Serialize\Serializer\Json; @@ -33,7 +36,10 @@ class ChargeActions extends AbstractMetaBox implements MetaBoxInterface protected $sortOrder = 1; /** @var int */ - protected $title = 'Pagar.me - Capture/Cancellation'; + protected $title = 'Pagar.me - Charges'; + + /** @var Config */ + private $config; /** * @var Order @@ -58,13 +64,15 @@ public function __construct( Json $jsonSerialize = null, array $data = [], Order $order = null, - \Woocommerce\Pagarme\Model\Charge $charge = null + \Woocommerce\Pagarme\Model\Charge $charge = null, + Config $config = null ) { parent::__construct($jsonSerialize, $data); try { $this->order = $order ?? new Order($this->getOrderId()); } catch (\Exception $e) {} $this->charge = $charge ?? new \Woocommerce\Pagarme\Model\Charge; + $this->config = $config ?? new Config(); } /** @@ -90,16 +98,28 @@ private function getOrderId() } /** - * @return false|Charge + * @return Charge[]|null + * @throws Exception */ - public function getCharges() + public function getCharges($orderCode) { - if ($this->getOrder()) { - return $this->getOrder()->get_charges(); + $chargeService = new ChargeService(); + if ($orderCode) { + return $chargeService->findChargesByCode($orderCode); } + return null; } + public function getChargeUrl($chargeID) + { + if (!$this->config->isAccAndMerchSaved()) { + return false; + } + + return $this->config->getDashUrl() . 'charges/' . $chargeID; + } + /** * @return array */ @@ -114,6 +134,7 @@ private function getRequest() public function getHeaderGrid() { return [ + 'Created At', 'Charge ID', 'Type', "Total Amount", diff --git a/src/Block/Checkout/Form/GooglePay.php b/src/Block/Checkout/Form/GooglePay.php new file mode 100644 index 00000000..9504fb3a --- /dev/null +++ b/src/Block/Checkout/Form/GooglePay.php @@ -0,0 +1,38 @@ + $this->name, 'key' => static::PAYMENT_METHOD_KEY, - 'label' => $this->settings['title'], + 'label' => $this->paymentModel->getName() , 'ariaLabel' => __( static::ARIA_LABEL, 'woo-pagarme-payments' ) ]; diff --git a/src/Block/ReactCheckout/GooglePay.php b/src/Block/ReactCheckout/GooglePay.php new file mode 100644 index 00000000..794df740 --- /dev/null +++ b/src/Block/ReactCheckout/GooglePay.php @@ -0,0 +1,41 @@ +config = new Config; + $paymentModel = new GooglePayModel(); + parent::__construct($paymentModel); + } + + public function getAdditionalPaymentMethodData() + { + return [ + 'accountId' => $this->config->getAccountId(), + 'merchantName' => $this->config->getGooglepayGoogleMerchantName(), + 'merchantId' => $this->config->getGooglepayGoogleMerchantId(), + 'isSandboxMode' => $this->config->getIsSandboxMode() + ]; + } +} diff --git a/src/Concrete/WoocommerceCoreSetup.php b/src/Concrete/WoocommerceCoreSetup.php index b2fafa07..b0824955 100644 --- a/src/Concrete/WoocommerceCoreSetup.php +++ b/src/Concrete/WoocommerceCoreSetup.php @@ -108,6 +108,7 @@ public function loadModuleConfigurationFromPlatform() $configData = self::fillWithVoucherConfig($configData, $storeConfig); $configData = self::fillWithHubConfig($configData, $storeConfig); $configData = self::fillWithMarketplaceConfig($configData); + $configData = self::fillWithGooglePayConfig($configData, $storeConfig); // These method calls are commented for now because they are not implemented yet: // $configData = self::fillWithAddressConfig($configData, $storeConfig); @@ -209,6 +210,23 @@ private static function fillWithPixConfig($dataObj, $storeConfig) return $dataObj; } + private static function fillWithGooglePayConfig($dataObj, $storeConfig) + { + $googlePayConfig = new \stdClass(); + $googlePayConfig->enabled = filter_var( + $storeConfig->getEnableGooglepay(), + FILTER_VALIDATE_BOOLEAN + ); + $googlePayConfig->merchantId = $storeConfig->getGooglepayGoogleMerchantId(); + $googlePayConfig->merchantName = $storeConfig->getGooglepayGoogleMerchantName(); + $googlePayConfig->accountId = $storeConfig->getAccountId(); + + $dataObj->googlePayConfig = $googlePayConfig; + + return $dataObj; + } + + private static function fillWithBoletoConfig($dataObj, $storeConfig) { $dataObj->boletoEnabled = $storeConfig->getEnableBillet(); @@ -259,7 +277,7 @@ private static function fillWithGeneralConfig($dataObj, $storeConfig) $dataObj->testMode = $storeConfig->getIsSandboxMode(); $dataObj->allowNoAddress = $storeConfig->getAllowNoAddress(); $dataObj->sendMail = false; - $dataObj->createOrder = false; + $dataObj->createOrder = true; if (self::$moduleConfig !== null) { $oldStoreId = self::$moduleConfig->getStoreId(); diff --git a/src/Concrete/WoocommercePlatformOrderDecorator.php b/src/Concrete/WoocommercePlatformOrderDecorator.php index c44dec4f..87e16c61 100644 --- a/src/Concrete/WoocommercePlatformOrderDecorator.php +++ b/src/Concrete/WoocommercePlatformOrderDecorator.php @@ -705,6 +705,17 @@ private function isVoucherPayment() return $payment['payment_method'] === 'voucher'; } + private function isGooglepayPayment() + { + if (count($this->paymentInformation) > 1) { + return false; + } + + $payment = $this->paymentInformation[0]; + + return $payment['payment_method'] === 'googlepay'; + } + private function getPaymentHandler() { if (count($this->paymentInformation) > 1) { @@ -734,9 +745,34 @@ private function getPaymentHandler() return 'Voucher'; } + if ($this->isGooglepayPayment()) { + return 'Googlepay'; + } + return null; } + private function extractPaymentDataFromGooglepay( + &$paymentData + ) { + $newPaymentData = new stdClass(); + $moneyService = new MoneyService(); + $cleanJson = $this->formData['googlepay']['token']; + if(!json_decode($this->formData['googlepay']['token'])) { + $cleanJson = stripslashes($this->formData['googlepay']['token']); + } + $newPaymentData->amount = $moneyService->floatToCents($this->getGrandTotal()); + $newPaymentData->googlepayData = $cleanJson; + $newPaymentData->billing_address = $this->getCustomer()?->getAddress()?->convertToSDKRequest(); + $newPaymentData->additionalInformation = ["googlepayData" => $cleanJson]; + $googlepayIndex = 'googlepay'; + if (!isset($paymentData[$googlepayIndex])) { + $paymentData[$googlepayIndex] = []; + } + + $paymentData[$googlepayIndex][] = $newPaymentData; + } + private function extractPaymentDataFromCreditCard( &$paymentData ) { @@ -1125,7 +1161,7 @@ protected function getAddress($platformAddress) $address = new Address(); - $this->validateAddressFields($platformAddress); + $this->validateAddressFields($platformAddress); $address->setStreet($platformAddress["street"]); $address->setNumber($platformAddress["number"]); diff --git a/src/Concrete/WoocommercePlatformPaymentMethodDecorator.php b/src/Concrete/WoocommercePlatformPaymentMethodDecorator.php index c2f07b3b..ac2dcdea 100644 --- a/src/Concrete/WoocommercePlatformPaymentMethodDecorator.php +++ b/src/Concrete/WoocommercePlatformPaymentMethodDecorator.php @@ -15,6 +15,8 @@ class WoocommercePlatformPaymentMethodDecorator implements PlatformPaymentMethod /** @var string */ const PIX = "pix"; + /** @var string */ + const GOOGLEPAY = "googlepay"; private $paymentMethod; @@ -61,4 +63,9 @@ private function getPix() { return self::PIX; } + + private function getGooglepay() + { + return self::GOOGLEPAY; + } } diff --git a/src/Controller/Gateways/AbstractGateway.php b/src/Controller/Gateways/AbstractGateway.php index 82b20728..e4096556 100644 --- a/src/Controller/Gateways/AbstractGateway.php +++ b/src/Controller/Gateways/AbstractGateway.php @@ -3,33 +3,33 @@ * @author Open Source Team * @copyright 2022 Pagar.me (https://pagar.me) * @license https://pagar.me Copyright - * * @link https://pagar.me */ -declare(strict_types=1); +declare(strict_types = 1); namespace Woocommerce\Pagarme\Controller\Gateways; -use WP_Error; use Exception; use WC_Admin_Settings; use WC_Payment_Gateway; +use Woocommerce\Pagarme\Block\Checkout\Gateway as GatewayBlock; +use Woocommerce\Pagarme\Block\Order\EmailPaymentDetails; +use Woocommerce\Pagarme\Block\Template; +use Woocommerce\Pagarme\Controller\Gateways\Exceptions\InvalidOptionException; use Woocommerce\Pagarme\Core; -use Woocommerce\Pagarme\Model\Order; use Woocommerce\Pagarme\Helper\Utils; -use Woocommerce\Pagarme\Model\Config; use Woocommerce\Pagarme\Model\Charge; -use Woocommerce\Pagarme\Model\Gateway; use Woocommerce\Pagarme\Model\Checkout; -use Woocommerce\Pagarme\Block\Template; -use Woocommerce\Pagarme\Model\Subscription; -use Woocommerce\Pagarme\Model\WooOrderRepository; +use Woocommerce\Pagarme\Model\Config; use Woocommerce\Pagarme\Model\Config\Source\Yesno; +use Woocommerce\Pagarme\Model\Gateway; +use Woocommerce\Pagarme\Model\Order; +use Woocommerce\Pagarme\Model\Payment\CreditCard; use Woocommerce\Pagarme\Model\Payment\PostFormatter; -use Woocommerce\Pagarme\Block\Order\EmailPaymentDetails; -use Woocommerce\Pagarme\Block\Checkout\Gateway as GatewayBlock; -use Woocommerce\Pagarme\Controller\Gateways\Exceptions\InvalidOptionException; +use Woocommerce\Pagarme\Model\Subscription; +use Woocommerce\Pagarme\Model\WooOrderRepository; +use WP_Error; defined('ABSPATH') || exit; @@ -51,13 +51,13 @@ abstract class AbstractGateway extends WC_Payment_Gateway /** @var string */ const PAYMENT_OPTION_UPDATE_SLUG = 'woocommerce_update_options_payment_gateways_'; - /** @var string */ + /** @var string */ const PAYMENT_OPTIONS_SETTINGS_NAME = 'woocommerce_%s_settings'; - /** @var array */ + /** @var array */ const LEGACY_SETTINGS_NAME = []; - /** @var array */ + /** @var array */ const LEGACY_SETTINGS_NEEDS_CONVERSION = []; const LEGACY_CONFIG_NAME = ""; @@ -86,7 +86,7 @@ abstract class AbstractGateway extends WC_Payment_Gateway /** @var GatewayBlock */ private $gatewayBlock; - /** @var Template*/ + /** @var Template */ private $template; /** @var Yesno */ @@ -145,7 +145,7 @@ public function __construct( add_action('woocommerce_receipt_' . $this->id, array($this, 'receipt_page')); add_action('woocommerce_thankyou_' . $this->id, [$this, 'thank_you_page']); add_action('admin_enqueue_scripts', array($this, 'payments_scripts')); - add_action('woocommerce_email_after_order_table', [$this, 'pagarme_email_payment_info'], 15, 2 ); + add_action('woocommerce_email_after_order_table', [$this, 'pagarme_email_payment_info'], 15, 2); $this->subscription = new Subscription($this); $this->addRefundSupport(); } @@ -181,10 +181,11 @@ public function jsUrl($jsFileName) /** * @param $orderId - * @return array + * + * @return array|null * @throws Exception */ - public function process_payment($orderId): array + public function process_payment($orderId) { $wooOrder = $this->wooOrderRepository->getById($orderId); if ($this->subscription->isChangePaymentSubscription()) { @@ -196,11 +197,28 @@ public function process_payment($orderId): array if ($this->subscription->hasSubscriptionFreeTrial()) { return $this->subscription->processFreeTrialSubscription($wooOrder); } - $this->checkout->process($wooOrder); - return [ - 'result' => 'success', - 'redirect' => $this->get_return_url($wooOrder) - ]; + + $process = $this->checkout->process($wooOrder); + if ($process) { + return [ + 'result' => 'success', + 'redirect' => $this->get_return_url($wooOrder) + ]; + } + + $errorMessage = $this->method == CreditCard::PAYMENT_CODE ? __( + '

You may have filled in one or more details incorrectly.

Try to fill in the details exactly as they ' + . 'appear on your card or bank app to complete the payment.', + 'woo-pagarme-payments' + ) : __('Error processing payment. Please try again later.', 'woo-pagarme-payments'); + + if (Utils::isCheckoutBlock()) { + wp_die($errorMessage, 'error'); + } + + wc_add_notice($errorMessage, 'error'); + + return null; } /** @@ -215,6 +233,7 @@ public function payment_fields() /** * @param $orderId + * * @return void */ public function receipt_page($orderId) @@ -224,6 +243,7 @@ public function receipt_page($orderId) /** * @param $order_id + * * @return void */ public function checkout_transparent($order_id) @@ -234,6 +254,7 @@ public function checkout_transparent($order_id) /** * @param $order_id + * * @return void * @throws Exception */ @@ -246,10 +267,10 @@ public function thank_you_page($order_id) '\Woocommerce\Pagarme\Block\Checkout\ThankYou', 'pagarme.checkout.thank-you', [ - 'woo_order' => $order, - 'pagarme_order' => $pagarmeOrder, + 'woo_order' => $order, + 'pagarme_order' => $pagarmeOrder, 'payment_method' => $this->method, - 'container' => true + 'container' => true ] )->toHtml(); } @@ -292,6 +313,7 @@ public function getTitle() if ($title = $this->get_option('title')) { return $title; } + return $this->getPaymentMethodTitle(); } @@ -333,6 +355,7 @@ private function append_gateway_form_fields() if ($this->isGatewayType()) { return $this->gateway_form_fields(); } + return []; } @@ -353,6 +376,7 @@ public function isGatewayType() if (empty($isPaymentGateway) || !key_exists($this->method, $isPaymentGateway)) { return $this->model->config->getIsGatewayIntegrationType(); } + return $isPaymentGateway[$this->method]; } @@ -366,11 +390,11 @@ public function field_enabled() 'type' => 'select', 'options' => $this->yesnoOptions->toLabelsArray(true), 'label' => __('Enable', 'woo-pagarme-payments') . ' ' . - __($this->getPaymentMethodTitle(), 'woo-pagarme-payments'), + __($this->getPaymentMethodTitle(), 'woo-pagarme-payments'), 'default' => __( - $this->config->getData('enable_' . $this->method), - 'woo-pagarme-payments' - ) ?? strtolower(Yesno::NO), + $this->config->getData('enable_' . $this->method), + 'woo-pagarme-payments' + ) ?? strtolower(Yesno::NO), ]; } @@ -388,16 +412,19 @@ public function field_title() ]; } - protected function getOldTitleName() { + protected function getOldTitleName() + { return null; } + /** * @param string $fieldName + * * @return string */ protected function getOldConfiguration($fieldName) { - if($this->config->getData($fieldName)) { + if ($this->config->getData($fieldName)) { return $this->config->getData($fieldName); } $oldData = get_option($this::LEGACY_CONFIG_NAME); @@ -405,6 +432,7 @@ protected function getOldConfiguration($fieldName) if ($oldData !== false && $legacyFieldName !== false && array_key_exists($legacyFieldName, $oldData)) { return $this->getOldData($legacyFieldName, $fieldName, $oldData); } + return null; } @@ -417,18 +445,21 @@ protected function getOldData($legacyFieldName, $fieldName, $oldData) !empty($oldData[$legacyFieldName]) && in_array($fieldName, $this::LEGACY_SETTINGS_NEEDS_CONVERSION) ) { - $functionHandler = "convert".Utils::snakeToPascalCase($fieldName); + $functionHandler = "convert" . Utils::snakeToPascalCase($fieldName); + return $this->$functionHandler($oldData); } + return $oldData[$legacyFieldName]; } - + protected function getLegacyFieldsName($fieldName) { if (array_key_exists($fieldName, $this::LEGACY_SETTINGS_NAME)) { return $this::LEGACY_SETTINGS_NAME[$fieldName]; } + return false; } @@ -436,6 +467,7 @@ protected function getLegacyFieldsName($fieldName) * @param mixed $optionName * @param mixed $oldValue * @param mixed $values + * * @return void */ public function beforeUpdateAdminOptions($optionName, $oldValue, $values) @@ -451,6 +483,7 @@ public function beforeUpdateAdminOptions($optionName, $oldValue, $values) /** * @param mixed $optionName * @param mixed $values + * * @return void */ public function beforeAddAdminOptions($optionName, $values) @@ -465,6 +498,7 @@ public function beforeAddAdminOptions($optionName, $values) /** * @param array $values + * * @return void */ protected function saveAdminOptionsInCoreConfig($values) @@ -483,6 +517,7 @@ protected function saveAdminOptionsInCoreConfig($values) /** * @param mixed $order + * * @return void */ public function pagarme_email_payment_info($order, $sent_to_admin) diff --git a/src/Controller/Gateways/GooglePay.php b/src/Controller/Gateways/GooglePay.php new file mode 100644 index 00000000..6c265da4 --- /dev/null +++ b/src/Controller/Gateways/GooglePay.php @@ -0,0 +1,84 @@ +supports[] = 'refunds'; + } + /** + * @return array + */ + public function append_form_fields() + { + $fields = [ + 'account_id' => $this->field_account_id(), + 'googlepay_google_merchant_id' => $this->field_googlepay_google_merchant_id(), + 'googlepay_google_merchant_name' => $this->field_googlepay_google_merchant_name(), + ]; + return $fields; + } + + public function field_account_id() + { + return [ + 'title' => __('Pagar.me account ID', 'woo-pagarme-payments'), + 'default' => $this->config->getData('account_id') ?? '', + 'type' => 'text', + 'description' => __('Check the Pagar.me Dashboard at: Settings → Keys → Account ID', 'woo-pagarme-payments'), + ]; + } + + public function field_googlepay_google_merchant_id() + { + return [ + 'title' => __('MerchantId Google Pay', 'woo-pagarme-payments'), + 'default' => '', + 'type' => 'text', + 'description' => sprintf( + __( + 'Google Merchant Identifier, get yours here.', + 'woo-pagarme-payments' + ), + "https://pay.google.com/business/console/?hl=pt-br" + ), + ]; + } + + public function field_googlepay_google_merchant_name() + { + return [ + 'title' => __('Store name on Google Pay', 'woo-pagarme-payments'), + 'default' => '', + 'desc_tip' => true, + 'type' => 'text', + 'desc' => __( + 'Your store name that will be displayed to the customer while purchasing through Google Pay.', + 'woo-pagarme-payments' + ), + ]; + } +} diff --git a/src/Controller/Hub.php b/src/Controller/Hub.php index 09a34a2f..1033591c 100644 --- a/src/Controller/Hub.php +++ b/src/Controller/Hub.php @@ -66,16 +66,13 @@ public function updateConfig() $moduleConfig->getPublicKey()->getValue() ); - $this->settings->setData( - 'account_id', - $moduleConfig->getAccountId()->getValue() - ); - $this->settings->setData( 'merchant_id', $moduleConfig->getMerchantId()->getValue() ); + $this->settings->setAccountId($moduleConfig->getAccountId()->getValue()); + $this->settings->setData('sandbox_secret_key', null); $this->settings->setData('sandbox_public_key', null); $this->settings->setData('environment', null); diff --git a/src/Helper/Utils.php b/src/Helper/Utils.php index e4817ffb..c1c74a62 100644 --- a/src/Helper/Utils.php +++ b/src/Helper/Utils.php @@ -6,6 +6,7 @@ exit(0); } +use WC_Blocks_Utils; use WC_Order; use Woocommerce\Pagarme\Core; use Woocommerce\Pagarme\Model\Order; @@ -594,4 +595,15 @@ public static function snakeToPascalCase($value) { return ucfirst(str_replace('_', '', ucwords($value, '_'))); } + + /** + * @return bool + */ + public static function isCheckoutBlock() { + if (!class_exists(WC_Blocks_Utils::class)) { + return false; + } + + return WC_Blocks_Utils::has_block_in_page(wc_get_page_id('checkout'), 'woocommerce/checkout'); + } } diff --git a/src/Model/Checkout.php b/src/Model/Checkout.php index 8df4a3e4..e684f52f 100644 --- a/src/Model/Checkout.php +++ b/src/Model/Checkout.php @@ -141,8 +141,8 @@ public function process(WC_Order $wc_order = null, string $type = CheckoutTypes: $order->update_meta('payment_method', $fields['payment_method']); $order->update_meta("attempts", $attempts); $this->addAuthenticationOnMetaData($order, $fields); - WC()->cart->empty_cart(); if ($response) { + WC()->cart->empty_cart(); do_action("on_pagarme_response", $wc_order->get_id(), $response); $order->update_meta('transaction_id', $response->getPagarmeId()->getValue()); $order->update_meta('pagarme_id', $response->getPagarmeId()->getValue()); @@ -204,11 +204,17 @@ private function convertCheckoutObject(PaymentRequestInterface $paymentRequest) $fields['pagarmetoken' . $key] = $card->getToken(); } } + $this->extractGooglePayToken($fields, $paymentRequest); $this->extractMulticustomers($fields, $paymentRequest); $this->extractOrderValue($fields, $paymentRequest); return $fields; } + private function extractGooglePayToken(&$fields, $paymentRequest) + { + $fields['googlepay']['token'] = $paymentRequest->getDataByKey('googlepay'); + } + private function addInstallmentsOnMetaData(&$order, $fields) { if (!array_key_exists("installments", $fields)) { diff --git a/src/Model/Config.php b/src/Model/Config.php index c5723567..65fb1123 100644 --- a/src/Model/Config.php +++ b/src/Model/Config.php @@ -203,6 +203,12 @@ public function isAccAndMerchSaved() : bool { return $this->getMerchantId() && $this->getAccountId(); } + public function setAccountId($accountId) + { + $this->setData('account_id', $accountId); + $this->updateGooglepayAccountId($accountId); + } + /** * @return mixed */ @@ -366,6 +372,15 @@ public function getTdsMinAmount() return $moneyService->centsToFloat($tdsMinAmount); } + private function updateGooglepayAccountId($accountId) + { + $googlepayOption = get_option( 'woocommerce_woo-pagarme-payments-googlepay_settings' ); + if(is_array($googlepayOption)) { + $googlepayOption['account_id'] = $accountId; + update_option( 'woocommerce_woo-pagarme-payments-googlepay_settings', $googlepayOption ); + } + } + public function isAnyBilletMethodEnabled() { return $this->isBilletEnabled() diff --git a/src/Model/Payment/Data/Googlepay.php b/src/Model/Payment/Data/Googlepay.php new file mode 100644 index 00000000..992e9a0c --- /dev/null +++ b/src/Model/Payment/Data/Googlepay.php @@ -0,0 +1,69 @@ +multicustomers = $multicustomers ?? new Multicustomers; + $this->init(); + } + + protected function init() { + $this->{$this->getMethod('token')}($this->getPostPaymentContent()['googlepay']['payload']); + } + + protected function setToken($data) + { + $this->setData('token', $data); + return $this->token = $data; + } + + public function getToken() + { + return $this->token; + } + /** + * @param $data + * @return $this + */ + public function setMulticustomers($data) + { + if ($this->havePaymentForm(Multicustomers::FIELD) && $this->multicustomers->isEnable($data)) { + return $this->setData(Multicustomers::FIELD, $this->multicustomers->setData($data)); + } + return $this; + } +} diff --git a/src/Model/Payment/Data/PaymentRequest.php b/src/Model/Payment/Data/PaymentRequest.php index 128761e4..cc80cbe9 100644 --- a/src/Model/Payment/Data/PaymentRequest.php +++ b/src/Model/Payment/Data/PaymentRequest.php @@ -39,6 +39,9 @@ class PaymentRequest extends AbstractPayment implements PaymentRequestInterface /** @var Pix */ private $pix; + /** @var Googlepay */ + private $googlepay; + /** * @param ShippingAddress|null $shippingAddress * @param BillingAddress|null $billingAddress @@ -47,6 +50,7 @@ class PaymentRequest extends AbstractPayment implements PaymentRequestInterface * @param Json|null $jsonSerialize * @param Billet|null $billet * @param Pix|null $pix + * @param Googlepay|null $googlepay * @param array $data */ public function __construct( @@ -57,6 +61,7 @@ public function __construct( Json $jsonSerialize = null, Billet $billet = null, Pix $pix = null, + Googlepay $googlepay = null, array $data = [] ) { parent::__construct($jsonSerialize, $data); @@ -66,6 +71,7 @@ public function __construct( $this->billingAddress = $billingAddress ?? new BillingAddress; $this->billet = $billet ?? new Billet; $this->pix = $pix ?? new Pix; + $this->googlepay = $googlepay ?? new Googlepay; $this->init(); } @@ -81,6 +87,7 @@ protected function init() } } $this->setCards(); + $this->setGooglepayToken(); $this->setShippingAddress(); $this->setBillingAddress(); } @@ -177,4 +184,23 @@ public function setPix() } return $this; } + + public function setGooglepayToken() + { + if ($this->havePaymentForm(self::GOOGLEPAY, true)) { + return $this->setData(self::GOOGLEPAY, $this->googlepay->getToken()); + } + return $this; + } + + /** + * @return PaymentRequest + */ + public function setGooglepay() + { + if ($this->havePaymentForm(self::GOOGLEPAY, false)) { + return $this->setData(self::GOOGLEPAY, $this->googlepay->getToken()); + } + return $this; + } } diff --git a/src/Model/Payment/Data/PaymentRequestInterface.php b/src/Model/Payment/Data/PaymentRequestInterface.php index 020e7d01..57470df9 100644 --- a/src/Model/Payment/Data/PaymentRequestInterface.php +++ b/src/Model/Payment/Data/PaymentRequestInterface.php @@ -43,6 +43,9 @@ interface PaymentRequestInterface /** @var string */ const PIX = 'pix'; + /** @var string */ + const GOOGLEPAY = 'googlepay'; + /** * @param string $value * @return PaymentRequest diff --git a/src/Model/Payment/GooglePay.php b/src/Model/Payment/GooglePay.php new file mode 100644 index 00000000..5ee08bcc --- /dev/null +++ b/src/Model/Payment/GooglePay.php @@ -0,0 +1,41 @@ + 'token' + ]; +} diff --git a/src/Model/Subscription.php b/src/Model/Subscription.php index 394b26b5..0bb292e8 100644 --- a/src/Model/Subscription.php +++ b/src/Model/Subscription.php @@ -20,6 +20,7 @@ use WC_Order; use WC_Subscriptions_Product; use Woocommerce\Pagarme\Controller\Orders; +use Woocommerce\Pagarme\Helper\Utils; use Woocommerce\Pagarme\Service\LogService; use Woocommerce\Pagarme\Service\CardService; use Woocommerce\Pagarme\Service\CustomerService; @@ -301,7 +302,14 @@ private function createCreditCard($pagarmeCustomer) */ private function saveCardInSubscription(array $card, \WC_Subscription $subscription) { - $subscription->add_meta_data('_pagarme_payment_subscription', json_encode($card), true); + $key = '_pagarme_payment_subscription'; + $value = json_encode($card); + if (FeatureCompatibilization::isHposActivated()) { + $subscription->update_meta_data($key, Utils::rm_tags($value)); + $subscription->save(); + return; + } + update_metadata('post', $subscription->get_id(), $key, $value); $subscription->save(); } diff --git a/templates/adminhtml/sales/order/meta-box/charge-actions.phtml b/templates/adminhtml/sales/order/meta-box/charge-actions.phtml index 3f1ffaa3..f9deb1d9 100644 --- a/templates/adminhtml/sales/order/meta-box/charge-actions.phtml +++ b/templates/adminhtml/sales/order/meta-box/charge-actions.phtml @@ -16,13 +16,14 @@ use Woocommerce\Pagarme\Block\Adminhtml\Sales\Order\MetaBox\Modal; if (!function_exists('add_action')) { exit(0); } + +$charges = $this->getCharges($this->getOrder()->ID); ?> -getCharges()) : ?> +
-

- Attention! It is now possible to use Woocommerce's automatic refund flow. Soon, " - . "this button will be dedicated to manual capture only.", 'woo-pagarme-payments') ?> -

@@ -31,10 +32,24 @@ if (!function_exists('add_action')) { - getCharges() as $charge) : ?> + getLastTransaction()->getCreatedAt()->getTimestamp(); + $offsetTimestamp = $chargeTimestamp + $minutesOffset; + + $chargeID = $charge->getPagarmeId()->getValue(); + $chargeUrl = $this->getChargeUrl($chargeID); + if ($chargeUrl) { + $chargeID = sprintf( + '%s', + $chargeUrl, + $chargeID + ); + } + ?> - - + + + getTotals() as $total) : ?> createBlock( diff --git a/templates/adminhtml/system/config/form/field/hub/integration.phtml b/templates/adminhtml/system/config/form/field/hub/integration.phtml index 1bf5d9d0..371a0773 100644 --- a/templates/adminhtml/system/config/form/field/hub/integration.phtml +++ b/templates/adminhtml/system/config/form/field/hub/integration.phtml @@ -60,7 +60,7 @@ $success = 'Integration keys successfully removed. Reload the page.'; }); swal.showLoading(); $.ajax({ - url: '', + url: '', type: 'POST', dataType: "json", data: JSON.stringify({ diff --git a/templates/checkout/payment/credit-card.phtml b/templates/checkout/payment/credit-card.phtml index bd1381eb..805793c8 100644 --- a/templates/checkout/payment/credit-card.phtml +++ b/templates/checkout/payment/credit-card.phtml @@ -15,6 +15,28 @@ declare(strict_types=1); if (!function_exists('add_action')) { exit(0); } + +wp_localize_script( + WCMP_JS_HANDLER_BASE_NAME . 'googlepay', + 'wc_pagarme_googlepay', + [ + 'allowedCcFlags' => $this->getConfig()->getCcFlags(), + 'merchantName' => $this->getConfig()->getGooglepayGoogleMerchantName(), + 'merchantId' => $this->getConfig()->getGooglepayGoogleMerchantId(), + 'accountId' => $this->getConfig()->getAccountId(), + 'isSandboxMode' => $this->getConfig()->getIsSandboxMode() + ] +); + +if ( $this->getConfig()->getEnableGooglepay() == "yes" && !$this->hasSubscriptionProductInCart() ) : ?> +
+
+

+ +

+
+createBlock( '\Woocommerce\Pagarme\Block\Checkout\Form\Card', 'pagarme.checkout.form.card', diff --git a/tests/Concrete/WoocommerceCoreSetupTest.php b/tests/Concrete/WoocommerceCoreSetupTest.php index 9f5ea26e..6a3f994a 100644 --- a/tests/Concrete/WoocommerceCoreSetupTest.php +++ b/tests/Concrete/WoocommerceCoreSetupTest.php @@ -52,7 +52,8 @@ private function getMockForConfiguration() 'getMultimethods2Card', 'getMulticustomers', 'getEnablePix', - 'getEnableVoucher' + 'getEnableVoucher', + 'getEnableGooglepay' )->andReturn(true); $configMock->shouldReceive('getSecretKey')->andReturn('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); @@ -72,6 +73,9 @@ private function getMockForConfiguration() $configMock->shouldReceive('getBilletBank')->andReturn(001); $configMock->shouldReceive('getPixQrcodeExpirationTime')->andReturn(3600); $configMock->shouldReceive('getPixAdditionalData')->andReturn(null); + $configMock->shouldReceive('getAccountId')->andReturn(false); + $configMock->shouldReceive('getGooglepayGoogleMerchantId')->andReturn('BCXXXXXXXXXXX'); + $configMock->shouldReceive('getGooglepayGoogleMerchantName')->andReturn('TESTE'); $configMock->shouldReceive('getHubInstallId')->andReturn('XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'); $configMock->shouldReceive('getHubEnvironment')->andReturn('sandbox'); $config = new WoocommerceCoreSetup(); diff --git a/tests/Model/CheckoutTest.php b/tests/Model/CheckoutTest.php index deecd95f..a6410e90 100644 --- a/tests/Model/CheckoutTest.php +++ b/tests/Model/CheckoutTest.php @@ -77,6 +77,8 @@ public function testProcessWithTdsAuthenticatedCreditCardPaymentMethodShouldSetA ->andReturn([$cardMock]); $paymentRequestMock->shouldReceive('getData') ->andReturn([]); + $paymentRequestMock->shouldReceive('getDataByKey') + ->andReturn([]); $_POST[PaymentRequestInterface::PAGARME_PAYMENT_REQUEST_KEY] = $paymentRequestMock; diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index 7824d8f7..afef3fa2 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,37 +42,35 @@ */ class ClassLoader { - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var string|null */ + /** @var ?string */ private $vendorDir; // PSR-4 /** - * @var array> + * @var array[] + * @psalm-var array> */ private $prefixLengthsPsr4 = array(); /** - * @var array> + * @var array[] + * @psalm-var array> */ private $prefixDirsPsr4 = array(); /** - * @var list + * @var array[] + * @psalm-var array */ private $fallbackDirsPsr4 = array(); // PSR-0 /** - * List of PSR-0 prefixes - * - * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) - * - * @var array>> + * @var array[] + * @psalm-var array> */ private $prefixesPsr0 = array(); /** - * @var list + * @var array[] + * @psalm-var array */ private $fallbackDirsPsr0 = array(); @@ -80,7 +78,8 @@ class ClassLoader private $useIncludePath = false; /** - * @var array + * @var string[] + * @psalm-var array */ private $classMap = array(); @@ -88,29 +87,29 @@ class ClassLoader private $classMapAuthoritative = false; /** - * @var array + * @var bool[] + * @psalm-var array */ private $missingClasses = array(); - /** @var string|null */ + /** @var ?string */ private $apcuPrefix; /** - * @var array + * @var self[] */ private static $registeredLoaders = array(); /** - * @param string|null $vendorDir + * @param ?string $vendorDir */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); } /** - * @return array> + * @return string[] */ public function getPrefixes() { @@ -122,7 +121,8 @@ public function getPrefixes() } /** - * @return array> + * @return array[] + * @psalm-return array> */ public function getPrefixesPsr4() { @@ -130,7 +130,8 @@ public function getPrefixesPsr4() } /** - * @return list + * @return array[] + * @psalm-return array */ public function getFallbackDirs() { @@ -138,7 +139,8 @@ public function getFallbackDirs() } /** - * @return list + * @return array[] + * @psalm-return array */ public function getFallbackDirsPsr4() { @@ -146,7 +148,8 @@ public function getFallbackDirsPsr4() } /** - * @return array Array of classname => path + * @return string[] Array of classname => path + * @psalm-return array */ public function getClassMap() { @@ -154,7 +157,8 @@ public function getClassMap() } /** - * @param array $classMap Class to filename map + * @param string[] $classMap Class to filename map + * @psalm-param array $classMap * * @return void */ @@ -171,25 +175,24 @@ public function addClassMap(array $classMap) * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories * * @return void */ public function add($prefix, $paths, $prepend = false) { - $paths = (array) $paths; if (!$prefix) { if ($prepend) { $this->fallbackDirsPsr0 = array_merge( - $paths, + (array) $paths, $this->fallbackDirsPsr0 ); } else { $this->fallbackDirsPsr0 = array_merge( $this->fallbackDirsPsr0, - $paths + (array) $paths ); } @@ -198,19 +201,19 @@ public function add($prefix, $paths, $prepend = false) $first = $prefix[0]; if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = $paths; + $this->prefixesPsr0[$first][$prefix] = (array) $paths; return; } if ($prepend) { $this->prefixesPsr0[$first][$prefix] = array_merge( - $paths, + (array) $paths, $this->prefixesPsr0[$first][$prefix] ); } else { $this->prefixesPsr0[$first][$prefix] = array_merge( $this->prefixesPsr0[$first][$prefix], - $paths + (array) $paths ); } } @@ -219,9 +222,9 @@ public function add($prefix, $paths, $prepend = false) * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException * @@ -229,18 +232,17 @@ public function add($prefix, $paths, $prepend = false) */ public function addPsr4($prefix, $paths, $prepend = false) { - $paths = (array) $paths; if (!$prefix) { // Register directories for the root namespace. if ($prepend) { $this->fallbackDirsPsr4 = array_merge( - $paths, + (array) $paths, $this->fallbackDirsPsr4 ); } else { $this->fallbackDirsPsr4 = array_merge( $this->fallbackDirsPsr4, - $paths + (array) $paths ); } } elseif (!isset($this->prefixDirsPsr4[$prefix])) { @@ -250,18 +252,18 @@ public function addPsr4($prefix, $paths, $prepend = false) throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); } $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = $paths; + $this->prefixDirsPsr4[$prefix] = (array) $paths; } elseif ($prepend) { // Prepend directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( - $paths, + (array) $paths, $this->prefixDirsPsr4[$prefix] ); } else { // Append directories for an already registered namespace. $this->prefixDirsPsr4[$prefix] = array_merge( $this->prefixDirsPsr4[$prefix], - $paths + (array) $paths ); } } @@ -270,8 +272,8 @@ public function addPsr4($prefix, $paths, $prepend = false) * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param list|string $paths The PSR-0 base directories + * @param string $prefix The prefix + * @param string[]|string $paths The PSR-0 base directories * * @return void */ @@ -288,8 +290,8 @@ public function set($prefix, $paths) * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param list|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param string[]|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException * @@ -423,8 +425,7 @@ public function unregister() public function loadClass($class) { if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); + includeFile($file); return true; } @@ -475,9 +476,9 @@ public function findFile($class) } /** - * Returns the currently registered loaders keyed by their corresponding vendor directories. + * Returns the currently registered loaders indexed by their corresponding vendor directories. * - * @return array + * @return self[] */ public static function getRegisteredLoaders() { @@ -554,26 +555,18 @@ private function findFileWithExtension($class, $ext) return false; } +} - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + * @private + */ +function includeFile($file) +{ + include $file; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 7a957026..cf4db599 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,5 +1,56 @@ { "packages": [ + { + "name": "antecedent/patchwork", + "version": "2.1.28", + "version_normalized": "2.1.28.0", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/6b30aff81ebadf0f2feb9268d3e08385cebcc08d", + "reference": "6b30aff81ebadf0f2feb9268d3e08385cebcc08d", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": ">=4" + }, + "time": "2024-02-06T09:26:11+00:00", + "type": "library", + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "https://antecedent.github.io/patchwork/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "support": { + "issues": "https://github.com/antecedent/patchwork/issues", + "source": "https://github.com/antecedent/patchwork/tree/2.1.28" + }, + "install-path": "../antecedent/patchwork" + }, { "name": "apimatic/jsonmapper", "version": "v1.3.1", @@ -120,6 +171,133 @@ }, "install-path": "../apimatic/unirest-php" }, + { + "name": "brain/monkey", + "version": "2.6.1", + "version_normalized": "2.6.1.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "a31c84515bb0d49be9310f52ef1733980ea8ffbb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/a31c84515bb0d49be9310f52ef1733980ea8ffbb", + "reference": "a31c84515bb0d49be9310f52ef1733980ea8ffbb", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.1.17", + "mockery/mockery": "^1.3.5 || ^1.4.4", + "php": ">=5.6.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1", + "phpcompatibility/php-compatibility": "^9.3.0", + "phpunit/phpunit": "^5.7.26 || ^6.0 || ^7.0 || >=8.0 <8.5.12 || ^8.5.14 || ^9.0" + }, + "time": "2021-11-11T15:53:55+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "inc/api.php" + ], + "psr-4": { + "Brain\\Monkey\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "support": { + "issues": "https://github.com/Brain-WP/BrainMonkey/issues", + "source": "https://github.com/Brain-WP/BrainMonkey" + }, + "install-path": "../brain/monkey" + }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.1", + "version_normalized": "2.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "reference": "8c3d0a3f6af734494ad8f6fbbee0ba92422859f3", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0|^8.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "^1.4 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0" + }, + "time": "2020-07-09T08:09:16+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "support": { + "issues": "https://github.com/hamcrest/hamcrest-php/issues", + "source": "https://github.com/hamcrest/hamcrest-php/tree/v2.0.1" + }, + "install-path": "../hamcrest/hamcrest-php" + }, { "name": "haydenpierce/class-finder", "version": "0.5.3", @@ -214,6 +392,92 @@ ], "install-path": "../mashape/unirest-php" }, + { + "name": "mockery/mockery", + "version": "1.6.12", + "version_normalized": "1.6.12.0", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "reference": "1f4efdd7d3beafe9807b08156dfcb176d18f1699", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "^2.0.1", + "lib-pcre": ">=7.0", + "php": ">=7.3" + }, + "conflict": { + "phpunit/phpunit": "<8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5 || ^9.6.17", + "symplify/easy-coding-standard": "^12.1.14" + }, + "time": "2024-05-16T03:13:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "library/helpers.php", + "library/Mockery.php" + ], + "psr-4": { + "Mockery\\": "library/Mockery" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "https://github.com/padraic", + "role": "Author" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "support": { + "docs": "https://docs.mockery.io/", + "issues": "https://github.com/mockery/mockery/issues", + "rss": "https://github.com/mockery/mockery/releases.atom", + "security": "https://github.com/mockery/mockery/security/advisories", + "source": "https://github.com/mockery/mockery" + }, + "install-path": "../mockery/mockery" + }, { "name": "monolog/monolog", "version": "1.27.1", @@ -303,25 +567,149 @@ ], "install-path": "../monolog/monolog" }, + { + "name": "myclabs/deep-copy", + "version": "1.12.0", + "version_normalized": "1.12.0.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "reference": "3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "doctrine/collections": "<1.6.8", + "doctrine/common": "<2.13.3 || >=3 <3.2.2" + }, + "require-dev": { + "doctrine/collections": "^1.6.8", + "doctrine/common": "^2.13.3 || ^3.2.2", + "phpspec/prophecy": "^1.10", + "phpunit/phpunit": "^7.5.20 || ^8.5.23 || ^9.5.13" + }, + "time": "2024-06-12T14:39:25+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/DeepCopy/deep_copy.php" + ], + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.12.0" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "install-path": "../myclabs/deep-copy" + }, + { + "name": "nikic/php-parser", + "version": "v5.1.0", + "version_normalized": "5.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "reference": "683130c2ff8c2739f4822ff7ac5c873ec529abd1", + "shasum": "" + }, + "require": { + "ext-ctype": "*", + "ext-json": "*", + "ext-tokenizer": "*", + "php": ">=7.4" + }, + "require-dev": { + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^9.0" + }, + "time": "2024-07-01T20:03:41+00:00", + "bin": [ + "bin/php-parse" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpParser\\": "lib/PhpParser" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Nikita Popov" + } + ], + "description": "A PHP parser written in PHP", + "keywords": [ + "parser", + "php" + ], + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v5.1.0" + }, + "install-path": "../nikic/php-parser" + }, { "name": "pagarme/ecommerce-module-core", - "version": "2.4.1", - "version_normalized": "2.4.1.0", + "version": "2.6.0", + "version_normalized": "2.6.0.0", "source": { "type": "git", "url": "https://github.com/pagarme/ecommerce-module-core.git", - "reference": "3e75e5365882c6806f2ac76e6901ee17815d101e" + "reference": "83eff7118a3a6ead781a920d2fa42b6a186105d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pagarme/ecommerce-module-core/zipball/3e75e5365882c6806f2ac76e6901ee17815d101e", - "reference": "3e75e5365882c6806f2ac76e6901ee17815d101e", + "url": "https://api.github.com/repos/pagarme/ecommerce-module-core/zipball/83eff7118a3a6ead781a920d2fa42b6a186105d2", + "reference": "83eff7118a3a6ead781a920d2fa42b6a186105d2", "shasum": "" }, "require": { "ext-json": "*", "monolog/monolog": "<3", - "pagarme/pagarmecoreapi": "v5.6.4", + "pagarme/pagarmecoreapi": "v5.6.5", "php": ">=7.1" }, "require-dev": { @@ -330,7 +718,7 @@ "nesbot/carbon": "1.39.0", "phpunit/phpunit": "^5 | ^6 | ^7 | ^8 | ^9" }, - "time": "2024-03-07T13:35:21+00:00", + "time": "2024-09-11T17:34:41+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -351,23 +739,23 @@ ], "description": "Core component for Pagar.me e-commerce platform modules.", "support": { - "source": "https://github.com/pagarme/ecommerce-module-core/tree/2.4.1" + "source": "https://github.com/pagarme/ecommerce-module-core/tree/2.6.0" }, "install-path": "../pagarme/ecommerce-module-core" }, { "name": "pagarme/pagarmecoreapi", - "version": "v5.6.4", - "version_normalized": "5.6.4.0", + "version": "v5.6.5", + "version_normalized": "5.6.5.0", "source": { "type": "git", "url": "https://github.com/pagarme/pagarme-core-api-php.git", - "reference": "acab7709b2579221417946b261f6c24710604eb8" + "reference": "58a88ec0968392a8eb54bcc0ee1c15e06fddd40e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/pagarme/pagarme-core-api-php/zipball/acab7709b2579221417946b261f6c24710604eb8", - "reference": "acab7709b2579221417946b261f6c24710604eb8", + "url": "https://api.github.com/repos/pagarme/pagarme-core-api-php/zipball/58a88ec0968392a8eb54bcc0ee1c15e06fddd40e", + "reference": "58a88ec0968392a8eb54bcc0ee1c15e06fddd40e", "shasum": "" }, "require": { @@ -381,7 +769,7 @@ "require-dev": { "squizlabs/php_codesniffer": "^2.7" }, - "time": "2023-12-15T13:58:12+00:00", + "time": "2024-06-13T16:46:46+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -410,64 +798,1729 @@ ], "support": { "issues": "https://github.com/pagarme/pagarme-core-api-php/issues", - "source": "https://github.com/pagarme/pagarme-core-api-php/tree/v5.6.4" + "source": "https://github.com/pagarme/pagarme-core-api-php/tree/v5.6.5" }, "install-path": "../pagarme/pagarmecoreapi" }, { - "name": "psr/log", - "version": "1.1.4", - "version_normalized": "1.1.4.0", + "name": "phar-io/manifest", + "version": "2.0.4", + "version_normalized": "2.0.4.0", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + "url": "https://github.com/phar-io/manifest.git", + "reference": "54750ef60c58e43759730615a392c31c80e23176" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", - "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176", + "reference": "54750ef60c58e43759730615a392c31c80e23176", "shasum": "" }, "require": { - "php": ">=5.3.0" + "ext-dom": "*", + "ext-libxml": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, - "time": "2021-05-03T11:20:27+00:00", + "time": "2024-03-03T12:33:53+00:00", "type": "library", "extra": { "branch-alias": { - "dev-master": "1.1.x-dev" + "dev-master": "2.0.x-dev" } }, "installation-source": "dist", "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", "support": { - "source": "https://github.com/php-fig/log/tree/1.1.4" + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.4" }, - "install-path": "../psr/log" + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "install-path": "../phar-io/manifest" + }, + { + "name": "phar-io/version", + "version": "3.2.1", + "version_normalized": "3.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/phar-io/version.git", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "reference": "4f7fd7836c6f332bb2933569e566a0d6c4cbed74", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "time": "2022-02-21T01:04:05+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" + } + ], + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.2.1" + }, + "install-path": "../phar-io/version" + }, + { + "name": "phpunit/php-code-coverage", + "version": "10.1.15", + "version_normalized": "10.1.15.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", + "reference": "5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1", + "phpunit/php-file-iterator": "^4.0", + "phpunit/php-text-template": "^3.0", + "sebastian/code-unit-reverse-lookup": "^3.0", + "sebastian/complexity": "^3.0", + "sebastian/environment": "^6.0", + "sebastian/lines-of-code": "^2.0", + "sebastian/version": "^4.0", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.1" + }, + "suggest": { + "ext-pcov": "PHP extension that provides line coverage", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" + }, + "time": "2024-06-29T08:25:15+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/10.1.15" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../phpunit/php-code-coverage" + }, + { + "name": "phpunit/php-file-iterator", + "version": "4.1.0", + "version_normalized": "4.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/a95037b6d9e608ba092da1b23931e537cadc3c3c", + "reference": "a95037b6d9e608ba092da1b23931e537cadc3c3c", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-08-31T06:24:48+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "security": "https://github.com/sebastianbergmann/php-file-iterator/security/policy", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/4.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../phpunit/php-file-iterator" + }, + { + "name": "phpunit/php-invoker", + "version": "4.0.0", + "version_normalized": "4.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "reference": "f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-pcntl": "*" + }, + "time": "2023-02-03T06:56:09+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../phpunit/php-invoker" + }, + { + "name": "phpunit/php-text-template", + "version": "3.0.1", + "version_normalized": "3.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "reference": "0c7b06ff49e3d5072f057eb1fa59258bf287a748", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-08-31T14:07:24+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "security": "https://github.com/sebastianbergmann/php-text-template/security/policy", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/3.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../phpunit/php-text-template" + }, + { + "name": "phpunit/php-timer", + "version": "6.0.0", + "version_normalized": "6.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "reference": "e2a2d67966e740530f4a3343fe2e030ffdc1161d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T06:57:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/6.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../phpunit/php-timer" + }, + { + "name": "phpunit/phpunit", + "version": "10.5.27", + "version_normalized": "10.5.27.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "2425f713b2a5350568ccb1a2d3984841a23e83c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2425f713b2a5350568ccb1a2d3984841a23e83c5", + "reference": "2425f713b2a5350568ccb1a2d3984841a23e83c5", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.12.0", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", + "php": ">=8.1", + "phpunit/php-code-coverage": "^10.1.15", + "phpunit/php-file-iterator": "^4.1.0", + "phpunit/php-invoker": "^4.0.0", + "phpunit/php-text-template": "^3.0.1", + "phpunit/php-timer": "^6.0.0", + "sebastian/cli-parser": "^2.0.1", + "sebastian/code-unit": "^2.0.0", + "sebastian/comparator": "^5.0.1", + "sebastian/diff": "^5.1.1", + "sebastian/environment": "^6.1.0", + "sebastian/exporter": "^5.1.2", + "sebastian/global-state": "^6.0.2", + "sebastian/object-enumerator": "^5.0.0", + "sebastian/recursion-context": "^5.0.0", + "sebastian/type": "^4.0.0", + "sebastian/version": "^4.0.1" + }, + "suggest": { + "ext-soap": "To be able to generate mocks based on WSDL files" + }, + "time": "2024-07-10T11:48:06+00:00", + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "10.5-dev" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/Framework/Assert/Functions.php" + ], + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.27" + }, + "funding": [ + { + "url": "https://phpunit.de/sponsors.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "install-path": "../phpunit/phpunit" + }, + { + "name": "psr/log", + "version": "1.1.4", + "version_normalized": "1.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2021-05-03T11:20:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "install-path": "../psr/log" + }, + { + "name": "sebastian/cli-parser", + "version": "2.0.1", + "version_normalized": "2.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "reference": "c34583b87e7b7a8055bf6c450c2c77ce32a24084", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2024-03-02T07:12:49+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "security": "https://github.com/sebastianbergmann/cli-parser/security/policy", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/2.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/cli-parser" + }, + { + "name": "sebastian/code-unit", + "version": "2.0.0", + "version_normalized": "2.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/a81fee9eef0b7a76af11d121767abc44c104e503", + "reference": "a81fee9eef0b7a76af11d121767abc44c104e503", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T06:58:43+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/code-unit" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "reference": "5e3a687f7d8ae33fb362c5c0743794bbb2420a1d", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T06:59:15+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/code-unit-reverse-lookup" + }, + { + "name": "sebastian/comparator", + "version": "5.0.1", + "version_normalized": "5.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2db5010a484d53ebf536087a70b4a5423c102372", + "reference": "2db5010a484d53ebf536087a70b4a5423c102372", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/diff": "^5.0", + "sebastian/exporter": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.3" + }, + "time": "2023-08-14T13:18:12+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "security": "https://github.com/sebastianbergmann/comparator/security/policy", + "source": "https://github.com/sebastianbergmann/comparator/tree/5.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/comparator" + }, + { + "name": "sebastian/complexity", + "version": "3.2.0", + "version_normalized": "3.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "68ff824baeae169ec9f2137158ee529584553799" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/68ff824baeae169ec9f2137158ee529584553799", + "reference": "68ff824baeae169ec9f2137158ee529584553799", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-12-21T08:37:17+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.2-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "security": "https://github.com/sebastianbergmann/complexity/security/policy", + "source": "https://github.com/sebastianbergmann/complexity/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/complexity" + }, + { + "name": "sebastian/diff", + "version": "5.1.1", + "version_normalized": "5.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/c41e007b4b62af48218231d6c2275e4c9b975b2e", + "reference": "c41e007b4b62af48218231d6c2275e4c9b975b2e", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0", + "symfony/process": "^6.4" + }, + "time": "2024-03-02T07:15:17+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "security": "https://github.com/sebastianbergmann/diff/security/policy", + "source": "https://github.com/sebastianbergmann/diff/tree/5.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/diff" + }, + { + "name": "sebastian/environment", + "version": "6.1.0", + "version_normalized": "6.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/8074dbcd93529b357029f5cc5058fd3e43666984", + "reference": "8074dbcd93529b357029f5cc5058fd3e43666984", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "suggest": { + "ext-posix": "*" + }, + "time": "2024-03-23T08:47:14+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "https://github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "security": "https://github.com/sebastianbergmann/environment/security/policy", + "source": "https://github.com/sebastianbergmann/environment/tree/6.1.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/environment" + }, + { + "name": "sebastian/exporter", + "version": "5.1.2", + "version_normalized": "5.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "955288482d97c19a372d3f31006ab3f37da47adf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/955288482d97c19a372d3f31006ab3f37da47adf", + "reference": "955288482d97c19a372d3f31006ab3f37da47adf", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": ">=8.1", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2024-03-02T07:17:12+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "https://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "security": "https://github.com/sebastianbergmann/exporter/security/policy", + "source": "https://github.com/sebastianbergmann/exporter/tree/5.1.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/exporter" + }, + { + "name": "sebastian/global-state", + "version": "6.0.2", + "version_normalized": "6.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "reference": "987bafff24ecc4c9ac418cab1145b96dd6e9cbd9", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "ext-dom": "*", + "phpunit/phpunit": "^10.0" + }, + "time": "2024-03-02T07:19:19+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "6.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "https://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "security": "https://github.com/sebastianbergmann/global-state/security/policy", + "source": "https://github.com/sebastianbergmann/global-state/tree/6.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/global-state" + }, + { + "name": "sebastian/lines-of-code", + "version": "2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/856e7f6a75a84e339195d48c556f23be2ebf75d0", + "reference": "856e7f6a75a84e339195d48c556f23be2ebf75d0", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.18 || ^5.0", + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-12-21T08:38:20+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "security": "https://github.com/sebastianbergmann/lines-of-code/security/policy", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/lines-of-code" + }, + { + "name": "sebastian/object-enumerator", + "version": "5.0.0", + "version_normalized": "5.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/202d0e344a580d7f7d04b3fafce6933e59dae906", + "reference": "202d0e344a580d7f7d04b3fafce6933e59dae906", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "sebastian/object-reflector": "^3.0", + "sebastian/recursion-context": "^5.0" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T07:08:32+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/object-enumerator" + }, + { + "name": "sebastian/object-reflector", + "version": "3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/24ed13d98130f0e7122df55d06c5c4942a577957", + "reference": "24ed13d98130f0e7122df55d06c5c4942a577957", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T07:06:18+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/object-reflector" + }, + { + "name": "sebastian/recursion-context", + "version": "5.0.0", + "version_normalized": "5.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/05909fb5bc7df4c52992396d0116aed689f93712", + "reference": "05909fb5bc7df4c52992396d0116aed689f93712", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T07:05:40+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "5.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "https://github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/5.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/recursion-context" + }, + { + "name": "sebastian/type", + "version": "4.0.0", + "version_normalized": "4.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/462699a16464c3944eefc02ebdd77882bd3925bf", + "reference": "462699a16464c3944eefc02ebdd77882bd3925bf", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "require-dev": { + "phpunit/phpunit": "^10.0" + }, + "time": "2023-02-03T07:10:45+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/4.0.0" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/type" + }, + { + "name": "sebastian/version", + "version": "4.0.1", + "version_normalized": "4.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "reference": "c51fa83a5d8f43f1402e3f32a005e6262244ef17", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "time": "2023-02-07T11:34:05+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "4.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/4.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "install-path": "../sebastian/version" + }, + { + "name": "theseer/tokenizer", + "version": "1.2.3", + "version_normalized": "1.2.3.0", + "source": { + "type": "git", + "url": "https://github.com/theseer/tokenizer.git", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "reference": "737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" + }, + "time": "2024-03-03T12:36:25+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.3" + }, + "funding": [ + { + "url": "https://github.com/theseer", + "type": "github" + } + ], + "install-path": "../theseer/tokenizer" + }, + { + "name": "wordpress/wordpress", + "version": "dev-master", + "version_normalized": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/WordPress/wordpress-develop/", + "reference": "d088e31c73456179502c9bd5354fc43c6267bd7a" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0", + "phpcompatibility/phpcompatibility-wp": "~2.1.2", + "squizlabs/php_codesniffer": "3.6.0", + "wp-coding-standards/wpcs": "~2.3.0", + "yoast/phpunit-polyfills": "^1.0.1" + }, + "time": "2021-11-08T10:47:55+00:00", + "type": "library", + "installation-source": "source", + "scripts": { + "compat": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --standard=phpcompat.xml.dist --report=summary,source" + ], + "format": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --report=summary,source" + ], + "lint": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --report=summary,source" + ], + "lint:errors": [ + "@lint -n" + ], + "test": [ + "@php ./vendor/phpunit/phpunit/phpunit" + ] + }, + "license": [ + "GPL-2.0-or-later" + ], + "description": "WordPress is open source software you can use to create a beautiful website, blog, or app.", + "homepage": "https://wordpress.org", + "keywords": [ + "blog", + "cms", + "wordpress", + "wp" + ], + "support": { + "issues": "https://core.trac.wordpress.org/" + }, + "install-path": "../wordpress/wordpress" } ], - "dev": false, - "dev-package-names": [] + "dev": true, + "dev-package-names": [ + "antecedent/patchwork", + "brain/monkey", + "hamcrest/hamcrest-php", + "mockery/mockery", + "myclabs/deep-copy", + "nikic/php-parser", + "phar-io/manifest", + "phar-io/version", + "phpunit/php-code-coverage", + "phpunit/php-file-iterator", + "phpunit/php-invoker", + "phpunit/php-text-template", + "phpunit/php-timer", + "phpunit/phpunit", + "sebastian/cli-parser", + "sebastian/code-unit", + "sebastian/code-unit-reverse-lookup", + "sebastian/comparator", + "sebastian/complexity", + "sebastian/diff", + "sebastian/environment", + "sebastian/exporter", + "sebastian/global-state", + "sebastian/lines-of-code", + "sebastian/object-enumerator", + "sebastian/object-reflector", + "sebastian/recursion-context", + "sebastian/type", + "sebastian/version", + "theseer/tokenizer", + "wordpress/wordpress" + ] } diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index afefc787..e1237f68 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,15 +1,24 @@ array( 'name' => 'pagarme/woocommerce-pagarme-payments', - 'pretty_version' => '3.2.2', - 'version' => '3.2.2.0', - 'reference' => NULL, + 'pretty_version' => '3.3.3', + 'version' => '3.3.3.0', + 'reference' => null, 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), - 'dev' => false, + 'dev' => true, ), 'versions' => array( + 'antecedent/patchwork' => array( + 'pretty_version' => '2.1.28', + 'version' => '2.1.28.0', + 'reference' => '6b30aff81ebadf0f2feb9268d3e08385cebcc08d', + 'type' => 'library', + 'install_path' => __DIR__ . '/../antecedent/patchwork', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'apimatic/jsonmapper' => array( 'pretty_version' => 'v1.3.1', 'version' => '1.3.1.0', @@ -28,6 +37,36 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'brain/monkey' => array( + 'pretty_version' => '2.6.1', + 'version' => '2.6.1.0', + 'reference' => 'a31c84515bb0d49be9310f52ef1733980ea8ffbb', + 'type' => 'library', + 'install_path' => __DIR__ . '/../brain/monkey', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'cordoval/hamcrest-php' => array( + 'dev_requirement' => true, + 'replaced' => array( + 0 => '*', + ), + ), + 'davedevelopment/hamcrest-php' => array( + 'dev_requirement' => true, + 'replaced' => array( + 0 => '*', + ), + ), + 'hamcrest/hamcrest-php' => array( + 'pretty_version' => 'v2.0.1', + 'version' => '2.0.1.0', + 'reference' => '8c3d0a3f6af734494ad8f6fbbee0ba92422859f3', + 'type' => 'library', + 'install_path' => __DIR__ . '/../hamcrest/hamcrest-php', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'haydenpierce/class-finder' => array( 'pretty_version' => '0.5.3', 'version' => '0.5.3.0', @@ -37,6 +76,12 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'kodova/hamcrest-php' => array( + 'dev_requirement' => true, + 'replaced' => array( + 0 => '*', + ), + ), 'mashape/unirest-php' => array( 'pretty_version' => 'v3.0.4', 'version' => '3.0.4.0', @@ -46,6 +91,15 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'mockery/mockery' => array( + 'pretty_version' => '1.6.12', + 'version' => '1.6.12.0', + 'reference' => '1f4efdd7d3beafe9807b08156dfcb176d18f1699', + 'type' => 'library', + 'install_path' => __DIR__ . '/../mockery/mockery', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'monolog/monolog' => array( 'pretty_version' => '1.27.1', 'version' => '1.27.1.0', @@ -55,33 +109,123 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'myclabs/deep-copy' => array( + 'pretty_version' => '1.12.0', + 'version' => '1.12.0.0', + 'reference' => '3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../myclabs/deep-copy', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'nikic/php-parser' => array( + 'pretty_version' => 'v5.1.0', + 'version' => '5.1.0.0', + 'reference' => '683130c2ff8c2739f4822ff7ac5c873ec529abd1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../nikic/php-parser', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'pagarme/ecommerce-module-core' => array( - 'pretty_version' => '2.4.1', - 'version' => '2.4.1.0', - 'reference' => '3e75e5365882c6806f2ac76e6901ee17815d101e', + 'pretty_version' => '2.6.0', + 'version' => '2.6.0.0', + 'reference' => '83eff7118a3a6ead781a920d2fa42b6a186105d2', 'type' => 'library', 'install_path' => __DIR__ . '/../pagarme/ecommerce-module-core', 'aliases' => array(), 'dev_requirement' => false, ), 'pagarme/pagarmecoreapi' => array( - 'pretty_version' => 'v5.6.4', - 'version' => '5.6.4.0', - 'reference' => 'acab7709b2579221417946b261f6c24710604eb8', + 'pretty_version' => 'v5.6.5', + 'version' => '5.6.5.0', + 'reference' => '58a88ec0968392a8eb54bcc0ee1c15e06fddd40e', 'type' => 'library', 'install_path' => __DIR__ . '/../pagarme/pagarmecoreapi', 'aliases' => array(), 'dev_requirement' => false, ), 'pagarme/woocommerce-pagarme-payments' => array( - 'pretty_version' => '3.2.2', - 'version' => '3.2.2.0', - 'reference' => NULL, + 'pretty_version' => '3.3.3', + 'version' => '3.3.3.0', + 'reference' => null, 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => false, ), + 'phar-io/manifest' => array( + 'pretty_version' => '2.0.4', + 'version' => '2.0.4.0', + 'reference' => '54750ef60c58e43759730615a392c31c80e23176', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phar-io/manifest', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phar-io/version' => array( + 'pretty_version' => '3.2.1', + 'version' => '3.2.1.0', + 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phar-io/version', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/php-code-coverage' => array( + 'pretty_version' => '10.1.15', + 'version' => '10.1.15.0', + 'reference' => '5da8b1728acd1e6ffdf2ff32ffbdfd04307f26ae', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/php-file-iterator' => array( + 'pretty_version' => '4.1.0', + 'version' => '4.1.0.0', + 'reference' => 'a95037b6d9e608ba092da1b23931e537cadc3c3c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/php-invoker' => array( + 'pretty_version' => '4.0.0', + 'version' => '4.0.0.0', + 'reference' => 'f5e568ba02fa5ba0ddd0f618391d5a9ea50b06d7', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/php-invoker', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/php-text-template' => array( + 'pretty_version' => '3.0.1', + 'version' => '3.0.1.0', + 'reference' => '0c7b06ff49e3d5072f057eb1fa59258bf287a748', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/php-text-template', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/php-timer' => array( + 'pretty_version' => '6.0.0', + 'version' => '6.0.0.0', + 'reference' => 'e2a2d67966e740530f4a3343fe2e030ffdc1161d', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/php-timer', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'phpunit/phpunit' => array( + 'pretty_version' => '10.5.27', + 'version' => '10.5.27.0', + 'reference' => '2425f713b2a5350568ccb1a2d3984841a23e83c5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpunit/phpunit', + 'aliases' => array(), + 'dev_requirement' => true, + ), 'psr/log' => array( 'pretty_version' => '1.1.4', 'version' => '1.1.4.0', @@ -97,5 +241,158 @@ 0 => '1.0.0', ), ), + 'sebastian/cli-parser' => array( + 'pretty_version' => '2.0.1', + 'version' => '2.0.1.0', + 'reference' => 'c34583b87e7b7a8055bf6c450c2c77ce32a24084', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/cli-parser', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/code-unit' => array( + 'pretty_version' => '2.0.0', + 'version' => '2.0.0.0', + 'reference' => 'a81fee9eef0b7a76af11d121767abc44c104e503', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/code-unit', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/code-unit-reverse-lookup' => array( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'reference' => '5e3a687f7d8ae33fb362c5c0743794bbb2420a1d', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/comparator' => array( + 'pretty_version' => '5.0.1', + 'version' => '5.0.1.0', + 'reference' => '2db5010a484d53ebf536087a70b4a5423c102372', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/comparator', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/complexity' => array( + 'pretty_version' => '3.2.0', + 'version' => '3.2.0.0', + 'reference' => '68ff824baeae169ec9f2137158ee529584553799', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/complexity', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/diff' => array( + 'pretty_version' => '5.1.1', + 'version' => '5.1.1.0', + 'reference' => 'c41e007b4b62af48218231d6c2275e4c9b975b2e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/diff', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/environment' => array( + 'pretty_version' => '6.1.0', + 'version' => '6.1.0.0', + 'reference' => '8074dbcd93529b357029f5cc5058fd3e43666984', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/environment', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/exporter' => array( + 'pretty_version' => '5.1.2', + 'version' => '5.1.2.0', + 'reference' => '955288482d97c19a372d3f31006ab3f37da47adf', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/exporter', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/global-state' => array( + 'pretty_version' => '6.0.2', + 'version' => '6.0.2.0', + 'reference' => '987bafff24ecc4c9ac418cab1145b96dd6e9cbd9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/global-state', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/lines-of-code' => array( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => '856e7f6a75a84e339195d48c556f23be2ebf75d0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/lines-of-code', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/object-enumerator' => array( + 'pretty_version' => '5.0.0', + 'version' => '5.0.0.0', + 'reference' => '202d0e344a580d7f7d04b3fafce6933e59dae906', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/object-enumerator', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/object-reflector' => array( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'reference' => '24ed13d98130f0e7122df55d06c5c4942a577957', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/object-reflector', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/recursion-context' => array( + 'pretty_version' => '5.0.0', + 'version' => '5.0.0.0', + 'reference' => '05909fb5bc7df4c52992396d0116aed689f93712', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/recursion-context', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/type' => array( + 'pretty_version' => '4.0.0', + 'version' => '4.0.0.0', + 'reference' => '462699a16464c3944eefc02ebdd77882bd3925bf', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/type', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'sebastian/version' => array( + 'pretty_version' => '4.0.1', + 'version' => '4.0.1.0', + 'reference' => 'c51fa83a5d8f43f1402e3f32a005e6262244ef17', + 'type' => 'library', + 'install_path' => __DIR__ . '/../sebastian/version', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'theseer/tokenizer' => array( + 'pretty_version' => '1.2.3', + 'version' => '1.2.3.0', + 'reference' => '737eda637ed5e28c3413cb1ebe8bb52cbf1ca7a2', + 'type' => 'library', + 'install_path' => __DIR__ . '/../theseer/tokenizer', + 'aliases' => array(), + 'dev_requirement' => true, + ), + 'wordpress/wordpress' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => 'd088e31c73456179502c9bd5354fc43c6267bd7a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../wordpress/wordpress', + 'aliases' => array(), + 'dev_requirement' => true, + ), ), ); diff --git a/vendor/pagarme/ecommerce-module-core/.gitignore b/vendor/pagarme/ecommerce-module-core/.gitignore index fd5fb9ac..db23bc72 100644 --- a/vendor/pagarme/ecommerce-module-core/.gitignore +++ b/vendor/pagarme/ecommerce-module-core/.gitignore @@ -2,3 +2,6 @@ /vendor/ /tests/report /tests/mock/db_test.sqlite +composer.lock +.phpunit.result.cache +coverage \ No newline at end of file diff --git a/vendor/pagarme/ecommerce-module-core/composer.json b/vendor/pagarme/ecommerce-module-core/composer.json index f3afe9d1..7813a372 100644 --- a/vendor/pagarme/ecommerce-module-core/composer.json +++ b/vendor/pagarme/ecommerce-module-core/composer.json @@ -2,7 +2,7 @@ "name": "pagarme/ecommerce-module-core", "description": "Core component for Pagar.me e-commerce platform modules.", "license": "MIT", - "version": "2.4.1", + "version": "2.6.0", "authors": [ { "name":"Open Source Team" @@ -12,7 +12,7 @@ "require": { "php": ">=7.1", "monolog/monolog": "<3", - "pagarme/pagarmecoreapi": "v5.6.4", + "pagarme/pagarmecoreapi": "v5.6.5", "ext-json": "*" }, "require-dev": { diff --git a/vendor/pagarme/ecommerce-module-core/src/Hub/Commands/InstallCommand.php b/vendor/pagarme/ecommerce-module-core/src/Hub/Commands/InstallCommand.php index 506200be..76ba3e96 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Hub/Commands/InstallCommand.php +++ b/vendor/pagarme/ecommerce-module-core/src/Hub/Commands/InstallCommand.php @@ -12,12 +12,6 @@ public function execute() { $moduleConfig = MPSetup::getModuleConfiguration(); - if ($moduleConfig->isHubEnabled()) { - $exception = new Exception("Hub already installed!"); - $this->logService->exception($exception); - throw $exception; - } - $moduleConfig->setAccountId($this->getAccountId()); $moduleConfig->setMerchantId($this->getMerchantId()); diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Charge.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Charge.php index 7e0a8b2c..f12995ae 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Charge.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Charge.php @@ -401,7 +401,7 @@ public function updateTransaction(Transaction $updatedTransaction, $overwriteId /** * @return array */ - public function getAcquirerTidCapturedAndAutorize() + public function getAcquirerTidCapturedAndAuthorize() { $transactions = $this->getTransactions(); diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Configuration.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Configuration.php index f31fdabd..54c2e6e0 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Configuration.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Aggregates/Configuration.php @@ -14,6 +14,7 @@ use Pagarme\Core\Kernel\ValueObjects\Configuration\RecurrenceConfig; use Pagarme\Core\Kernel\ValueObjects\Configuration\VoucherConfig; use Pagarme\Core\Kernel\ValueObjects\Configuration\DebitConfig; +use Pagarme\Core\Kernel\ValueObjects\Configuration\GooglePayConfig; use Pagarme\Core\Kernel\ValueObjects\Key\AbstractSecretKey; use Pagarme\Core\Kernel\ValueObjects\Key\AbstractPublicKey; use Pagarme\Core\Kernel\ValueObjects\Key\TestPublicKey; @@ -42,6 +43,7 @@ final class Configuration extends AbstractEntity * @var bool */ private $creditCardEnabled; + private $googlepayEnabled; /** * * @var bool @@ -158,6 +160,7 @@ final class Configuration extends AbstractEntity /** @var DebitConfig */ private $debitConfig; + private $googlePayConfig; /** * @var PixConfig @@ -222,6 +225,18 @@ public function getDebitConfig() return $this->debitConfig; } + public function getGooglePayConfig() + { + return $this->googlePayConfig; + } + + /** + * @param GooglePayConfig $googlePayConfig + */ + public function setGooglePayConfig(GooglePayConfig $googlePayConfig) + { + $this->googlePayConfig = $googlePayConfig; + } /** * @param DebitConfig $debitConfig */ @@ -421,6 +436,19 @@ public function setCreditCardEnabled($creditCardEnabled) return $this; } + /** + * + * @param bool $googlepayEnabled + * @return Configuration + */ + public function setGooglePayEnabled($googlepayEnabled) + { + $this->googlepayEnabled = filter_var( + $googlepayEnabled, + FILTER_VALIDATE_BOOLEAN + ); + return $this; + } /** * @param $sendMailEnable * @return $this @@ -492,6 +520,10 @@ protected function isCreditCardEnabled() { return $this->creditCardEnabled; } + protected function isGooglePayEnabled() + { + return $this->googlepayEnabled; + } /** * @return bool @@ -845,6 +877,7 @@ public function jsonSerialize() "voucherConfig" => $this->getVoucherConfig(), "debitConfig" => $this->getDebitConfig(), "pixConfig" => $this->getPixConfig(), + "googlePayConfig" => $this->getGooglePayConfig(), "marketplaceConfig" => $this->getMarketplaceConfig() ]; } diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/ConfigurationFactory.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/ConfigurationFactory.php index 3ff694d9..abb14c72 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/ConfigurationFactory.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/ConfigurationFactory.php @@ -7,6 +7,7 @@ use Pagarme\Core\Kernel\Factories\Configurations\DebitConfigFactory; use Pagarme\Core\Kernel\Factories\Configurations\MarketplaceConfigFactory; use Pagarme\Core\Kernel\Factories\Configurations\PixConfigFactory; +use Pagarme\Core\Kernel\Factories\Configurations\GooglePayConfigFactory; use Pagarme\Core\Kernel\Factories\Configurations\RecurrenceConfigFactory; use Pagarme\Core\Kernel\Factories\Configurations\VoucherConfigFactory; use Pagarme\Core\Kernel\Interfaces\FactoryInterface; @@ -231,6 +232,11 @@ public function createFromJsonData($json) (new PixConfigFactory())->createFromDbData($data->pixConfig) ); } + if (!empty($data->googlePayConfig)) { + $config->setGooglePayConfig( + (new GooglePayConfigFactory())->createFromDbData($data->googlePayConfig) + ); + } if (!empty($data->allowNoAddress)) { $config->setAllowNoAddress($data->allowNoAddress); diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/Configurations/GooglePayConfigFactory.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/Configurations/GooglePayConfigFactory.php new file mode 100644 index 00000000..d935ea4f --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Factories/Configurations/GooglePayConfigFactory.php @@ -0,0 +1,35 @@ +enabled)) { + $googlePayConfig->setEnabled((bool) $data->enabled); + } + + if (!empty($data->title)) { + $googlePayConfig->setTitle($data->title); + } + + if (!empty($data->merchantId)) { + $googlePayConfig->setMerchantId($data->merchantId); + } + if (!empty($data->merchantName)) { + $googlePayConfig->setMerchantName($data->merchantName); + } + + return $googlePayConfig; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/I18N/PTBR.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/I18N/PTBR.php index 744d7e12..4d8415fa 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/I18N/PTBR.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/I18N/PTBR.php @@ -30,7 +30,7 @@ protected function getTable() 'Remaining amount: %.2f' => "Quantidade faltante: %.2f", "Some charges couldn't be canceled at Pagarme. Reasons:" => "Algumas cobranças não puderam ser canceladas na Pagarme. Razões:", "without interest" => "sem juros", - "with %.2f%% of interest" => "com %.2f%% de juros", + "with interest" => "com juros", "%dx of %s %s (Total: %s)" => "%dx de %s %s (Total: %s)", "Order payment failed" => "Pagamento do pedido falhou", "The order will be canceled" => "O pedido será cancelado", diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ChargeRepository.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ChargeRepository.php index 8ce69c5c..29e5756d 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ChargeRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ChargeRepository.php @@ -234,7 +234,7 @@ public function findChargeWithOutOrder($code) $orderTable = $this->db->getTable( AbstractDatabaseDecorator::TABLE_ORDER ); - + $code = filter_var($code, FILTER_SANITIZE_SPECIAL_CHARS); $query = "SELECT charge.* FROM `{$chargeTable}` as charge LEFT JOIN `{$orderTable}` as o on charge.order_id = o.pagarme_id @@ -255,4 +255,66 @@ public function findChargeWithOutOrder($code) return $chargeList; } + + /** + * @param $code + * @return Charge[] + * @throws \Exception + */ + public function findChargesByCode($code) + { + $chargeTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_CHARGE); + $transactionTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_TRANSACTION); + + $this->db->query("SET group_concat_max_len = 8096;"); + + $query = " + SELECT + c.*, + t.id as tran_id, + t.pagarme_id as tran_pagarme_id, + t.charge_id as tran_charge_id, + t.amount as tran_amount, + t.paid_amount as tran_paid_amount, + t.acquirer_name as tran_acquirer_name, + t.acquirer_message as tran_acquirer_message, + t.acquirer_nsu as tran_acquirer_nsu, + t.acquirer_tid as tran_acquirer_tid, + t.acquirer_auth_code as tran_acquirer_auth_code, + t.type as tran_type, + t.status as tran_status, + t.created_at as tran_created_at, + t.boleto_url as tran_boleto_url, + t.card_data as tran_card_data, + t.transaction_data as tran_data + FROM + $chargeTable as c + LEFT JOIN $transactionTable as t on c.pagarme_id = t.charge_id + WHERE c.code = '$code' + ORDER BY c.id DESC; + "; + + $result = $this->db->fetch($query); + + if ($result->num_rows === 0) { + return []; + } + + $factory = new ChargeFactory(); + + $charges = []; + foreach ($result->rows as &$row) { + $row['tran_card_data'] = StringFunctionsHelper::removeLineBreaks( + $row['tran_card_data'] + ); + + $row['tran_data'] = StringFunctionsHelper::removeLineBreaks( + $row['tran_data'] + ); + + $charges[] = $factory->createFromDbData($row); + } + + return $charges; + } } \ No newline at end of file diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ConfigurationRepository.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ConfigurationRepository.php index 59319cdd..fa8ccf42 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ConfigurationRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/ConfigurationRepository.php @@ -77,7 +77,7 @@ public function delete(AbstractEntity $object) public function find($objectId) { $configTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_MODULE_CONFIGURATION); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT data, id FROM `$configTable` WHERE id = {$objectId};"; $result = $this->db->fetch($query); @@ -101,7 +101,7 @@ public function findByStore($storeId) } $configTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_MODULE_CONFIGURATION); - + $storeId = filter_var($storeId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT data, id FROM `$configTable` WHERE store_id = {$storeId};"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/OrderRepository.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/OrderRepository.php index fd7d7dc5..267dc8ad 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/OrderRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Repositories/OrderRepository.php @@ -65,7 +65,7 @@ protected function update(AbstractEntity &$object) public function findByCode($codeId) { $orderTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_ORDER); - + $codeId = filter_var($codeId, FILTER_SANITIZE_SPECIAL_CHARS); $query = "SELECT * FROM `$orderTable` "; $query .= "WHERE code = '{$codeId}';"; @@ -117,7 +117,7 @@ public function findByPagarmeId(AbstractValidString $pagarmeId) public function findByPlatformId($platformID) { $orderTable = $this->db->getTable(AbstractDatabaseDecorator::TABLE_ORDER); - + $platformID = filter_var($platformID, FILTER_SANITIZE_SPECIAL_CHARS); $query = "SELECT * FROM `$orderTable` "; $query .= "WHERE code = '{$platformID}' ORDER BY id DESC;"; diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/ChargeService.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/ChargeService.php index 4c49543d..6ef63a51 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/ChargeService.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/ChargeService.php @@ -311,13 +311,22 @@ public function findChargeWithOutOrder($code) { $chargeRepository = new ChargeRepository(); - try { - return $chargeRepository->findChargeWithOutOrder($code); - } catch (Exception $exception) { - throw new Exception($exception, $exception->getCode()); - } + return $chargeRepository->findChargeWithOutOrder($code); } + /** + * @param $code + * + * @return Charge[] + * @throws \Exception + */ + public function findChargesByCode($code) + { + $chargeRepository = new ChargeRepository(); + + return $chargeRepository->findChargesByCode($code); + } + /** * @param Charge $charge * @throws Exception diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/InstallmentService.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/InstallmentService.php index b51b386e..be4df11f 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/InstallmentService.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/Services/InstallmentService.php @@ -110,10 +110,7 @@ public function getLabelFor(Installment $installment) $interestLabel = $i18n->getDashboard('without interest'); if ($installment->getInterest() > 0) { - $interestLabel = ", " . $i18n->getDashboard( - 'with %.2f%% of interest', - $installment->getInterest() * 100 - ); + $interestLabel = $i18n->getDashboard('with interest'); } $moneyService = new MoneyService(); @@ -154,4 +151,4 @@ function (Installment $installment) use ($brandConfig) { } ); } -} \ No newline at end of file +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/Configuration/GooglePayConfig.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/Configuration/GooglePayConfig.php new file mode 100644 index 00000000..4bfad925 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/Configuration/GooglePayConfig.php @@ -0,0 +1,92 @@ +enabled = $enabled; + return $this; + } + + /** + * @param string $title + * @return GooglePayConfig + */ + public function setTitle($title) + { + $this->title = $title; + return $this; + } + + /** + * @param string $merchantId + * @return GooglePayConfig + */ + public function setMerchantId($merchantId) + { + $this->merchantId = $merchantId; + return $this; + } + + /** + * @param string $merchantId + * @return GooglePayConfig + */ + public function setMerchantName($merchantName) + { + $this->merchantName = $merchantName; + return $this; + } + + protected function isEqual($object) + { + return $this->enabled === $this->isEnabled() + && $this->title === $this->getTitle() + && $this->merchantName === $this->getMerchantName() + && $this->merchantId === $this->getMerchantId(); + } + + public function isEnabled() + { + return $this->enabled; + } + + public function getTitle() + { + return $this->title; + } + + public function getMerchantName() + { + return $this->merchantName; + } + + public function getMerchantId() + { + return $this->merchantId; + } + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return [ + "enabled" => $this->isEnabled(), + "title" => $this->getTitle(), + "merchantId" => $this->getMerchantId(), + "merchantName" => $this->getMerchantName(), + ]; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/PaymentMethod.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/PaymentMethod.php index ab3c2b04..93aef3a3 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/PaymentMethod.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/PaymentMethod.php @@ -11,6 +11,7 @@ final class PaymentMethod extends AbstractValueObject const DEBIT_CARD = 'debit_card'; const VOUCHER = 'voucher'; const PIX = 'pix'; + const GOOGLEPAY = 'googlepay'; /** * @var string @@ -51,6 +52,10 @@ static public function pix() { return new self(self::PIX); } + static public function googlepay() + { + return new self(self::GOOGLEPAY); + } /** * diff --git a/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/TransactionType.php b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/TransactionType.php index fabd3b95..2b43d00e 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/TransactionType.php +++ b/vendor/pagarme/ecommerce-module-core/src/Kernel/ValueObjects/TransactionType.php @@ -11,6 +11,7 @@ final class TransactionType extends AbstractValueObject const VOUCHER = "voucher"; const DEBIT_CARD = "debit_card"; const PIX = 'pix'; + const GOOGLEPAY = 'googlepay'; /** * * @var string @@ -51,6 +52,10 @@ public static function pix() { return new self(self::PIX); } + public static function googlepay() + { + return new self(self::GOOGLEPAY); + } /** * diff --git a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Aggregates/Recipient.php b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Aggregates/Recipient.php index a10d72e5..164cc36a 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Aggregates/Recipient.php +++ b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Aggregates/Recipient.php @@ -57,6 +57,8 @@ class Recipient extends AbstractEntity implements RecipientInterface /** @var int */ private $transferDay = 0; /** @var string */ + private $status = ''; + /** @var string */ private $createdAt; /** @var string */ private $updatedAt; @@ -477,6 +479,48 @@ public function setTransferDay($transferDay) return $this; } + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param string $status + * @return Recipient + */ + public function setStatus($status, $kycStatus = '') + { + $recipientStatus = static::parseStatus($status, $kycStatus); + $this->status = $recipientStatus; + return $this; + } + + public static function parseStatus($status, $kycStatus) + { + if ($status === 'registration') { + if ($kycStatus === 'pending') { + return static::REGISTERED; + } + + if ($kycStatus === 'denied') { + return static::DISAPPROVED; + } + } + + if ($status === 'affiliation' && $kycStatus === 'pending') { + return static::WAITING_FOR_ANALYSIS; + } + + if ($kycStatus === 'partially_denied') { + return static::VALIDATION_REQUESTED; + } + + return $status; + } + /** * @return string */ diff --git a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Factories/RecipientFactory.php b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Factories/RecipientFactory.php index bae4e0ce..7231733d 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Factories/RecipientFactory.php +++ b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Factories/RecipientFactory.php @@ -29,6 +29,10 @@ public function createFromPostData($postData) return; } + if (isset($postData['status'])) { + $postData = $this->formatFromWebhook($postData); + } + $this->setId($postData); $this->setRecipientId($postData); $this->setExternalId($postData); @@ -63,11 +67,14 @@ public function createFromDbData($dbData) ->setExternalId($dbData['external_id']) ->setName($dbData['name']) ->setEmail($dbData['email']) - ->setDocumentType($dbData['document_type']) ->setDocument($dbData['document']) - ->setType($dbData['document_type'] == 'cpf' ? 'individual' : 'company') + ->setType($dbData['type'] == 'cpf' ? 'individual' : 'company') ->setPagarmeId(new RecipientId($dbData['pagarme_id'])); + if (isset($dbData['status'])) { + $this->recipient->setStatus($dbData['status']); + } + if (self::TYPE_BY_DOCUMENT) { $this->recipient->setType($this->getTypeByDocument($this->recipient->getDocument())); } @@ -79,6 +86,18 @@ public function createFromDbData($dbData) return $this->recipient; } + private function formatFromWebhook($postData) + { + $postData['recipient_id'] = $postData['id']; + unset($postData['id']); + + $kycStatus = $postData['kyc_details']['status'] ?? ''; + + $this->recipient->setStatus($postData['status'], $kycStatus); + + return $postData; + } + private function getTypeByDocument($document) { if ($document) { diff --git a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Interfaces/RecipientInterface.php b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Interfaces/RecipientInterface.php index 42bff96e..90685d1c 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Interfaces/RecipientInterface.php +++ b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Interfaces/RecipientInterface.php @@ -4,6 +4,22 @@ interface RecipientInterface { + const REGISTERED = 'registered'; + + const VALIDATION_REQUESTED = 'validation_requested'; + + const WAITING_FOR_ANALYSIS = 'waiting_for_analysis'; + + const ACTIVE = 'active'; + + const DISAPPROVED = 'disapproved'; + + const SUSPENDED = 'suspended'; + + const BLOCKED = 'blocked'; + + const INACTIVE = 'inactive'; + /** * @return int */ diff --git a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Repositories/RecipientRepository.php b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Repositories/RecipientRepository.php index da4fecd3..cbe5edb2 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Repositories/RecipientRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Repositories/RecipientRepository.php @@ -27,23 +27,32 @@ protected function create(AbstractEntity &$object) AbstractDatabaseDecorator::TABLE_RECIPIENTS ); - $query = " - INSERT INTO $table ( - `external_id`, - `name`, - `email`, - `document_type`, - `document`, - `pagarme_id` - ) VALUES ( - '{$object->getExternalId()}', - '{$object->getName()}', - '{$object->getEmail()}', - '{$object->getDocumentType()}', - '{$object->getDocument()}', - '{$object->getPagarmeId()->getValue()}' - ) - "; + $query = "INSERT INTO $table ( + `external_id`, + `name`, + `email`, + `type`, + `document`, + `pagarme_id`"; + + $queryStatusFieldValue = ''; + + if (!empty($object->getStatus())) { + $query .= ",`status`"; + $queryStatusFieldValue = ",{$object->getStatus()}"; + } + + $query .= ") VALUES ( + '{$object->getExternalId()}', + '{$object->getName()}', + '{$object->getEmail()}', + '{$object->getDocumentType()}', + '{$object->getDocument()}', + '{$object->getPagarmeId()->getValue()}'"; + + $query .= $queryStatusFieldValue; + + $query .= ")"; $this->db->query($query); } @@ -59,7 +68,8 @@ protected function update(AbstractEntity &$object) `external_id`='{$object->getExternalId()}', `name`='{$object->getName()}', `email`='{$object->getEmail()}', - `pagarme_id`='{$object->getPagarmeId()->getValue()}' + `pagarme_id`='{$object->getPagarmeId()->getValue()}', + `status`='{$object->getStatus()}' WHERE `id`='{$object->getId()}' "; @@ -82,7 +92,7 @@ public function find($objectId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECIPIENTS ); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = $objectId"; $result = $this->db->fetch($query); @@ -102,7 +112,7 @@ public function findByPagarmeId(AbstractValidString $pagarmeId) AbstractDatabaseDecorator::TABLE_RECIPIENTS ); - $query = "SELECT * FROM {$table} WHERE pagarme_id = {$pagarmeId}"; + $query = "SELECT * FROM {$table} WHERE pagarme_id = '{$pagarmeId}'"; $result = $this->db->fetch($query); @@ -165,7 +175,7 @@ public function findBySellerId($sellerId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECIPIENTS ); - + $sellerId = filter_var($sellerId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM `$table` as t "; $query .= "WHERE t.external_id = '$sellerId';"; diff --git a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Services/RecipientService.php b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Services/RecipientService.php index 583a1ba9..463f63e3 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Marketplace/Services/RecipientService.php +++ b/vendor/pagarme/ecommerce-module-core/src/Marketplace/Services/RecipientService.php @@ -13,6 +13,7 @@ use Pagarme\Core\Kernel\Exceptions\InvalidParamException; use Pagarme\Core\Kernel\Services\LocalizationService; use Pagarme\Core\Kernel\Services\LogService; +use Pagarme\Core\Kernel\ValueObjects\AbstractValidString; use Pagarme\Core\Kernel\ValueObjects\Id\RecipientId; use Pagarme\Core\Marketplace\Aggregates\Recipient; use Pagarme\Core\Marketplace\Factories\RecipientFactory; @@ -260,6 +261,17 @@ public function findByPagarmeId($pagarmeId) } } + /** + * @param string|AbstractValidString $pagarmeId + * */ + public function findSavedByPagarmeId($pagarmeId) + { + if (is_string($pagarmeId)) { + $pagarmeId = new RecipientId($pagarmeId); + } + return $this->recipientRepository->findByPagarmeId($pagarmeId); + } + public function delete($id) { $recipient = $this->recipientRepository->find($id); diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Factory/RecipientFactory.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Factory/RecipientFactory.php new file mode 100644 index 00000000..6230ad47 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Factory/RecipientFactory.php @@ -0,0 +1,181 @@ +createBankAccount($recipientData); + $transferSettings = $this->createTransferSettings($recipientData); + if ($recipientData['register_information']['type'] === Recipient::INDIVIDUAL) { + $registerInformation = $this->createIndividual($recipientData['register_information']); + } + if ($recipientData['register_information']['type'] === Recipient::CORPORATION) { + $registerInformation = $this->createCorportarion($recipientData['register_information']); + } + return $this->createBaseRecipient($bankAccount, $transferSettings, $registerInformation, $code); + } + + private function createCorportarion($recipientData) + { + $registerInformation = new CorporationRegisterInformation(); + $registerInformation->setEmail($recipientData['email']); + $registerInformation->setSiteUrl($recipientData['site_url']); + $document = new Document($recipientData['document']); + $registerInformation->setDocumentNumber($document->getDocumentWithoutMask()); + $registerInformation->setType($recipientData['type']); + $phoneArray = $this->cleanPhoneArray($recipientData['phone_number']); + foreach ($phoneArray as $phone) { + $phoneNumber = new Phones($phone['type'], $phone['number']); + $registerInformation->addPhoneNumbers($phoneNumber->convertToRegisterInformationPhonesRequest()); + } + $registerInformation->setCompanyName($recipientData['company_name']); + $registerInformation->setTradingName($recipientData['trading_name']); + $registerInformation->setAnnualRevenue(preg_replace("/\D/", "", $recipientData['annual_revenue'])); + $registerInformation->setCorporationType($recipientData['corporation_type']); + $registerInformation->setFoundingDate($recipientData['founding_date']); + foreach ($recipientData['managing_partners'] as $partner) { + $registerInformation->addManagingPartners($this->createManagingPartner($partner)); + } + $registerInformation->setAddress($this->createAddress($recipientData['main_address'])); + return $registerInformation->convertToSDKRequest(); + } + + + private function createIndividual($recipientData) + { + $document = new Document($recipientData['document']); + $registerInformation = new IndividualRegisterInformation(); + $registerInformation->setType($recipientData['type']); + $registerInformation->setDocumentNumber($document->getDocumentWithoutMask()); + $registerInformation->setEmail($recipientData['email']); + $registerInformation->setName($recipientData['name']); + $registerInformation->setSiteUrl($recipientData['site_url']); + $registerInformation->setMotherName($recipientData['mother_name']); + $phoneArray = $this->cleanPhoneArray($recipientData['phone_number']); + foreach ($phoneArray as $phone) { + $phoneNumber = new Phones($phone['type'], $phone['number']); + $registerInformation->addPhoneNumbers($phoneNumber->convertToRegisterInformationPhonesRequest()); + } + $registerInformation->setBirthdate($recipientData['birthdate']); + $registerInformation->setMonthlyIncome(preg_replace("/\D/", "", $recipientData['monthly_income'])); + $registerInformation->setProfessionalOccupation($recipientData['professional_occupation']); + $registerInformation->setAddress($this->createAddress($recipientData['address'])); + return $registerInformation->convertToSDKRequest(); + } + + private function createManagingPartner($partner) + { + $document = new Document($partner['document']); + $newPartner = new ManagingPartner(); + $newPartner->setType($partner['type']); + $newPartner->setName($partner['name']); + $newPartner->setDocumentNumber($document->getDocumentWithoutMask()); + $newPartner->setEmail($partner['email']); + $newPartner->setMotherName($partner['mother_name']); + $phoneArray = $this->cleanPhoneArray($partner['phone_number']); + foreach ($phoneArray as $phone) { + $phoneNumber = new Phones($phone['type'], $phone['number']); + $newPartner->addPhoneNumbers($phoneNumber->convertToRegisterInformationPhonesRequest()); + } + $newPartner->setBirthdate($partner['birthdate']); + $newPartner->setMonthlyIncome(preg_replace("/\D/", "", $partner['monthly_income'])); + $newPartner->setProfessionalOccupation($partner['professional_occupation']); + $newPartner->setAddress($this->createAddress($partner['address'])); + $newPartner->setSelfDeclaredLegalRepresentative(true); + return $newPartner->convertToArray(); + } + + private function createBankAccount($recipientData) + { + $holderDocument = new Document($recipientData["holder_document"]); + $bankAccount = new BankAccount(); + $bankAccount->setHolderName($recipientData['holder_name']); + $bankAccount->setHolderType($recipientData["holder_document_type"]); + $bankAccount->setHolderDocument($holderDocument->getDocumentWithoutMask()); + $bankAccount->setBank($recipientData["bank"]); + $bankAccount->setBranchNumber($recipientData["branch_number"]); + $bankAccount->setBranchCheckDigit($recipientData["branch_check_digit"]); + $bankAccount->setAccountNumber($recipientData["account_number"]); + $bankAccount->setAccountCheckDigit($recipientData["account_check_digit"]); + $bankAccount->setType($recipientData["account_type"]); + $bankAccount->setMetadata(null); + return $bankAccount->convertToSdk(); + } + + private function createTransferSettings($recipientData) + { + if ($recipientData['transfer_enabled'] === 0) { + return null; + } + + $transferSettings = new TransferSettings( + (bool)$recipientData['transfer_enabled'], + $recipientData['transfer_interval'], + $recipientData['transfer_day'] + ); + return $transferSettings->convertToSdkRequest(); + } + + private function createBaseRecipient($bankAccount, $transferSettings, $registerInformation, $code) + { + $recipient = new Recipient(); + $recipient->setBankAccount($bankAccount); + $recipient->setTransferSettings($transferSettings); + + // Product team decision + $recipient->setAutomaticAnticipationSettings(null); + + $recipient->setRegisterInformation($registerInformation); + $recipient->setCode($code); + return $recipient; + } + + private function createAddress($addressFields) + { + $address = new Address(); + $address->setZipCode($addressFields['zip_code']); + $address->setStreet($addressFields['street']); + $address->setStreetNumber($addressFields['street_number']); + $address->setComplementary($addressFields['complementary']); + $address->setReferencePoint($addressFields['reference_point']); + $address->setNeighborhood($addressFields['neighborhood']); + $address->setState($addressFields['state']); + $address->setCity($addressFields['city']); + return $address->convertToCreateRegisterInformationAddressRequest(); + } + + private function cleanPhoneArray($phoneArray) + { + $validPhones = []; + foreach ($phoneArray as $phone) { + if (empty($phone['number'])) { + continue; + } + $validPhones[] = $phone; + } + return $validPhones; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Account/PaymentEnum.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Account/PaymentEnum.php index a5e2ab04..955d67c6 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Account/PaymentEnum.php +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Account/PaymentEnum.php @@ -15,4 +15,6 @@ abstract class PaymentEnum const PIX = 'pix'; const VOUCHER = 'voucher'; + + const GOOGLEPAY = 'googlepay'; } diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Address.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Address.php new file mode 100644 index 00000000..edfc55bc --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Address.php @@ -0,0 +1,125 @@ +zipCode = $zipCode; + } + + public function setStreet($street) + { + $this->street = $street; + } + + public function setStreetNumber($street_number) + { + $this->street_number = $street_number; + } + + public function setComplementary($complementary) + { + $this->complementary = empty($complementary) ? "Nenhum" : $complementary; + } + + public function setReferencePoint($referencePoint) + { + $this->referencePoint = empty($referencePoint) ? "Nenhum" : $referencePoint; + } + + public function setNeighborhood($neighborhood) + { + $this->neighborhood = $neighborhood; + } + + public function setState($state) + { + $this->state = $state; + } + + public function setCity($city) + { + $this->city = $city; + } + + public function getZipCode() + { + return $this->zipCode; + } + + public function getStreet() + { + return $this->street; + } + + public function getStreetNumber() + { + return $this->street_number; + } + + public function getComplementary() + { + return $this->complementary; + } + + public function getReferencePoint() + { + return $this->referencePoint; + } + + public function getNeighborhood() + { + return $this->neighborhood; + } + + public function getState() + { + return $this->state; + } + + public function getCity() + { + return $this->city; + } + + public function convertToArray() + { + return array( + 'zip_code' => $this->getZipCode(), + 'street' => $this->getStreet(), + 'street_number' => $this->getStreetNumber(), + 'complementary' => $this->getComplementary(), + 'reference_point' => $this->getReferencePoint(), + 'neighbordhood' => $this->getNeighborhood(), + 'state' => $this->getState(), + 'city' => $this->getCity() + ); + } + + public function convertToCreateRegisterInformationAddressRequest() + { + return new CreateRegisterInformationAddressRequest( + $this->getStreet(), + $this->getComplementary(), + $this->getStreetNumber(), + $this->getNeighborhood(), + $this->getCity(), + $this->getState(), + $this->getZipCode(), + $this->getReferencePoint() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Common/Document.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Common/Document.php new file mode 100644 index 00000000..ff948c01 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Common/Document.php @@ -0,0 +1,24 @@ +setDocumentNumber($documentNumber); + } + + private function setDocumentNumber($document) + { + $this->documentNumber = $document; + } + public function getDocumentWithoutMask() + { + return preg_replace("/\D/" , "",$this->documentNumber); + } + +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BankAccount.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BankAccount.php new file mode 100644 index 00000000..5e51dd70 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BankAccount.php @@ -0,0 +1,140 @@ +holderName; + } + + public function getHolderType() + { + return $this->holderType; + } + + public function getHolderDocument() + { + return $this->holderDocument; + } + + public function getBank() + { + return $this->bank; + } + + public function getBranchNumber() + { + return $this->branchNumber; + } + + public function getBranchCheckDigit() + { + return $this->branchCheckDigit; + } + + public function getAccountNumber() + { + return $this->accountNumber; + } + + public function getAccountCheckDigit() + { + return $this->accountCheckDigit; + } + + public function getType() + { + return $this->type; + } + + public function getMetadata() + { + return $this->metadata; + } + + + public function setHolderName($holderName): void + { + $this->holderName = $holderName; + } + + public function setHolderType($holderType): void + { + $this->holderType = $holderType; + } + + public function setHolderDocument($holderDocument): void + { + $this->holderDocument = $holderDocument; + } + + public function setBank($bank): void + { + $this->bank = $bank; + } + + public function setBranchNumber($branchNumber): void + { + $this->branchNumber = $branchNumber; + } + + public function setBranchCheckDigit($branchCheckDigit): void + { + if ($branchCheckDigit === '') { + return; + } + $this->branchCheckDigit = $branchCheckDigit; + } + + public function setAccountNumber($accountNumber): void + { + $this->accountNumber = $accountNumber; + } + + public function setAccountCheckDigit($accountCheckDigit): void + { + $this->accountCheckDigit = $accountCheckDigit; + } + + public function setType($type): void + { + $this->type = $type; + } + + public function setMetadata($metadata): void + { + $this->metadata = $metadata; + } + + public function convertToSdk() + { + return new CreateBankAccountRequest( + $this->getHolderName(), + $this->getHolderType(), + $this->getHolderDocument(), + $this->getBank(), + $this->getBranchNumber(), + $this->getBranchCheckDigit(), + $this->getAccountNumber(), + $this->getAccountCheckDigit(), + $this->getType(), + $this->getMetadata(), + null + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BasePersonInformation.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BasePersonInformation.php new file mode 100644 index 00000000..128bb3a0 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BasePersonInformation.php @@ -0,0 +1,68 @@ +name = $name; + } + + public function setMotherName($motherName) + { + if(empty($motherName)) { + return; + } + $this->motherName = $motherName; + } + + public function setBirthdate($birthdate) + { + $this->birthdate = $birthdate; + } + + public function setMonthlyIncome($monthlyIncome) + { + if($monthlyIncome < 0) { + throw new \InvalidArgumentException("Monthly income cannot be negative"); + } + $this->monthlyIncome = $monthlyIncome; + } + + public function setProfessionalOccupation($professionalOccupation) + { + $this->professionalOccupation = $professionalOccupation; + } + + public function getName() + { + return $this->name; + } + + public function getMotherName() + { + return $this->motherName; + } + + public function getBirthdate() + { + return $this->birthdate; + } + + public function getMonthlyIncome() + { + return $this->monthlyIncome; + } + + public function getProfessionalOccupation() + { + return $this->professionalOccupation; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BaseRegisterInformation.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BaseRegisterInformation.php new file mode 100644 index 00000000..973a2e80 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/BaseRegisterInformation.php @@ -0,0 +1,88 @@ +type = $type; + } + + public function setDocumentNumber($documentNumber) + { + $this->documentNumber = $documentNumber; + } + + public function setEmail($email) + { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + throw new InvalidArgumentException('Invalid e-mail'); + } + $this->email = $email; + } + + public function setSiteUrl($siteUrl) + { + if (empty($siteUrl)) { + return; + } + if (!filter_var($siteUrl, FILTER_VALIDATE_URL)) { + throw new InvalidArgumentException("Site Url is not valid!"); + } + $this->siteUrl = $siteUrl; + } + + public function setAddress($address) + { + $this->address = $address; + } + + public function addPhoneNumbers($phoneNumbers) + { + $this->phoneNumbers[] = $phoneNumbers; + } + + public function getType() + { + return $this->type; + } + + public function getPhoneNumbers() + { + return $this->phoneNumbers; + } + + public function getDocumentNumber() + { + return $this->documentNumber; + } + + public function getEmail() + { + return $this->email; + } + + public function getSiteUrl() + { + return $this->siteUrl; + } + + public function getAddress() + { + return $this->address; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/CorporationRegisterInformation.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/CorporationRegisterInformation.php new file mode 100644 index 00000000..6adf14e9 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/CorporationRegisterInformation.php @@ -0,0 +1,94 @@ +companyName = $companyName; + } + + public function setCorporationType($corporationType) + { + $this->corporationType = $corporationType; + } + + + public function setTradingName($tradingName) + { + $this->tradingName = $tradingName; + } + + public function setAnnualRevenue($annualRevenue) + { + $this->annualRevenue = $annualRevenue; + } + + public function setFoundingDate($foundingDate) + { + $this->foundingDate = $foundingDate; + } + + public function addManagingPartners($managingPartners) + { + $this->managingPartners[] = $managingPartners; + } + + public function getCompanyName() + { + return $this->companyName; + } + + public function getCorporationType() + { + return $this->corporationType; + } + + public function getTradingName() + { + return $this->tradingName; + } + + public function getAnnualRevenue() + { + return $this->annualRevenue; + } + + public function getFoundingDate() + { + return $this->foundingDate; + } + + public function getManagingPartners() + { + return $this->managingPartners; + } + + public function convertToSDKRequest() + { + return new CreateRegisterInformationCorporationRequest( + $this->getEmail(), + $this->getDocumentNumber(), + $this->getType(), + $this->getSiteUrl(), + $this->getPhoneNumbers(), + $this->getCompanyName(), + $this->getCorporationType(), + $this->getTradingName(), + $this->getAnnualRevenue(), + $this->getFoundingDate(), + $this->getManagingPartners(), + $this->getAddress() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/IndividualRegisterInformation.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/IndividualRegisterInformation.php new file mode 100644 index 00000000..ae715325 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/IndividualRegisterInformation.php @@ -0,0 +1,25 @@ +getEmail(), + $this->getDocumentNumber(), + $this->getType(), + $this->getSiteUrl(), + $this->getPhoneNumbers(), + $this->getName(), + $this->getMotherName(), + $this->getBirthdate(), + $this->getMonthlyIncome(), + $this->getProfessionalOccupation(), + $this->getAddress() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/ManagingPartner.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/ManagingPartner.php new file mode 100644 index 00000000..370dcd04 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/ManagingPartner.php @@ -0,0 +1,35 @@ +selfDeclaredLegalRepresentative = $selfDeclaredLegalRepresentative; + } + + public function getSelfDeclaredLegalRepresentative() + { + return $this->selfDeclaredLegalRepresentative; + } + + public function convertToArray() + { + return array( + 'type' => $this->getType(), + 'document' => $this->getDocumentNumber(), + 'email' => $this->getEmail(), + 'name' => $this->getName(), + 'mother_name' => $this->getMotherName(), + 'phone_numbers' => $this->getPhoneNumbers(), + 'birthdate' => $this->getBirthdate(), + 'monthly_income' => $this->getMonthlyIncome(), + 'professional_occupation' => $this->getProfessionalOccupation(), + 'address' => $this->getAddress(), + 'self_declared_legal_representative' => $this->getSelfDeclaredLegalRepresentative() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/TransferSettings.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/TransferSettings.php new file mode 100644 index 00000000..fedfe4a9 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Marketplace/TransferSettings.php @@ -0,0 +1,111 @@ +setTransferEnabled($transferEnabled); + $this->setTransferInterval($transferInterval); + $this->setTransferDay($transferDay); + } + + private function setTransferEnabled($transferEnabled): void + { + $this->transferEnabled = $transferEnabled; + } + + private function setTransferInterval($transferInterval): void + { + if (!in_array($transferInterval, self::VALID_TRANSFER_INTERVAL)) { + throw new InvalidArgumentException("Invalid argument to transferInterval"); + } + $this->transferInterval = $transferInterval; + } + + private function setTransferDay($transferDay): void + { + if ($this->getTransferInterval() === self::TRANSFER_INTERVAL_DAILY) { + $this->transferDay = 0; + return; + } + $this->validateTransferDay($transferDay); + $this->transferDay = $transferDay; + } + + private function validateTransferDay($transferDay) + { + if ($this->getTransferInterval() === self::TRANSFER_INTERVAL_WEEKLY && !$this->isValidForWeeklyInterval($transferDay)) { + throw new InvalidArgumentException("Invalid Transfer Day to Weekly Transfer Interval!"); + } + if ($this->getTransferInterval() === self::TRANSFER_INTERVAL_MONTHLY && !$this->isValidForMonthlyInterval($transferDay)) { + throw new InvalidArgumentException("Invalid Transfer Day to Monthly Transfer Interval!"); + } + return true; + } + + private function isValidForWeeklyInterval($transferDay) + { + if ((int) $transferDay >= 1 && (int) $transferDay <= 5) { + return true; + } + return false; + } + private function isValidForMonthlyInterval($transferDay) + { + if ($transferDay >= 1 && $transferDay <= 31) { + return true; + } + return false; + } + + public function getTransferEnabled() + { + return $this->transferEnabled; + } + + public function getTransferInterval() + { + return $this->transferInterval; + } + + public function getTransferDay() + { + return $this->transferDay; + } + + + public function convertToArray() + { + return array ( + 'transfer_enabled' => $this->getTransferEnabled(), + 'transfer_interval' => $this->getTransferInterval(), + 'transfer_day' => $this->getTransferDay() + ); + } + + public function convertToSdkRequest() + { + return new CreateTransferSettingsRequest( + $this->getTransferEnabled(), + $this->getTransferInterval(), + $this->getTransferDay() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Phones.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Phones.php new file mode 100644 index 00000000..079b3653 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Phones.php @@ -0,0 +1,65 @@ +typePhone = $typePhone; + $this->phoneNumber = $phoneNumber; + $this->areaCode = $areaCode; + if($areaCode === null) { + $this->populateAreaCodeAndPhoneByString($phoneNumber); + } + } + + public function populateAreaCodeAndPhoneByString($phoneNumber) + { + $phone = $this->cleanPhone($phoneNumber); + $this->areaCode = substr($phone, 0, 2); + $this->phoneNumber = substr($phone, 2, 11); + } + + private function cleanPhone($phoneNumber) + { + return preg_replace('/\D/', '', $phoneNumber);; + } + + + public function getTypePhone() + { + return $this->typePhone; + } + public function getAreaCode() + { + return $this->areaCode; + } + public function getPhoneNumber() + { + return $this->phoneNumber; + } + + public function convertToArray() + { + return array( + 'type' => $this->getTypePhone(), + 'ddd' => $this->getAreaCode(), + 'number' => $this->getPhoneNumber() + ); + } + + public function convertToRegisterInformationPhonesRequest() + { + return new CreateRegisterInformationPhoneRequest( + $this->getAreaCode(), + $this->getPhoneNumber(), + $this->getTypePhone() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Recipient.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Recipient.php new file mode 100644 index 00000000..47a70631 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Model/Recipient.php @@ -0,0 +1,80 @@ +bankAccount = $bankAccount; + } + + + public function setRegisterInformation($registerInformation): void + { + $this->registerInformation = $registerInformation; + } + + public function setTransferSettings($transferSettings): void + { + $this->transferSettings = $transferSettings; + } + + public function setAutomaticAnticipationSettings($automaticAnticipationSettings): void + { + $this->automaticAnticipationSettings = $automaticAnticipationSettings; + } + + public function setCode($code): void + { + $this->code = $code; + } + + public function getBankAccount() + { + return $this->bankAccount; + } + + public function getTransferSettings() + { + return $this->transferSettings; + } + + public function getAutomaticAnticipationSettings() + { + return $this->automaticAnticipationSettings; + } + + public function getRegisterInformation() + { + return $this->registerInformation; + } + + public function getCode() + { + return $this->code; + } + + public function convertToCreateRequest() + { + return new CreateRecipientRequest( + $this->getBankAccount(), + $this->getTransferSettings(), + $this->getAutomaticAnticipationSettings(), + $this->getRegisterInformation(), + $this->getCode() + ); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Middle/Proxy/RecipientProxy.php b/vendor/pagarme/ecommerce-module-core/src/Middle/Proxy/RecipientProxy.php new file mode 100644 index 00000000..299090bd --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Middle/Proxy/RecipientProxy.php @@ -0,0 +1,48 @@ +client = $auth->services(); + } + + public function create(Recipient $recipient) + { + /** + * @var \PagarmeCoreApiLib\Controllers\RecipientsController + */ + $recipientRequest = $this->client->getRecipients()->createRecipient( + $recipient->convertToCreateRequest() + ); + return $recipientRequest; + } + + public function getFromPagarme($recipientId) + { + $recipientRequest = $this->client->getRecipients()->getRecipient( + $recipientId + ); + return $recipientRequest; + } + + public function createKycLink($recipientId) + { + $kycLinkResponse = $this->client->getRecipients()->createKycLink( + $recipientId + ); + return $kycLinkResponse; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Order.php b/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Order.php index c13a68c8..c0eba08a 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Order.php +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Order.php @@ -347,7 +347,7 @@ public function setSplitData($splitData) * @return mixed data which can be serialized by json_encode, * which is a value of any type other than a resource. * @since 5.4.0 - */ + */ #[\ReturnTypeWillChange] public function jsonSerialize() @@ -527,4 +527,8 @@ private function debitPaymentMethod() { return PaymentMethod::debit_card(); } + private function googlepayPaymentMethod() + { + return PaymentMethod::googlepay(); + } } diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Payments/GooglePayPayment.php b/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Payments/GooglePayPayment.php new file mode 100644 index 00000000..12af1e18 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/Aggregates/Payments/GooglePayPayment.php @@ -0,0 +1,117 @@ +additionalInformation; + } + + /** + * @param array $billingAddress + */ + public function setBillingAddress($billingAddress) + { + $this->billingAddress = $billingAddress; + } + + /** + * @param array $additionalInformation + */ + public function setAdditionalInformation($additionalInformation) + { + $this->additionalInformation = $additionalInformation; + } + + static public function getBaseCode() + { + return PaymentMethod::creditCard()->getMethod(); + } + + public function getGooglePayload() + { + return $this->getParsedGooglePayload(); + } + + private function getParsedGooglePayload() + { + $payload = json_decode($this->getAdditionalInformation()->googlepayData, true); + $this->parseVersion($payload); + $this->parseSignedMessage($payload); + $this->parseIntermediateSigningKey($payload); + $payload['merchant_identifier'] = $this->getMerchantIdentifier(); + return $payload; + } + + private function parseIntermediateSigningKey(&$payload) + { + $payload['intermediate_signing_key'] = $payload['intermediateSigningKey']; + $payload['intermediate_signing_key']['signed_key'] = $payload['intermediate_signing_key']['signedKey']; + unset($payload['intermediateSigningKey']); + unset($payload['intermediate_signing_key']['signedKey']); + } + + private function parseSignedMessage(&$payload) + { + $payload['signed_message'] = $payload['signedMessage']; + unset($payload['signedMessage']); + } + + private function parseVersion(&$payload) + { + $payload['version'] = $payload['protocolVersion']; + unset($payload['protocolVersion']); + } + + private function getMerchantIdentifier() + { + return $this->moduleConfig->getGooglePayConfig()->getMerchantId(); + } + + private function getStatementDescriptor() + { + return $this->moduleConfig->getCardStatementDescriptor(); + } + + private function getBillingAddress() + { + return $this->billingAddress; + } + + /** + * @return CreateGooglePayPaymentRequest + */ + protected function convertToPrimitivePaymentRequest() + { + $payload = new \stdClass(); + $payload->type = "google_pay"; + $payload->google_pay = $this->getGooglePayload(); + $card = new \stdClass(); + $card->billing_address = $this->getBillingAddress(); + return new CreateGooglePayPaymentRequest($this->getStatementDescriptor(), $payload, $card); + } +} diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/Factories/PaymentFactory.php b/vendor/pagarme/ecommerce-module-core/src/Payment/Factories/PaymentFactory.php index 312835a5..62e419e0 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Payment/Factories/PaymentFactory.php +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/Factories/PaymentFactory.php @@ -14,6 +14,7 @@ use Pagarme\Core\Payment\Aggregates\Payments\NewDebitCardPayment; use Pagarme\Core\Payment\Aggregates\Payments\NewVoucherPayment; use Pagarme\Core\Payment\Aggregates\Payments\PixPayment; +use Pagarme\Core\Payment\Aggregates\Payments\GooglePayPayment; use Pagarme\Core\Payment\Aggregates\Payments\SavedCreditCardPayment; use Pagarme\Core\Payment\Aggregates\Payments\SavedVoucherCardPayment; use Pagarme\Core\Payment\ValueObjects\BoletoBank; @@ -39,6 +40,7 @@ public function __construct() 'createVoucherPayments', 'createDebitCardPayments', 'createPixPayments', + 'createGooglePayPayments', ]; $this->moduleConfig = MPSetup::getModuleConfiguration(); @@ -281,6 +283,43 @@ private function createPixPayments($data) return $payments; } + + /** + * @param array $data + * @return GooglePayPayment[] + * @throws InvalidParamException + */ + private function createGooglePayPayments($data) + { + $googlepayDataIndex = "googlepay"; + + if (!isset($data->$googlepayDataIndex)) { + return []; + } + + $googlepayData = $data->$googlepayDataIndex; + + $payments = []; + foreach ($googlepayData as $value) { + $payment = new GooglePayPayment(); + + $customer = $this->createCustomer($value); + if ($customer !== null) { + $payment->setCustomer($customer); + } + + if (!empty($value->additionalInformation)) { + $payment->setAdditionalInformation($value->additionalInformation); + } + $payment->setBillingAddress($value->billing_address); + $payment->setAmount($value->amount); + + $payments[] = $payment; + } + + return $payments; + } + /** * @param $identifier * @return AbstractCreditCardPayment|null diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/CustomerRepository.php b/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/CustomerRepository.php index 63c32480..235861a7 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/CustomerRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/CustomerRepository.php @@ -15,6 +15,7 @@ final class CustomerRepository extends AbstractRepository public function findByCode($customerCode) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_CUSTOMER); + $customerCode = filter_var($customerCode, FILTER_SANITIZE_SPECIAL_CHARS); $query = "SELECT * FROM $table WHERE code = '$customerCode'"; $result = $this->db->fetch($query); @@ -59,6 +60,7 @@ protected function update(AbstractEntity &$object) public function deleteByCode($customerCode) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_CUSTOMER); + $customerCode = filter_var($customerCode, FILTER_SANITIZE_SPECIAL_CHARS); $query = "DELETE FROM $table WHERE code = '$customerCode'"; return $this->db->query($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/SavedCardRepository.php b/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/SavedCardRepository.php index eda5cf48..a8e1a99f 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/SavedCardRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/Repositories/SavedCardRepository.php @@ -97,6 +97,7 @@ public function delete(AbstractEntity $object) public function find($objectId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_SAVED_CARD); + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = '$objectId'"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Payment/ValueObjects/PaymentMethod.php b/vendor/pagarme/ecommerce-module-core/src/Payment/ValueObjects/PaymentMethod.php index f3a47954..2dadbe33 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Payment/ValueObjects/PaymentMethod.php +++ b/vendor/pagarme/ecommerce-module-core/src/Payment/ValueObjects/PaymentMethod.php @@ -16,6 +16,7 @@ final class PaymentMethod extends AbstractValueObject const CASH = 'cash'; const DEBIT_CARD = 'debitCard'; const PIX = 'pix'; + const GOOGLEPAY = 'googlepay'; private $method; @@ -48,6 +49,10 @@ static public function pix() { return new self(self::PIX); } + static public function googlepay() + { + return new self(self::GOOGLEPAY); + } static public function ticket() { diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ChargeRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ChargeRepository.php index a1d960c4..a9998b9d 100755 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ChargeRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ChargeRepository.php @@ -166,7 +166,7 @@ public function findByInvoiceId($invoiceId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_CHARGE ); - + $invoiceId = filter_var($invoiceId, FILTER_SANITIZE_SPECIAL_CHARS); $query = " SELECT id, @@ -264,7 +264,7 @@ public function findByCode($codeOrder) $transactionTable = $this->db->getTable( AbstractDatabaseDecorator::TABLE_TRANSACTION ); - + $codeOrder = filter_var($codeOrder, FILTER_SANITIZE_SPECIAL_CHARS); $query = " SELECT recurrence_charge.*, diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/PlanRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/PlanRepository.php index b26b0384..26838104 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/PlanRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/PlanRepository.php @@ -94,6 +94,7 @@ public function find($objectId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_PRODUCTS_PLAN ); + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = '$objectId' LIMIT 1"; $result = $this->db->fetch($query); @@ -187,6 +188,7 @@ public function findByProductId($productId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_PRODUCTS_PLAN ); + $productId = filter_var($productId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE product_id = '{$productId}' LIMIT 1"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ProductSubscriptionRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ProductSubscriptionRepository.php index c5b53d7a..1452774f 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ProductSubscriptionRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/ProductSubscriptionRepository.php @@ -104,7 +104,7 @@ public function find($objectId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_PRODUCTS_SUBSCRIPTION ); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = $objectId"; $result = $this->db->fetch($query); @@ -171,6 +171,7 @@ public function findByProductId($productId) $table = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_PRODUCTS_SUBSCRIPTION ); + $productId = filter_var($productId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE product_id = $productId"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/RepetitionRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/RepetitionRepository.php index 93361181..fda981c9 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/RepetitionRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/RepetitionRepository.php @@ -63,7 +63,7 @@ public function delete(AbstractEntity $object) public function deleteBySubscriptionId($subscriptionProductId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_REPETITIONS); - + $subscriptionProductId = filter_var($subscriptionProductId, FILTER_SANITIZE_NUMBER_INT); $query = "DELETE FROM $table WHERE subscription_id = {$subscriptionProductId}"; $this->db->query($query); @@ -72,7 +72,7 @@ public function deleteBySubscriptionId($subscriptionProductId) public function find($objectId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_REPETITIONS); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = $objectId"; $result = $this->db->fetch($query); @@ -100,7 +100,7 @@ public function listEntities($limit, $listDisabled) public function findBySubscriptionId($subscriptionId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_REPETITIONS); - + $subscriptionId = filter_var($subscriptionId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE subscription_id = $subscriptionId"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubProductRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubProductRepository.php index 0844da5f..43343795 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubProductRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubProductRepository.php @@ -105,7 +105,8 @@ public function findByRecurrence($recurrenceEntity) public function findByRecurrenceIdAndProductId($recurrenceId, $productId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_RECURRENCE_SUB_PRODUCTS); - + $recurrenceId = filter_var($recurrenceId, FILTER_SANITIZE_NUMBER_INT); + $productId = filter_var($productId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table" . " WHERE product_recurrence_id = {$recurrenceId}" . " AND product_id = '{$productId}'"; diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionItemRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionItemRepository.php index 82f5107f..97fac6fe 100755 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionItemRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionItemRepository.php @@ -77,7 +77,7 @@ public function findByCode($code) $subscriptionItemTable = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_ITEM ); - + $code = filter_var($code, FILTER_SANITIZE_SPECIAL_CHARS); $query = " SELECT * FROM {$subscriptionItemTable} @@ -167,7 +167,7 @@ public function find($objectId) $subscriptionItemTable = $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION_ITEM ); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM {$subscriptionItemTable} WHERE id = '" . $objectId . "'"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionRepository.php b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionRepository.php index b84f0eed..e5cbb4e9 100755 --- a/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Recurrence/Repositories/SubscriptionRepository.php @@ -53,7 +53,7 @@ public function findByCode($code) $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION ); - + $code = filter_var($code, FILTER_SANITIZE_SPECIAL_CHARS); $query = " SELECT * FROM {$subscriptionTable} as recurrence_subscription @@ -170,7 +170,7 @@ public function find($objectId) $this->db->getTable( AbstractDatabaseDecorator::TABLE_RECURRENCE_SUBSCRIPTION ); - + $objectId = filter_var($objectId, FILTER_SANITIZE_NUMBER_INT); $query = "SELECT * FROM $table WHERE id = '" . $objectId . "'"; $result = $this->db->fetch($query); @@ -236,7 +236,7 @@ public function findByCustomerId($customerId) $customerTable = $this->db->getTable( AbstractDatabaseDecorator::TABLE_CUSTOMER) ; - + $customerId = filter_var($customerId, FILTER_SANITIZE_SPECIAL_CHARS); $query = " SELECT recurrence_subscription.* FROM {$recurrenceTable} as recurrence_subscription diff --git a/vendor/pagarme/ecommerce-module-core/src/Webhook/Aggregates/Webhook.php b/vendor/pagarme/ecommerce-module-core/src/Webhook/Aggregates/Webhook.php index 61ab4c03..33c3de60 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Webhook/Aggregates/Webhook.php +++ b/vendor/pagarme/ecommerce-module-core/src/Webhook/Aggregates/Webhook.php @@ -55,6 +55,13 @@ public function setComponent($data) return $this; } + if ( + $this->type->getEntityType() == 'recipient' + ) { + $this->component = 'Marketplace'; + return $this; + } + $this->component = 'Kernel'; return $this; } diff --git a/vendor/pagarme/ecommerce-module-core/src/Webhook/Repositories/WebhookRepository.php b/vendor/pagarme/ecommerce-module-core/src/Webhook/Repositories/WebhookRepository.php index b78dcd2e..1ee6aba6 100644 --- a/vendor/pagarme/ecommerce-module-core/src/Webhook/Repositories/WebhookRepository.php +++ b/vendor/pagarme/ecommerce-module-core/src/Webhook/Repositories/WebhookRepository.php @@ -31,6 +31,7 @@ public function delete(AbstractEntity $object) public function find($objectId) { $table = $this->db->getTable(AbstractDatabaseDecorator::TABLE_WEBHOOK); + $objectId = filter_var($objectId, FILTER_SANITIZE_SPECIAL_CHARS); $query = "SELECT * FROM $table WHERE id = '$objectId'"; $result = $this->db->fetch($query); diff --git a/vendor/pagarme/ecommerce-module-core/src/Webhook/Services/RecipientHandlerService.php b/vendor/pagarme/ecommerce-module-core/src/Webhook/Services/RecipientHandlerService.php new file mode 100644 index 00000000..6500d2af --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/src/Webhook/Services/RecipientHandlerService.php @@ -0,0 +1,87 @@ +getActionHandle($webhook->getType()->getAction()); + + if (method_exists($this, $handler)) { + return $this->$handler($webhook); + } + + $type = "{$webhook->getType()->getEntityType()}.{$webhook->getType()->getAction()}"; + $message = sprintf(static::WEBHOOK_NOT_IMPLEMENTED_MESSAGE, $type); + $this->getLogService()->info($message); + + return [ + "message" => $message, + "code" => static::STATUS_CODE + ]; + } + + protected function handleUpdated(Webhook $webhook) + { + $recipientService = new RecipientService(); + /** @var Recipient $recipientEntity */ + $recipientEntity = $webhook->getEntity(); + $foundedRecipent = $recipientService->findSavedByPagarmeId($recipientEntity->getPagarmeId()); + if (empty($foundedRecipent)) { + $message = sprintf(static::RECIPIENT_NOT_FOUNDED_MESSAGE, $recipientEntity->getPagarmeId()); + $this->getLogService()->info($message); + return [ + "message" => $message, + "code" => static::STATUS_CODE + ]; + } + + $foundedRecipent->setStatus($recipientEntity->getStatus()); + + $recipientService->saveRecipient($foundedRecipent); + + return [ + "message" => static::RECIPIENT_UPDATED_MESSAGE, + "code" => static::STATUS_CODE + ]; + } + + protected function getActionHandle($action) + { + $baseActions = explode('_', $action ?? ''); + $action = ''; + foreach ($baseActions as $baseAction) { + $action .= ucfirst($baseAction); + } + + return 'handle' . $action; + } + + protected function getLogService() + { + return new LogService('Webhook', true); + } +} \ No newline at end of file diff --git a/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Aggregates/RecipientTest.php b/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Aggregates/RecipientTest.php new file mode 100644 index 00000000..f7fe30d4 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Aggregates/RecipientTest.php @@ -0,0 +1,33 @@ +assertEquals($expectedStatus, $result); + } + + public function statusDataProvider() + { + return [ + "Registered status" => ["registration", "pending", RecipientInterface::REGISTERED], + "Validation Request status" => ["affiliation", "partially_denied", RecipientInterface::VALIDATION_REQUESTED], + "Waiting for analysis status" => ["affiliation", "pending", RecipientInterface::WAITING_FOR_ANALYSIS], + "Active status" => ["active", "approved", RecipientInterface::ACTIVE], + "Disapproved status" => ["registration", "denied", RecipientInterface::DISAPPROVED], + "Suspended status" => ["suspended", "", RecipientInterface::SUSPENDED], + "Blocked status" => ["blocked", "", RecipientInterface::BLOCKED], + "Inactive status" => ["inactive", "", RecipientInterface::INACTIVE], + ]; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Factories/RecipientFactoryTest.php b/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Factories/RecipientFactoryTest.php new file mode 100644 index 00000000..6e9dc745 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/tests/Marketplace/Factories/RecipientFactoryTest.php @@ -0,0 +1,91 @@ + $pagarmeId, + "name" => "Test recipient", + "email" => "test@recipient.test", + "document" => "11111111111", + "description" => "Test description", + "type" => "individual", + "payment_mode" => "bank_transfer", + "status" => "active", + "kyc_details" => + [ + "status" => "approved" + ], + ]; + + $recipientFactory = new RecipientFactory(); + + $result = $recipientFactory->createFromPostData($webhookData); + $this->assertSame($result->getStatus(), RecipientInterface::ACTIVE); + $this->assertSame($result->getPagarmeId()->getValue(), $webhookData['id']); + } + + public function testCreateFromDbDataShouldCreateWithStatus() + { + $dbData = [ + "id" => 1, + "external_id" => 2, + "name" => "Test recipient", + "email" => "test@recipient.test", + "document" => "11111111111", + "type" => "cpf", + "pagarme_id" => "rp_xxxxxxxxxxxxxxxx", + "status" => RecipientInterface::ACTIVE, + ]; + + $recipientFactory = new RecipientFactory(); + + $result = $recipientFactory->createFromDbData($dbData); + $this->assertSame($result->getStatus(), RecipientInterface::ACTIVE); + } + + public function webhookDataProvider() + { + return [ + "webhook with kyc_details" => [ + [ + "id" => 'rp_xxxxxxxxxxxxxxxx', + "name" => "Test recipient", + "email" => "test@recipient.test", + "document" => "11111111111", + "description" => "Test description", + "type" => "individual", + "payment_mode" => "bank_transfer", + "status" => "active", + "kyc_details" => + [ + "status" => "approved" + ], + ] + ], + "webhook without kyc_details" => [ + [ + "id" => 'rp_xxxxxxxxxxxxxxxx', + "name" => "Test recipient", + "email" => "test@recipient.test", + "document" => "11111111111", + "description" => "Test description", + "type" => "individual", + "payment_mode" => "bank_transfer", + "status" => "active", + ] + ], + ]; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/tests/Middle/Factory/RecipientFactoryTest.php b/vendor/pagarme/ecommerce-module-core/tests/Middle/Factory/RecipientFactoryTest.php new file mode 100644 index 00000000..28fb889d --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/tests/Middle/Factory/RecipientFactoryTest.php @@ -0,0 +1,195 @@ +getIndividualArrayData(); + $recipientFactory = new RecipientFactory(); + $result = $recipientFactory->createRecipient($arrayDataValid); + $this->assertInstanceOf(CreateBankAccountRequest::class, $result->getBankAccount()); + $this->assertInstanceOf(CreateTransferSettingsRequest::class, $result->getTransferSettings()); + $this->assertNull($result->getAutomaticAnticipationSettings()); + $this->assertInstanceOf(CreateRegisterInformationIndividualRequest::class, $result->getRegisterInformation()); + $this->assertInstanceOf(Recipient::class, $result); + } + + public function testCreateNewCorporationRecipientWithAllDataValid() + { + $arrayDataValid = $this->getCorporationArrayData(); + $recipientFactory = new RecipientFactory(); + $result = $recipientFactory->createRecipient($arrayDataValid); + $this->assertInstanceOf(CreateBankAccountRequest::class, $result->getBankAccount()); + $this->assertInstanceOf(CreateTransferSettingsRequest::class, $result->getTransferSettings()); + $this->assertNull($result->getAutomaticAnticipationSettings()); + $this->assertInstanceOf(CreateRegisterInformationCorporationRequest::class, $result->getRegisterInformation()); + $this->assertInstanceOf(Recipient::class, $result); + } + + + /** + * @expectedException + */ + public function testCreateNewRecipientWithEmptyArray() + { + $this->expectError(); + $arrayDataValid = []; + $recipientFactory = new RecipientFactory(); + $recipientFactory->createRecipient($arrayDataValid); + } + + private function getIndividualArrayData() + { + return [ + "register_information" => [ + "webkul_seller" => "3", + "external_id" => "128693", + "type" => "individual", + "document" => "123.456.789-10", + "name" => "Teste teste", + "email" => "teste@teste.com", + "site_url" => "https://teste.com", + "mother_name" => "Teste", + "birthdate" => "01/03/1989", + "monthly_income" => "150.000,00", + "professional_occupation" => "Teste", + "phone_number" => [ + [ + "type" => "home_phone", + "number" => "(99) 9999-9999" + ], + [ + "type" => "mobile_phone", + "number" => "(99) 9111-1111" + ] + ], + "address" => [ + "zip_code" => "12345-678", + "street" => "Rua Teste", + "street_number" => "123", + "complementary" => "Teste Complemento", + "reference_point" => "Teste Referencia", + "neighborhood" => "Teste Bairro", + "state" => "SP", + "city" => "São Paulo", + ] + + ], + "existing_recipient" => "0", + "holder_name" => "Teste teste", + "holder_document_type" => "individual", + "holder_document" => "123.456.789-10", + "bank" => "001", + "branch_number" => "0000", + "branch_check_digit" => "1", + "account_number" => "1234567", + "account_check_digit" => "1", + "account_type" => "checking", + "transfer_enabled" => "1", + "transfer_interval" => "Weekly", + "transfer_day" => "3" + ]; + } + private function getCorporationArrayData() + { + return [ + "register_information" => [ + "webkul_seller" => "4", + "external_id" => "150894", + "type" => "corporation", + "document" => "12.345.678/0001-10", + "name" => "Teste teste", + "company_name" => "Teste empresarial Ltda", + "trading_name" => "Teste empresarial", + "email" => "teste@teste.com", + "site_url" => "https://teste.com", + "birthdate" => "01/03/1983", + "annual_revenue" => "1.500.000,00", + "corporation_type" => "Sociedade Empresária Limitada", + "founding_date" => "11/09/2013", + "phone_number" => [ + [ + "type" => "home_phone", + "number" => "(99) 9999-9999" + ], + [ + "type" => "mobile_phone", + ] + ], + "main_address" => [ + "zip_code" => "12345-678", + "street" => "Rua Teste", + "street_number" => "123", + "complementary" => "Teste Complemento", + "reference_point" => "Teste Referencia", + "neighborhood" => "Teste Bairro", + "state" => "SP", + "city" => "São Paulo", + ], + "managing_partners" => [ + [ + "name" => "Teste teste", + "type" => "individual", + "document" => "123.456.789-10", + "mother_name" => "Teste teste", + "email" => "teste@teste.com", + "birthdate" => "01/03/1995", + "monthly_income" => "1.500,00", + "professional_occupation" => "Sócio-Administrador", + "self_declared_legal_representative" => "1", + "phone_number" => [ + [ + "type" => "home_phone", + "number" => "(99) 9999-9999" + ], + [ + "type" => "mobile_phone", + ] + ], + "address" => [ + "zip_code" => "12345-678", + "street" => "Rua Teste", + "street_number" => "123", + "complementary" => "Teste Complemento", + "reference_point" => "Teste Referencia", + "neighborhood" => "Teste Bairro", + "state" => "SP", + "city" => "São Paulo", + ] + + ] + ] + ], + "holder_name" => "Teste empresarial Ltda", + "holder_document_type" => "company", + "holder_document" => "12.345.678/0001-10", + "bank" => "001", + "branch_number" => "1234", + "branch_check_digit" => "1", + "account_number" => "1234567", + "account_check_digit" => "1", + "account_type" => "checking", + "transfer_enabled" => "1", + "transfer_interval" => "Monthly", + "transfer_day" => "19", + + ]; + } +} diff --git a/vendor/pagarme/ecommerce-module-core/tests/Webhook/Aggregates/WebhookTest.php b/vendor/pagarme/ecommerce-module-core/tests/Webhook/Aggregates/WebhookTest.php index 000d2484..d1ee2441 100644 --- a/vendor/pagarme/ecommerce-module-core/tests/Webhook/Aggregates/WebhookTest.php +++ b/vendor/pagarme/ecommerce-module-core/tests/Webhook/Aggregates/WebhookTest.php @@ -2,11 +2,12 @@ namespace Pagarme\Core\Test\Webhook\Aggregates; -use Pagarme\Core\Recurrence\Aggregates\Charge; +use PHPUnit\Framework\TestCase; use Pagarme\Core\Webhook\Aggregates\Webhook; +use Pagarme\Core\Recurrence\Aggregates\Charge; use Pagarme\Core\Webhook\ValueObjects\WebhookId; +use Pagarme\Core\Marketplace\Aggregates\Recipient; use Pagarme\Core\Webhook\ValueObjects\WebhookType; -use PHPUnit\Framework\TestCase; class WebhookIdTests extends TestCase { @@ -42,4 +43,20 @@ public function testWebHookObjectRecurrence() $this->assertEquals('create', $webhook->getType()->getAction()); $this->assertEquals('Recurrence', $webhook->getComponent()); } + + public function testWebHookObjectMarketplace() + { + $webhook = new Webhook(); + $webhook->setId(1); + $webhook->setPagarmeId(new WebhookId('hook_xxxxxxxxxxxxxxxx')); + $webhook->setType(WebhookType::fromPostType('recipient.updated')); + $webhook->setEntity(new Recipient()); + $webhook->setComponent([]); + + $this->assertEquals(1, $webhook->getId()); + $this->assertEquals('hook_xxxxxxxxxxxxxxxx', $webhook->getPagarmeId()->getValue()); + $this->assertEquals('recipient', $webhook->getType()->getEntityType()); + $this->assertEquals('updated', $webhook->getType()->getAction()); + $this->assertEquals('Marketplace', $webhook->getComponent()); + } } diff --git a/vendor/pagarme/ecommerce-module-core/tests/Webhook/Services/RecipientHandlerServiceTest.php b/vendor/pagarme/ecommerce-module-core/tests/Webhook/Services/RecipientHandlerServiceTest.php new file mode 100644 index 00000000..7bdcaa38 --- /dev/null +++ b/vendor/pagarme/ecommerce-module-core/tests/Webhook/Services/RecipientHandlerServiceTest.php @@ -0,0 +1,83 @@ +setType($webhookType); + $recipient = new Recipient(); + $recipient->setPagarmeId(new RecipientId('rp_xxxxxxxxxxxxxxxx')); + $recipient->setStatus(RecipientInterface::ACTIVE); + $webhook->setEntity($recipient); + + $foundedRecipient = new Recipient(); + $recipientServiceMock = Mockery::mock('overload:Pagarme\Core\Marketplace\Services\RecipientService'); + $recipientServiceMock->shouldReceive('findSavedByPagarmeId')->andReturn($foundedRecipient); + $recipientServiceMock->shouldReceive('saveRecipient')->withArgs(function ($updatedRecipient) { + return $updatedRecipient->getStatus() === RecipientInterface::ACTIVE; + }); + + $recipientHandlerService = new RecipientHandlerService(); + $result = $recipientHandlerService->handle($webhook); + + $this->assertSame($result['message'], RecipientHandlerService::RECIPIENT_UPDATED_MESSAGE); + $this->assertSame($result['code'], RecipientHandlerService::STATUS_CODE); + } + + public function testHandleShouldNotFoundRecipient() + { + $webhookType = WebhookType::fromPostType('recipient.updated'); + $webhook = new Webhook(); + $webhook->setType($webhookType); + $recipient = new Recipient(); + $recipient->setPagarmeId(new RecipientId('rp_xxxxxxxxxxxxxxxx')); + $recipient->setStatus(RecipientInterface::ACTIVE); + $webhook->setEntity($recipient); + + $recipientServiceMock = Mockery::mock('overload:Pagarme\Core\Marketplace\Services\RecipientService'); + $recipientServiceMock->shouldReceive('findSavedByPagarmeId')->andReturnNull(); + + $logServiceMock = Mockery::mock('overload:Pagarme\Core\Kernel\Services\LogService'); + $logServiceMock->shouldReceive('info')->andReturnSelf(); + + $recipientHandlerService = new RecipientHandlerService(); + $result = $recipientHandlerService->handle($webhook); + + $this->assertSame($result['message'], sprintf(RecipientHandlerService::RECIPIENT_NOT_FOUNDED_MESSAGE, $recipient->getPagarmeId()->getValue())); + $this->assertSame($result['code'], RecipientHandlerService::STATUS_CODE); + } + + public function testHandleShouldNotFoundHandler() + { + $webhookName = 'recipient.created'; + $webhookType = WebhookType::fromPostType($webhookName); + $webhook = new Webhook(); + $webhook->setType($webhookType); + + $logServiceMock = Mockery::mock('overload:Pagarme\Core\Kernel\Services\LogService'); + $logServiceMock->shouldReceive('info')->andReturnSelf(); + + $recipientHandlerService = new RecipientHandlerService(); + $result = $recipientHandlerService->handle($webhook); + + $this->assertSame($result['message'], sprintf(RecipientHandlerService::WEBHOOK_NOT_IMPLEMENTED_MESSAGE, $webhookName)); + $this->assertSame($result['code'], RecipientHandlerService::STATUS_CODE); + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Controllers/RecipientsController.php b/vendor/pagarme/pagarmecoreapi/src/Controllers/RecipientsController.php index c28a4832..1c77a173 100644 --- a/vendor/pagarme/pagarmecoreapi/src/Controllers/RecipientsController.php +++ b/vendor/pagarme/pagarmecoreapi/src/Controllers/RecipientsController.php @@ -1266,6 +1266,62 @@ public function createRecipient( return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\GetRecipientResponse'); } + /** + * Create kyc link + * + * @param string $recipientId Recipient id + * @return mixed response from the API call + * @throws APIException Thrown if API call fails + */ + public function createKycLink( + $recipientId + ) { + + //prepare query string for API call + $_queryBuilder = '/recipients/{recipient_id}/kyc_link '; + + //process optional query parameters + $_queryBuilder = APIHelper::appendUrlWithTemplateParameters($_queryBuilder, array ( + 'recipient_id' => $recipientId, + )); + + //validate and preprocess url + $_queryUrl = APIHelper::cleanUrl(Configuration::$BASEURI . $_queryBuilder); + + //prepare headers + $_headers = array ( + 'user-agent' => BaseController::USER_AGENT, + 'Accept' => 'application/json' + ); + + //set HTTP basic auth parameters + Request::auth(Configuration::$basicAuthUserName, Configuration::$basicAuthPassword); + + //call on-before Http callback + $_httpRequest = new HttpRequest(HttpMethod::POST, $_headers, $_queryUrl); + if ($this->getHttpCallBack() != null) { + $this->getHttpCallBack()->callOnBeforeRequest($_httpRequest); + } + + //and invoke the API call request to fetch the response + $response = Request::post($_queryUrl, $_headers); + + $_httpResponse = new HttpResponse($response->code, $response->headers, $response->raw_body); + $_httpContext = new HttpContext($_httpRequest, $_httpResponse); + + //call on-after Http callback + if ($this->getHttpCallBack() != null) { + $this->getHttpCallBack()->callOnAfterRequest($_httpContext); + } + + //handle errors defined at the API level + $this->validateResponse($_httpResponse, $_httpContext); + + $mapper = $this->getJsonMapper(); + + return $mapper->mapClass($response->body, 'PagarmeCoreApiLib\\Models\\CreateKycLinkResponse'); + } + /** * Retrieves recipient information * diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateGooglePayPaymentRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateGooglePayPaymentRequest.php new file mode 100644 index 00000000..ac1c5290 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateGooglePayPaymentRequest.php @@ -0,0 +1,59 @@ +statementDescriptor + * @param Object $payload Initialization value for $this->payload + * @param Object $card Initialization value for $this->card + */ + public function __construct() + { + if (3 == func_num_args()) { + $this->statementDescriptor = func_get_arg(0); + $this->payload = func_get_arg(1); + $this->card = func_get_arg(2); + } + } + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['statement_descriptor'] = $this->statementDescriptor; + $json['payload'] = $this->payload; + $json['card'] = $this->card; + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateKycLinkResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateKycLinkResponse.php new file mode 100644 index 00000000..b9bc8314 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateKycLinkResponse.php @@ -0,0 +1,58 @@ +url + * @param string $base64_qrcode Initialization value for $this->base64_qrcode + * @param array $expires_at Initialization value for $this->expires_at + */ + public function __construct() + { + if (3 == func_num_args()) { + $this->url = func_get_arg(0); + $this->base64_qrcode = func_get_arg(1); + $this->expires_at = func_get_arg(2); + } + } + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['url'] = $this->url; + $json['base64_qrcode'] = $this->base64_qrcode; + $json['expires_at'] = $this->expires_at; + + return $json; + } +} \ No newline at end of file diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRecipientRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRecipientRequest.php index 4628b2b9..cd223818 100644 --- a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRecipientRequest.php +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRecipientRequest.php @@ -15,130 +15,77 @@ class CreateRecipientRequest implements JsonSerializable { /** - * Recipient name + * Default Bank Account * @required - * @var string $name public property - */ - public $name; - - /** - * Recipient email - * @required - * @var string $email public property - */ - public $email; - - /** - * Recipient description - * @required - * @var string $description public property + * @maps default_bank_account + * @var array $defaultBankAccount public property */ - public $description; - + public $defaultBankAccount; /** - * Recipient document number + * Transfer Settings * @required - * @var string $document public property + * @maps transfer_settings + * @var CreateTransferSettingsRequest $transferSettings public property */ - public $document; + public $transferSettings; /** - * Recipient type + * Automatic Anticipation Settings * @required - * @var string $type public property + * @maps automatic_anticipation_settings + * @var array|null|mixed $automaticAnticipationSettings public property */ - public $type; - + public $automaticAnticipationSettings; /** - * Bank account + * Register Information * @required - * @maps default_bank_account - * @var \PagarmeCoreApiLib\Models\CreateBankAccountRequest $defaultBankAccount public property + * @maps register_information + * @var CreateRegisterInformationBaseRequest */ - public $defaultBankAccount; - + public $registerInformation; /** - * Metadata - * @required - * @var array $metadata public property - */ - public $metadata; - - /** - * Receiver Transfer Information - * @maps transfer_settings - * @var \PagarmeCoreApiLib\Models\CreateTransferSettingsRequest|null $transferSettings public property - */ - public $transferSettings; - - /** - * Recipient code + * Code * @required + * @maps code * @var string $code public property */ public $code; - /** - * Payment mode - * @required - * @maps payment_mode - * @var string $paymentMode public property - */ - public $paymentMode; /** - * Constructor to set initial or default values of member properties - * @param string $name Initialization value for $this->name - * @param string $email Initialization value for $this->email - * @param string $description Initialization value for $this->description - * @param string $document Initialization value for $this->document - * @param string $type Initialization value for $this->type - * @param CreateBankAccountRequest $defaultBankAccount Initialization value for $this->defaultBankAccount - * @param array $metadata Initialization value for $this->metadata - * @param CreateTransferSettingsRequest $transferSettings Initialization value for $this->transferSettings - * @param string $code Initialization value for $this->code - * @param string $paymentMode Initialization value for $this->paymentMode + * @param CreateBankAccountRequest $defaultBankAccount + * @param null|CreateTransferSettingsRequest $transferSettings + * @param array|null|mixed $automaticAnticipationSettings + * @param CreateRegisterInformationBaseRequest $registerInformation + * @param string $code */ - public function __construct() - { - switch (func_num_args()) { - case 10: - $this->name = func_get_arg(0); - $this->email = func_get_arg(1); - $this->description = func_get_arg(2); - $this->document = func_get_arg(3); - $this->type = func_get_arg(4); - $this->defaultBankAccount = func_get_arg(5); - $this->metadata = func_get_arg(6); - $this->transferSettings = func_get_arg(7); - $this->code = func_get_arg(8); - $this->paymentMode = func_get_arg(9); - break; - - default: - $this->paymentMode = 'bank_transfer'; - break; - } + public function __construct( + CreateBankAccountRequest $defaultBankAccount, + $transferSettings, + $automaticAnticipationSettings, + CreateRegisterInformationBaseRequest $registerInformation, + $code + ) { + $this->defaultBankAccount = $defaultBankAccount; + $this->transferSettings = $transferSettings; + $this->automaticAnticipationSettings = $automaticAnticipationSettings; + $this->registerInformation = $registerInformation; + $this->code = $code; } - - + /** * Encode this object to JSON + * @return array */ - #[\ReturnTypeWillChange] + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) public function jsonSerialize() { - $json = array(); - $json['name'] = $this->name; - $json['email'] = $this->email; - $json['description'] = $this->description; - $json['document'] = $this->document; - $json['type'] = $this->type; - $json['default_bank_account'] = $this->defaultBankAccount; - $json['metadata'] = $this->metadata; - $json['transfer_settings'] = $this->transferSettings; - $json['code'] = $this->code; - $json['payment_mode'] = $this->paymentMode; + $json = []; + $json['default_bank_account'] = $this->defaultBankAccount; + $json['transfer_settings'] = $this->transferSettings; + $json['automatic_anticipation_settings'] = $this->automaticAnticipationSettings; + $json['register_information'] = $this->registerInformation; + $json['code'] = $this->code; return $json; } diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationAddressRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationAddressRequest.php new file mode 100644 index 00000000..aab425e9 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationAddressRequest.php @@ -0,0 +1,120 @@ +street = $street; + $this->complementary = $complementary; + $this->streetNumber = $streetNumber; + $this->neighborhood = $neighborhood; + $this->city = $city; + $this->state = $state; + $this->zipCode = $zipCode; + $this->referencePoint = $referencePoint; + } + + + /** + * Encode this object to JSON + * @return array|stdClass + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize() + { + $json = []; + $json['street'] = $this->street; + $json['complementary'] = $this->complementary; + $json['street_number'] = $this->streetNumber; + $json['neighborhood'] = $this->neighborhood; + $json['city'] = $this->city; + $json['state'] = $this->state; + $json['zip_code'] = $this->zipCode; + $json['reference_point'] = $this->referencePoint; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationBaseRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationBaseRequest.php new file mode 100644 index 00000000..9fa96754 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationBaseRequest.php @@ -0,0 +1,87 @@ +email = $email; + $this->document = $document; + $this->type = $type; + $this->siteUrl = $siteUrl; + $this->phoneNumbers = $phoneNumbers; + } + + + /** + * Encode this object to JSON + * @return array + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize() + { + $json = []; + $json['email'] = $this->email; + $json['document'] = $this->document; + $json['type'] = $this->type; + $json['site_url'] = $this->siteUrl; + $json['phone_numbers'] = $this->phoneNumbers; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationCorporationRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationCorporationRequest.php new file mode 100644 index 00000000..59096240 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationCorporationRequest.php @@ -0,0 +1,124 @@ +companyName = $companyName; + $this->corporationType = $corporationType; + $this->tradingName = $tradingName; + $this->annualRevenue = $annualRevenue; + $this->foundingDate = $foundingDate; + $this->managingPartners = $managingPartners; + $this->mainAddress = $mainAddress; + } + + /** + * Encode this object to JSON + * + * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields + * are set. (default: false) + * + * @return array|stdClass + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize() + { + $json = []; + $json['company_name'] = $this->companyName; + $json['corporation_type'] = $this->corporationType; + $json['trading_name'] = $this->tradingName; + $json['annual_revenue'] = $this->annualRevenue; + $json['founding_date'] = $this->foundingDate; + $json['managing_partners'] = $this->managingPartners; + $json['main_address'] = $this->mainAddress; + $json = array_merge($json, parent::jsonSerialize()); + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationIndividualRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationIndividualRequest.php new file mode 100644 index 00000000..d50e52da --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationIndividualRequest.php @@ -0,0 +1,113 @@ +name = $name; + $this->motherName = $motherName; + $this->birthdate = $birthdate; + $this->monthlyIncome = $monthlyIncome; + $this->professionalOccupation = $professionalOccupation; + $this->address = $address; + } + + /** + * Encode this object to JSON + * + * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields + * are set. (default: false) + * + * @return array + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize() + { + $json = []; + $json['name'] = $this->name; + $json['mother_name'] = $this->motherName; + $json['birthdate'] = $this->birthdate; + $json['monthly_income'] = $this->monthlyIncome; + $json['professional_occupation'] = $this->professionalOccupation; + $json['address'] = $this->address; + $json = array_merge($json, parent::jsonSerialize()); + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationPhoneRequest.php b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationPhoneRequest.php new file mode 100644 index 00000000..626b0068 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/CreateRegisterInformationPhoneRequest.php @@ -0,0 +1,63 @@ +ddd = $ddd; + $this->number = $number; + $this->type = $type; + } + + /** + * Encode this object to JSON + * + * @param bool $asArrayWhenEmpty Whether to serialize this model as an array whenever no fields + * are set. (default: false) + * + * @return array|stdClass + */ + #[\ReturnTypeWillChange] // @phan-suppress-current-line PhanUndeclaredClassAttribute for (php < 8.1) + public function jsonSerialize() + { + $json = []; + $json['ddd'] = $this->ddd; + $json['number'] = $this->number; + $json['type'] = $this->type; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientAddressResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientAddressResponse.php new file mode 100644 index 00000000..3cf22a4c --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientAddressResponse.php @@ -0,0 +1,113 @@ +street = func_get_arg(0); + $this->complementary = func_get_arg(1); + $this->streetNumber = func_get_arg(2); + $this->neighborhood = func_get_arg(3); + $this->city = func_get_arg(4); + $this->state = func_get_arg(5); + $this->zipCode = func_get_arg(6); + $this->referencePoint = func_get_arg(7); + } + } + + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['street'] = $this->street; + $json['complementary'] = $this->complementary; + $json['street_number'] = $this->streetNumber; + $json['neighborhood'] = $this->neighborhood; + $json['city'] = $this->city; + $json['state'] = $this->state; + $json['zip_code'] = $this->zipCode; + $json['reference_point'] = $this->referencePoint; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientKycDetailsResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientKycDetailsResponse.php new file mode 100644 index 00000000..82d8a7e7 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientKycDetailsResponse.php @@ -0,0 +1,44 @@ +status + * @param string $status_reason Initialization value for $this->status_reason + */ + public function __construct() + { + if (2 == func_num_args()) { + $this->status = func_get_arg(0); + $this->status_reason = func_get_arg(1); + } + } + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['status'] = $this->status; + $json['status_reason'] = $this->status_reason; + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientManagingPartnersResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientManagingPartnersResponse.php new file mode 100644 index 00000000..83319ca0 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientManagingPartnersResponse.php @@ -0,0 +1,160 @@ +name = func_get_arg(0); + $this->email = func_get_arg(1); + $this->document = func_get_arg(2); + $this->type = func_get_arg(3); + $this->motherName = func_get_arg(4); + $this->birthdate = func_get_arg(5); + $this->monthlyIncome = func_get_arg(6); + $this->professionalOccupation = func_get_arg(7); + $this->selfDeclaredRepresentative = func_get_arg(8); + $this->address = func_get_arg(9); + $this->phoneNumbers = func_get_arg(10); + } + } + + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['name'] = $this->name; + $json['email'] = $this->email; + $json['document'] = $this->document; + $json['type'] = $this->type; + $json['mother_name'] = $this->motherName; + $json['birthdate'] = $this->birthdate; + $json['monthly_income'] = $this->monthlyIncome; + $json['professional_occupation'] = $this->professionalOccupation; + $json['self_declared_representative'] = $this->selfDeclaredRepresentative; + $json['address'] = $this->address; + $json['phone_numbers'] = $this->phoneNumbers; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientPhonesResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientPhonesResponse.php new file mode 100644 index 00000000..e53a8828 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientPhonesResponse.php @@ -0,0 +1,68 @@ +ddd = func_get_arg(0); + $this->number = func_get_arg(1); + $this->type = func_get_arg(2); + } + } + + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['ddd'] = $this->ddd; + $json['number'] = $this->number; + $json['type'] = $this->type; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientRegisterInformationResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientRegisterInformationResponse.php new file mode 100644 index 00000000..c6cac603 --- /dev/null +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientRegisterInformationResponse.php @@ -0,0 +1,233 @@ +email + * @param string $document Initialization value for $this->document + * @param string $type Initialization value for $this->type + * @param string $siteUrl Initialization value for $this->siteUrl + * @param string $phoneNumbers Initialization value for $this->phoneNumbers + */ + public function __construct() + { + switch (func_num_args()) { + case 11: + $this->email = func_get_arg(0); + $this->document = func_get_arg(1); + $this->type = func_get_arg(2); + $this->siteUrl = func_get_arg(3); + $this->phoneNumbers = func_get_arg(4); + $this->name = func_get_arg(5); + $this->motherName = func_get_arg(6); + $this->birthdate = func_get_arg(7); + $this->monthlyIncome = func_get_arg(8); + $this->professionalOccupation = func_get_arg(9); + $this->address = func_get_arg(10); + break; + + case 12: + $this->email = func_get_arg(0); + $this->document = func_get_arg(1); + $this->type = func_get_arg(2); + $this->siteUrl = func_get_arg(3); + $this->phoneNumbers = func_get_arg(4); + $this->companyName = func_get_arg(5); + $this->tradingName = func_get_arg(6); + $this->annualRevenue = func_get_arg(7); + $this->corporationType = func_get_arg(8); + $this->foundingDate = func_get_arg(9); + $this->mainAddress = func_get_arg(10); + $this->managingPartners = func_get_arg(11); + break; + + default: + break; + } + } + + + /** + * Encode this object to JSON + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $json = array(); + $json['email'] = $this->email; + $json['document'] = $this->document; + $json['type'] = $this->type; + $json['site_url'] = $this->siteUrl; + $json['phone_numbers'] = $this->phoneNumbers; + $json['company_name'] = $this->companyName; + $json['trading_name'] = $this->tradingName; + $json['annual_revenue'] = $this->annualRevenue; + $json['corporation_type'] = $this->corporationType; + $json['founding_date'] = $this->foundingDate; + $json['main_address'] = $this->mainAddress; + $json['managing_partners'] = $this->managingPartners; + $json['name'] = $this->name; + $json['mother_name'] = $this->motherName; + $json['birthdate'] = $this->birthdate; + $json['monthly_income'] = $this->monthlyIncome; + $json['professional_occupation'] = $this->professionalOccupation; + $json['address'] = $this->address; + + return $json; + } +} diff --git a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientResponse.php b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientResponse.php index abb10a50..52479f7b 100644 --- a/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientResponse.php +++ b/vendor/pagarme/pagarmecoreapi/src/Models/GetRecipientResponse.php @@ -64,6 +64,13 @@ class GetRecipientResponse implements JsonSerializable */ public $status; + /** + * KYC Details + * @required + * @var \PagarmeCoreApiLib\Models\GetRecipientKycDetailsResponse|null $kyc_details public property + */ + public $kyc_details; + /** * Creation date * @required @@ -128,6 +135,12 @@ class GetRecipientResponse implements JsonSerializable */ public $transferSettings; + /** + * @maps register_information + * @var \PagarmeCoreApiLib\Models\GetRecipientRegisterInformationResponse $registerInformation public property + */ + public $registerInformation; + /** * Recipient code * @required @@ -154,6 +167,8 @@ class GetRecipientResponse implements JsonSerializable * >description * @param string $type Initialization value for $this->type * @param string $status Initialization value for $this->status + * @param GetRecipientKycDetailsResponse $kyc_details Initialization value for $this- + * >kyc_details * @param \DateTime $createdAt Initialization value for $this- * >createdAt * @param \DateTime $updatedAt Initialization value for $this- @@ -177,7 +192,7 @@ class GetRecipientResponse implements JsonSerializable public function __construct() { switch (func_num_args()) { - case 17: + case 18: $this->id = func_get_arg(0); $this->name = func_get_arg(1); $this->email = func_get_arg(2); @@ -185,17 +200,35 @@ public function __construct() $this->description = func_get_arg(4); $this->type = func_get_arg(5); $this->status = func_get_arg(6); - $this->createdAt = func_get_arg(7); - $this->updatedAt = func_get_arg(8); - $this->deletedAt = func_get_arg(9); - $this->defaultBankAccount = func_get_arg(10); - $this->gatewayRecipients = func_get_arg(11); - $this->metadata = func_get_arg(12); - $this->automaticAnticipationSettings = func_get_arg(13); - $this->transferSettings = func_get_arg(14); - $this->code = func_get_arg(15); - $this->paymentMode = func_get_arg(16); + $this->kyc_details = func_get_arg(7); + $this->createdAt = func_get_arg(8); + $this->updatedAt = func_get_arg(9); + $this->deletedAt = func_get_arg(10); + $this->defaultBankAccount = func_get_arg(11); + $this->gatewayRecipients = func_get_arg(12); + $this->metadata = func_get_arg(13); + $this->automaticAnticipationSettings = func_get_arg(14); + $this->transferSettings = func_get_arg(15); + $this->code = func_get_arg(16); + $this->paymentMode = func_get_arg(17); break; + case 16: + $this->id = func_get_arg(0); + $this->name = func_get_arg(1); + $this->email = func_get_arg(2); + $this->code = func_get_arg(3); + $this->document = func_get_arg(4); + $this->type = func_get_arg(5); + $this->paymentMode = func_get_arg(6); + $this->status = func_get_arg(7); + $this->kyc_details = func_get_arg(8); + $this->createdAt = func_get_arg(9); + $this->updatedAt = func_get_arg(10); + $this->transferSettings = func_get_arg(11); + $this->defaultBankAccount = func_get_arg(12); + $this->gatewayRecipients = func_get_arg(13); + $this->automaticAnticipationSettings = func_get_arg(14); + $this->registerInformation = func_get_arg(15); default: $this->paymentMode = 'bank_transfer'; @@ -218,6 +251,7 @@ public function jsonSerialize() $json['description'] = $this->description; $json['type'] = $this->type; $json['status'] = $this->status; + $json['kyc_details'] = $this->kyc_details; $json['created_at'] = DateTimeHelper::toRfc3339DateTime($this->createdAt); $json['updated_at'] = DateTimeHelper::toRfc3339DateTime($this->updatedAt); $json['deleted_at'] = DateTimeHelper::toRfc3339DateTime($this->deletedAt); @@ -227,6 +261,7 @@ public function jsonSerialize() $json['automatic_anticipation_settings'] = $this->automaticAnticipationSettings; $json['transfer_settings'] = $this->transferSettings; $json['code'] = $this->code; + $json['register_information'] = $this->registerInformation; $json['payment_mode'] = $this->paymentMode; return $json; diff --git a/webpack.config.js b/webpack.config.js index 3ccbb043..658602b4 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -11,6 +11,7 @@ module.exports = { new DependencyExtractionWebpackPlugin(), ], entry: { + // googlepay: './assets/javascripts/front/reactCheckout/payments/GooglePay/index.js', pix: './assets/javascripts/front/reactCheckout/payments/Pix/index.js', billet: './assets/javascripts/front/reactCheckout/payments/Billet/index.js', credit_card: './assets/javascripts/front/reactCheckout/payments/CreditCard/index.js', diff --git a/woo-pagarme-payments.php b/woo-pagarme-payments.php index da6b2afe..51b2d877 100644 --- a/woo-pagarme-payments.php +++ b/woo-pagarme-payments.php @@ -1,7 +1,7 @@
getPagarmeId()->getValue() ?>getTransaction($charge)->getTransactionType()->getType()) ?>getLastTransaction()->getTransactionType()->getType()) ?> + class="button-primary"> getTransaction($charge)->getTransactionType()->getType() === 'credit_card') : ?> + class="button-primary">