From daa47158cb98dce41218ee91c9dd0e05d5f358c3 Mon Sep 17 00:00:00 2001 From: Dimitar Natskin emerchantpay Date: Thu, 18 Apr 2024 16:27:08 +0300 Subject: [PATCH] 1.1.5 --- .gitignore | 2 + .phpcs.xml | 62 ++- .phpmd.xml | 5 +- LICENSE.md | 125 ++++++ README.md | 21 +- .../payment/emerchantpay_checkout.php | 3 +- .../payment/emerchantpay_direct.php | 20 +- .../en-gb/payment/emerchantpay_direct.php | 1 + .../model/payment/emerchantpay/base_model.php | 38 +- admin/model/payment/emerchantpay_checkout.php | 106 ++--- admin/model/payment/emerchantpay_direct.php | 101 ++--- .../payment/emerchantpay_direct.twig | 14 +- .../payment/emerchantpay_checkout.php | 39 +- .../payment/emerchantpay_direct.php | 42 +- .../model/payment/emerchantpay/base_model.php | 167 ++++---- .../model/payment/emerchantpay_checkout.php | 95 ++--- catalog/model/payment/emerchantpay_direct.php | 74 +--- .../view/javascript/emerchantpay/card.min.js | 2 +- composer.json | 22 +- composer.lock | 374 +++++++++--------- install.json | 2 +- system/admin/base_controller.php | 158 +++----- system/catalog/base_controller.php | 30 +- system/catalog/settings_helper.php | 18 +- system/catalog/threeds_helper.php | 45 +-- system/db_helper.php | 21 +- system/emerchantpay_helper.php | 33 +- .../API/Constants/BankAccountTypes.php | 2 +- .../src/Genesis/API/Constants/Banks.php | 7 +- .../Genesis/API/Constants/DateTimeFormat.php | 2 +- .../src/Genesis/API/Constants/Endpoints.php | 2 +- .../Genesis/API/Constants/Environments.php | 2 +- .../src/Genesis/API/Constants/Errors.php | 2 +- .../Fraud/Chargeback/ExternallyProcessed.php | 2 +- .../Fraud/Chargeback/ProcessingTypes.php | 2 +- .../NonFinancial/KYC/CVVPresents.php | 2 +- .../NonFinancial/KYC/CallServiceTypes.php | 2 +- .../KYC/CallVerificationStatuses.php | 2 +- .../KYC/DeviceFingerprintTypes.php | 2 +- .../NonFinancial/KYC/DocumentTypes.php | 2 +- .../Constants/NonFinancial/KYC/Genders.php | 2 +- .../KYC/IdentityDocumentMethods.php | 2 +- .../NonFinancial/KYC/IndustryTypes.php | 2 +- .../NonFinancial/KYC/PaymentMethods.php | 2 +- .../NonFinancial/KYC/ProfileActionTypes.php | 2 +- .../KYC/ProfileCurrentStatuses.php | 2 +- .../NonFinancial/KYC/TransactionStatuses.php | 2 +- .../KYC/VerificationAddressesTypes.php | 2 +- .../KYC/VerificationDocumentTypes.php | 2 +- .../KYC/VerificationLanguages.php | 2 +- .../KYC/VerificationSupportedModes.php | 2 +- .../API/Constants/NonFinancial/Services.php | 2 +- .../Genesis/API/Constants/Payment/Methods.php | 2 +- .../Transaction/CustomRequiredParameters.php | 2 +- .../API/Constants/Transaction/Names.php | 2 +- .../Parameters/AfricanMobileOperators.php | 2 +- .../Parameters/Alternatives/AccountTypes.php | 2 +- .../Parameters/Alternatives/P24/BankCodes.php | 2 +- .../Alternatives/PurposeOfRemittances.php | 2 +- .../Parameters/Business/PaymentTypes.php | 2 +- .../Parameters/CashPayments/CompanyTypes.php | 88 +++++ .../Parameters/CashPayments/Gender.php | 64 +++ .../CashPayments/MaritalStatuses.php | 78 ++++ .../Parameters/CredentialOnFile.php | 2 +- .../CustomerIdentificationOwner.php | 2 +- .../CustomerIdentificationSubType.php | 2 +- .../CustomerIdentificationType.php | 2 +- .../Parameters/Funding/IdentifierTypes.php | 2 +- .../Funding/ReceiverAccountTypes.php | 2 +- .../Transaction/Parameters/IFrameTargets.php | 2 +- .../Parameters/IdentificationTypes.php | 2 +- .../ManagedRecurring/AmountTypes.php | 2 +- .../ManagedRecurring/Frequencies.php | 2 +- .../Parameters/ManagedRecurring/Intervals.php | 2 +- .../Parameters/ManagedRecurring/Modes.php | 2 +- .../ManagedRecurring/PaymentTypes.php | 2 +- .../Mobile/ApplePay/PaymentTypes.php | 2 +- .../Mobile/GooglePay/PaymentTypes.php | 2 +- .../Parameters/MpiProtocolVersions.php | 2 +- .../OnlineBanking/BankCodeParameters.php | 7 +- .../OnlineBanking/Ideal/AllowedBanks.php | 2 +- .../Parameters/OnlineBanking/PaymentTypes.php | 2 +- .../OnlineBanking/PayoutBankParameters.php | 2 +- .../PayoutPaymentTypesParameters.php | 2 +- .../Parameters/PayByVouchers/CardTypes.php | 8 +- .../Parameters/PayByVouchers/RedeemTypes.php | 8 +- .../Parameters/Payout/MoneyTransferTypes.php | 2 +- .../Parameters/Recurring/Categories.php | 2 +- .../Parameters/Recurring/Types.php | 2 +- .../Refund/BankAccountTypeParameters.php | 2 +- .../Parameters/RussianMobileOperators.php | 2 +- .../Transaction/Parameters/ScaExemptions.php | 2 +- .../Transaction/Parameters/SourceOfFunds.php | 2 +- .../Threeds/V2/Browser/ColorDepths.php | 2 +- .../PasswordChangeIndicators.php | 2 +- .../RegistrationIndicators.php | 2 +- .../ShippingAddressUsageIndicators.php | 2 +- .../SuspiciousActivityIndicators.php | 2 +- .../V2/CardHolderAccount/UpdateIndicators.php | 2 +- .../V2/Control/ChallengeIndicators.php | 2 +- .../V2/Control/ChallengeWindowSizes.php | 2 +- .../Threeds/V2/Control/DeviceTypes.php | 2 +- .../V2/MerchantRisk/DeliveryTimeframes.php | 2 +- .../PreOrderPurchaseIndicators.php | 2 +- .../V2/MerchantRisk/ReorderItemIndicators.php | 2 +- .../V2/MerchantRisk/ShippingIndicators.php | 2 +- .../Threeds/V2/Purchase/Categories.php | 2 +- .../Parameters/Threeds/V2/Sdk/Interfaces.php | 2 +- .../Parameters/Threeds/V2/Sdk/UiTypes.php | 2 +- .../Wallets/PayPal/PaymentTypes.php | 2 +- .../API/Constants/Transaction/States.php | 2 +- .../API/Constants/Transaction/Types.php | 4 +- .../src/Genesis/API/Constants/i18n.php | 2 +- .../src/Genesis/API/Notification.php | 17 +- .../genesis_php/src/Genesis/API/Request.php | 53 ++- .../API/Request/Base/BaseVersionedRequest.php | 6 +- .../Genesis/API/Request/Base/Financial.php | 4 +- .../Request/Base/Financial/Alternative.php | 2 +- .../Base/Financial/Alternative/Klarna.php | 5 +- .../Base/Financial/Cards/CreditCard.php | 2 +- .../Base/Financial/Cards/CreditCard3D.php | 2 +- .../API/Request/Base/Financial/GiftCard.php | 2 +- .../API/Request/Base/Financial/Reference.php | 2 +- .../Base/Financial/SouthAmericanPayment.php | 2 +- .../API/Request/Base/GraphQLRequest.php | 251 ++++++++++++ .../NonFinancial/Consumers/BaseRequest.php | 2 +- .../Base/NonFinancial/DateRangeRequest.php | 47 +-- .../Base/NonFinancial/Fx/BaseRequest.php | 2 +- .../Base/NonFinancial/KYC/BaseRequest.php | 21 +- .../TokenizationApi/BaseRequest.php | 2 +- .../Financial/Alternatives/ABNiDEAL.php | 2 +- .../Financial/Alternatives/Earthport.php | 2 +- .../Request/Financial/Alternatives/INPay.php | 2 +- .../Alternatives/Klarna/Authorize.php | 2 +- .../Financial/Alternatives/Klarna/Capture.php | 2 +- .../Financial/Alternatives/Klarna/Item.php | 13 +- .../Financial/Alternatives/Klarna/Items.php | 2 +- .../Klarna/ProductIdentifiers.php | 2 +- .../Financial/Alternatives/Klarna/Refund.php | 2 +- .../Request/Financial/Alternatives/P24.php | 2 +- .../Request/Financial/Alternatives/POLi.php | 2 +- .../Request/Financial/Alternatives/PPRO.php | 2 +- .../Financial/Alternatives/PaypalExpress.php | 2 +- .../Request/Financial/Alternatives/Sofort.php | 2 +- .../Alternatives/TransferTo/Payout.php | 2 +- .../Financial/Alternatives/Trustly/Sale.php | 2 +- .../Alternatives/Trustly/Withdrawal.php | 2 +- .../Genesis/API/Request/Financial/Cancel.php | 2 +- .../Genesis/API/Request/Financial/Capture.php | 2 +- .../API/Request/Financial/Cards/Argencard.php | 2 +- .../API/Request/Financial/Cards/Aura.php | 2 +- .../API/Request/Financial/Cards/Authorize.php | 15 +- .../Request/Financial/Cards/Authorize3D.php | 2 +- .../Request/Financial/Cards/Bancontact.php | 2 +- .../API/Request/Financial/Cards/Cabal.php | 2 +- .../API/Request/Financial/Cards/Cencosud.php | 2 +- .../API/Request/Financial/Cards/Credit.php | 45 ++- .../API/Request/Financial/Cards/Elo.php | 2 +- .../Financial/Cards/EzeeCardPayout.php | 2 +- .../API/Request/Financial/Cards/Hipercard.php | 2 +- .../API/Request/Financial/Cards/Naranja.php | 2 +- .../API/Request/Financial/Cards/Nativa.php | 2 +- .../API/Request/Financial/Cards/Payout.php | 8 +- .../Cards/Recurring/InitRecurringSale.php | 2 +- .../Cards/Recurring/InitRecurringSale3D.php | 2 +- .../Cards/Recurring/RecurringSale.php | 2 +- .../API/Request/Financial/Cards/Sale.php | 14 +- .../API/Request/Financial/Cards/Sale3D.php | 2 +- .../Financial/Cards/TarjetaShopping.php | 2 +- .../Cards/Threeds/V2/MethodContinue.php | 2 +- .../Request/Financial/CashPayments/Baloto.php | 2 +- .../Financial/CashPayments/Banamex.php | 2 +- .../CashPayments/BancoDeOccidente.php | 2 +- .../Request/Financial/CashPayments/Boleto.php | 2 +- .../Financial/CashPayments/Carulla.php | 2 +- .../Request/Financial/CashPayments/Efecty.php | 2 +- .../CashPayments/EmpreseDeEnergia.php | 2 +- .../Request/Financial/CashPayments/Oxxo.php | 2 +- .../Financial/CashPayments/PagoFacil.php | 2 +- .../Request/Financial/CashPayments/Pix.php | 146 ++++++- .../Financial/CashPayments/Redpagos.php | 2 +- .../Financial/CashPayments/SantanderCash.php | 2 +- .../Financial/CashPayments/Surtimax.php | 2 +- .../Financial/Crypto/BitPay/Payout.php | 2 +- .../Financial/Crypto/BitPay/Refund.php | 2 +- .../Request/Financial/Crypto/BitPay/Sale.php | 2 +- .../Financial/GiftCards/Fashioncheque.php | 2 +- .../Financial/GiftCards/Intersolve.php | 2 +- .../API/Request/Financial/GiftCards/Tcs.php | 2 +- .../Financial/Mobile/AfricanMobileSale.php | 2 +- .../API/Request/Financial/Mobile/ApplePay.php | 2 +- .../Request/Financial/Mobile/GooglePay.php | 2 +- .../Financial/Mobile/RussianMobileSale.php | 2 +- .../OnlineBankingPayments/Alipay.php | 2 +- .../OnlineBankingPayments/AstropayDirect.php | 2 +- .../OnlineBankingPayments/BancoDoBrasil.php | 2 +- .../OnlineBankingPayments/Bancomer.php | 2 +- .../OnlineBankingPayments/Bradesco.php | 2 +- .../OnlineBankingPayments/Citadel/Payin.php | 2 +- .../OnlineBankingPayments/Citadel/Payout.php | 2 +- .../OnlineBankingPayments/Davivienda.php | 2 +- .../OnlineBankingPayments/Entercash.php | 2 +- .../Financial/OnlineBankingPayments/Eps.php | 2 +- .../OnlineBankingPayments/GiroPay.php | 2 +- .../Financial/OnlineBankingPayments/Ideal.php | 2 +- .../InstaDebit/Payin.php | 2 +- .../InstaDebit/Payout.php | 2 +- .../OnlineBankingPayments/InstantTransfer.php | 2 +- .../Financial/OnlineBankingPayments/Itau.php | 2 +- .../OnlineBankingPayments/Multibanco.php | 2 +- .../OnlineBankingPayments/MyBank.php | 2 +- .../OnlineBanking/Payin.php | 2 +- .../OnlineBanking/Payout.php | 18 +- .../Financial/OnlineBankingPayments/PayU.php | 2 +- .../OnlineBankingPayments/PostFinance.php | 2 +- .../Financial/OnlineBankingPayments/Pse.php | 2 +- .../OnlineBankingPayments/RapiPago.php | 2 +- .../OnlineBankingPayments/SafetyPay.php | 2 +- .../OnlineBankingPayments/Santander.php | 2 +- .../OnlineBankingPayments/TrustPay.php | 2 +- .../Financial/OnlineBankingPayments/Upi.php | 2 +- .../OnlineBankingPayments/WeChat.php | 2 +- .../OnlineBankingPayments/Webpay.php | 2 +- .../OnlineBankingPayments/iDebit/Payin.php | 2 +- .../OnlineBankingPayments/iDebit/Payout.php | 2 +- .../Request/Financial/PayByVouchers/Sale.php | 2 +- .../Request/Financial/PayByVouchers/oBeP.php | 2 +- .../Financial/Payout/AfricanMobilePayout.php | 2 +- .../Financial/Payout/RussianMobilePayout.php | 2 +- .../Genesis/API/Request/Financial/Refund.php | 2 +- .../API/Request/Financial/SCT/Payout.php | 2 +- .../SDD/Recurring/InitRecurringSale.php | 2 +- .../Financial/SDD/Recurring/RecurringSale.php | 2 +- .../API/Request/Financial/SDD/Refund.php | 2 +- .../API/Request/Financial/SDD/Sale.php | 2 +- .../TravelData/AirlineItineraryLegData.php | 2 +- .../Financial/Vouchers/AstropayCard.php | 2 +- .../API/Request/Financial/Vouchers/CashU.php | 2 +- .../Request/Financial/Vouchers/Neosurf.php | 2 +- .../Financial/Vouchers/Paysafecard.php | 2 +- .../Request/Financial/Wallets/Neteller.php | 2 +- .../API/Request/Financial/Wallets/PayPal.php | 2 +- .../API/Request/Financial/Wallets/Qiwi.php | 2 +- .../Request/Financial/Wallets/WebMoney.php | 2 +- .../API/Request/Financial/Wallets/Zimpler.php | 2 +- .../Request/Financial/Wallets/eZeeWallet.php | 40 +- .../Genesis/API/Request/NonFinancial/AVS.php | 2 +- .../NonFinancial/AccountVerification.php | 2 +- .../Alternatives/TransferTo/Payers.php | 2 +- .../NonFinancial/BillingApi/Transaction.php | 337 ++++++++++++++++ .../API/Request/NonFinancial/Blacklist.php | 2 +- .../Request/NonFinancial/Consumers/Create.php | 2 +- .../NonFinancial/Consumers/Disable.php | 2 +- .../Request/NonFinancial/Consumers/Enable.php | 2 +- .../NonFinancial/Consumers/Retrieve.php | 2 +- .../Request/NonFinancial/Consumers/Update.php | 2 +- .../Fraud/Chargeback/DateRange.php | 51 +-- .../Fraud/Chargeback/Transaction.php | 2 +- .../NonFinancial/Fraud/Reports/DateRange.php | 2 +- .../Fraud/Reports/Transaction.php | 2 +- .../Fraud/Retrieval/DateRange.php | 2 +- .../Fraud/Retrieval/Transaction.php | 2 +- .../API/Request/NonFinancial/Fx/GetRate.php | 2 +- .../API/Request/NonFinancial/Fx/GetRates.php | 2 +- .../API/Request/NonFinancial/Fx/GetTier.php | 2 +- .../API/Request/NonFinancial/Fx/GetTiers.php | 2 +- .../Request/NonFinancial/Fx/SearchRate.php | 2 +- .../Request/NonFinancial/KYC/CNPJ/Check.php | 93 +++++ .../Request/NonFinancial/KYC/CPF/Check.php | 93 +++++ .../Request/NonFinancial/KYC/Call/Create.php | 2 +- .../Request/NonFinancial/KYC/Call/Update.php | 2 +- .../KYC/ClientVerification/Register.php | 2 +- .../KYC/ClientVerification/Status.php | 2 +- .../KYC/ClientVerification/Verify.php | 2 +- .../KYC/ConsumerRegistration/Create.php | 2 +- .../KYC/ConsumerRegistration/Update.php | 2 +- .../KYC/IdentityDocument/Download.php | 2 +- .../KYC/IdentityDocument/Upload.php | 2 +- .../NonFinancial/KYC/Transaction/Create.php | 2 +- .../NonFinancial/KYC/Transaction/Update.php | 2 +- .../ProcessedTransactions/DateRange.php | 2 +- .../ProcessedTransactions/PostDateRange.php | 2 +- .../ProcessedTransactions/Transaction.php | 2 +- .../NonFinancial/Reconcile/DateRange.php | 103 +---- .../NonFinancial/Reconcile/Transaction.php | 2 +- .../NonFinancial/Retrieve/AbniDealBanks.php | 2 +- .../API/Request/NonFinancial/Sca/Checker.php | 2 +- .../TokenizationApi/DeleteToken.php | 2 +- .../TokenizationApi/Detokenize.php | 2 +- .../NonFinancial/TokenizationApi/GetCard.php | 2 +- .../NonFinancial/TokenizationApi/Tokenize.php | 2 +- .../TokenizationApi/UpdateToken.php | 2 +- .../TokenizationApi/ValidateToken.php | 2 +- .../TransactionApi/CardExpiryDateUpdate.php | 2 +- .../src/Genesis/API/Request/WPF/Create.php | 64 ++- .../src/Genesis/API/Request/WPF/Reconcile.php | 2 +- .../genesis_php/src/Genesis/API/Response.php | 25 +- .../src/Genesis/API/Traits/MagicAccessors.php | 2 +- .../Traits/Request/AddressInfoAttributes.php | 2 +- .../API/Traits/Request/BaseAttributes.php | 2 +- .../Traits/Request/CreditCardAttributes.php | 2 +- .../CustomerAddress/BillingInfoAttributes.php | 27 +- .../CustomerInfoAttributes.php | 2 +- .../ShippingInfoAttributes.php | 27 +- .../API/Traits/Request/DocumentAttributes.php | 2 +- .../Financial/AccountOwnerAttributes.php | 2 +- .../Request/Financial/AsyncAttributes.php | 2 +- .../Request/Financial/BankAttributes.php | 2 +- .../Financial/BeneficiaryAttributes.php | 2 +- .../Request/Financial/BirthDateAttributes.php | 2 +- .../AirlinesAirCarriersAttributes.php | 2 +- .../Financial/Business/BusinessAttributes.php | 2 +- .../CarPlaneAndBoatRentalsAttributes.php | 2 +- .../Business/CruiseLinesAttributes.php | 2 +- .../Business/EventManagementAttributes.php | 2 +- .../Business/FurnitureAttributes.php | 2 +- .../HotelsAndRealEstateRentalsAttributes.php | 2 +- .../Business/TravelAgenciesAttributes.php | 2 +- .../Recurring/ManagedRecurringAttributes.php | 2 +- .../ManagedRecurringIndianCardAttributes.php | 2 +- .../Recurring/RecurringCategoryAttributes.php | 2 +- .../Recurring/RecurringTypeAttributes.php | 18 +- .../SubsequentRecurringTypeAttributes.php | 86 ++++ .../Financial/CredentialOnFileAttributes.php | 2 +- .../Request/Financial/CryptoAttributes.php | 2 +- .../CustomerAttributes.php | 16 +- .../Financial/CustomerIdentificationData.php | 2 +- .../Financial/DescriptorAttributes.php | 2 +- .../Request/Financial/FundingAttributes.php | 2 +- .../Request/Financial/FxRateAttributes.php | 2 +- .../Request/Financial/GamingAttributes.php | 2 +- .../Request/Financial/MpiAttributes.php | 2 +- .../Financial/NotificationAttributes.php | 2 +- .../UserCategoryAttributes.php | 2 +- .../VirtualPaymentAddressAttributes.php | 2 +- .../Request/Financial/PaymentAttributes.php | 2 +- .../Financial/PendingPaymentAttributes.php | 2 +- .../Request/Financial/PproAttributes.php | 2 +- .../Financial/PreauthorizationAttributes.php | 2 +- .../Financial/PurposeOfPaymentAttributes.php | 44 +++ .../Request/Financial/ReferenceAttributes.php | 2 +- .../Financial/Refund/BankAttributes.php | 2 +- .../Request/Financial/ScaAttributes.php | 2 +- .../Financial/SourceOfFundsAttributes.php | 2 +- .../Financial/Threeds/V2/AllAttributes.php | 2 +- .../Request/Financial/Threeds/V2/Browser.php | 2 +- .../Threeds/V2/CardHolderAccount.php | 2 +- .../Financial/Threeds/V2/CommonAttributes.php | 2 +- .../Request/Financial/Threeds/V2/Control.php | 2 +- .../Financial/Threeds/V2/MerchantRisk.php | 2 +- .../Request/Financial/Threeds/V2/Method.php | 2 +- .../Request/Financial/Threeds/V2/Purchase.php | 2 +- .../Financial/Threeds/V2/Recurring.php | 2 +- .../Request/Financial/Threeds/V2/Sdk.php | 2 +- .../Financial/Threeds/V2/WpfAttributes.php | 2 +- .../TravelData/AirlineItineraryAttributes.php | 2 +- .../TravelData/CarRentalAttributes.php | 2 +- .../TravelData/HotelRentalAttributes.php | 2 +- .../TravelData/ReferenceTicketAttributes.php | 2 +- .../TravelData/TravelDataAttributes.php | 2 +- .../Request/Financial/UcofAttributes.php | 2 +- .../Request/Financial/VoucherAttributes.php | 2 +- .../Request/Mobile/ApplePayAttributes.php | 12 +- .../Request/Mobile/GooglePayAttributes.php | 2 +- .../API/Traits/Request/MotoAttributes.php | 2 +- .../BillingApi/OrderByDirection.php | 73 ++++ .../NonFinancial/CustomerInformation.php | 2 +- .../Request/NonFinancial/DateAttributes.php | 135 +++++++ .../Request/NonFinancial/DepositLimits.php | 2 +- .../NonFinancial/ExternallyProcessed.php | 2 +- .../NonFinancial/IdentityDocuments.php | 2 +- .../KYC/KycBackgroundChecksVerifications.php | 2 +- .../KYC/KycDocumentVerifications.php | 2 +- .../NonFinancial/KYC/KycFaceVerifications.php | 2 +- .../NonFinancial/KYC/KycVerifications.php | 2 +- .../NonFinancial/KycBillingInformation.php | 2 +- .../NonFinancial/KycShippingInformation.php | 2 +- .../Request/NonFinancial/PagingAttributes.php | 93 +++++ .../Request/NonFinancial/PaymentDetails.php | 2 +- .../Request/NonFinancial/ProcessingType.php | 2 +- .../TokenizationApiAttributes.php | 2 +- .../TokenizationApiCardAttributes.php | 2 +- .../TokenizationApiTokenAttributes.php | 2 +- .../Payout/MoneyTransferPayoutAttributes.php | 2 +- .../API/Traits/Request/RiskAttributes.php | 2 +- .../Traits/Request/TokenizationAttributes.php | 2 +- .../Genesis/API/Traits/RestrictedSetter.php | 2 +- .../Validations/Request/Validations.php | 26 +- .../API/Validators/Request/Base/Validator.php | 8 +- .../API/Validators/Request/RegexValidator.php | 2 +- .../genesis_php/src/Genesis/Builder.php | 2 +- .../genesis_php/src/Genesis/Builders/FORM.php | 2 +- .../genesis_php/src/Genesis/Builders/JSON.php | 6 +- .../genesis_php/src/Genesis/Builders/XML.php | 9 +- .../genesis_php/src/Genesis/Config.php | 30 +- .../Genesis/Exceptions/DeprecatedMethod.php | 2 +- .../Genesis/Exceptions/EnvironmentNotSet.php | 2 +- .../src/Genesis/Exceptions/ErrorAPI.php | 2 +- .../src/Genesis/Exceptions/ErrorNetwork.php | 2 +- .../src/Genesis/Exceptions/ErrorParameter.php | 2 +- .../src/Genesis/Exceptions/Exception.php | 2 +- .../Genesis/Exceptions/InvalidArgument.php | 2 +- .../src/Genesis/Exceptions/InvalidMethod.php | 5 +- .../Genesis/Exceptions/InvalidResponse.php | 2 +- .../src/Genesis/Exceptions/NotImplemented.php | 2 +- .../genesis_php/src/Genesis/Genesis.php | 2 +- .../src/Genesis/Interfaces/Builder.php | 2 +- .../src/Genesis/Interfaces/Parser.php | 2 +- .../genesis_php/src/Genesis/Network.php | 52 ++- .../genesis_php/src/Genesis/Network/Base.php | 7 +- .../src/Genesis/Network/Stream.php | 24 +- .../genesis_php/src/Genesis/Network/cURL.php | 22 +- .../genesis_php/src/Genesis/Parser.php | 2 +- .../genesis_php/src/Genesis/Parsers/JSON.php | 2 +- .../genesis_php/src/Genesis/Parsers/XML.php | 17 +- .../genesis_php/src/Genesis/Utils/Common.php | 19 +- .../genesis_php/src/Genesis/Utils/Country.php | 2 +- .../src/Genesis/Utils/Requirements.php | 12 +- .../src/Genesis/Utils/Threeds/V2.php | 4 +- 419 files changed, 3191 insertions(+), 1608 deletions(-) create mode 100644 LICENSE.md create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Constants/Transaction/Parameters/CashPayments/CompanyTypes.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Constants/Transaction/Parameters/CashPayments/Gender.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Constants/Transaction/Parameters/CashPayments/MaritalStatuses.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Request/Base/GraphQLRequest.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Request/NonFinancial/BillingApi/Transaction.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Request/NonFinancial/KYC/CNPJ/Check.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Request/NonFinancial/KYC/CPF/Check.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/Financial/Cards/Recurring/SubsequentRecurringTypeAttributes.php rename system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/Financial/{OnlineBankingPayments => }/CustomerAttributes.php (89%) create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/Financial/PurposeOfPaymentAttributes.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/NonFinancial/BillingApi/OrderByDirection.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/NonFinancial/DateAttributes.php create mode 100644 system/storage/vendor/genesisgateway/genesis_php/src/Genesis/API/Traits/Request/NonFinancial/PagingAttributes.php diff --git a/.gitignore b/.gitignore index 0ae5733..4dc2248 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ emerchantpay.ocmod.zip /vendor/ bin/check-standards +phpcs_report.xml +phpmd_report.xml diff --git a/.phpcs.xml b/.phpcs.xml index aab5a6c..7855f9a 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -1,10 +1,64 @@ - - Generally-applicable sniffs for OpenCart EMP Plugin - - + + Combined Code Sniffer rule set for OpenCart and OpenCart EMP Plugin */vendor/* *.min.js *.min.css + */tests/* + + + + 5 + error + + + 1 + warning + + + + + + 5 + error + + + 5 + error + + + + + + + + + + + *.tpl + *.css + *.html + *.ini + *.txt + 1 + warning + + + Please review this TODO comment: %s + 3 + warning + + + Please review this FIXME comment: %s + 5 + warning + + + + + + + + diff --git a/.phpmd.xml b/.phpmd.xml index 9513501..35cee37 100644 --- a/.phpmd.xml +++ b/.phpmd.xml @@ -24,7 +24,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -58,4 +58,5 @@ */genesisgateway/* + */vendor/* diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e5d14b4 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,125 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. +Preamble +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + +a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. +b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. +c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + +a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, +c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS +How to Apply These Terms to Your New Programs +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + +one line to give the program's name and an idea of what it does. +Copyright (C) yyyy name of author + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + +Gnomovision version 69, Copyright (C) year name of author +Gnomovision comes with ABSOLUTELY NO WARRANTY; for details +type `show w'. This is free software, and you are welcome +to redistribute it under certain conditions; type `show c' +for details. +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright +interest in the program `Gnomovision' +(which makes passes at compilers) written +by James Hacker. + +signature of Ty Coon, 1 April 1989 +Ty Coon, President of Vice +This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. diff --git a/README.md b/README.md index 679b124..21cbad9 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ emerchantpay Gateway Module for OpenCart ======================================== +[![Software License](https://img.shields.io/badge/license-GPL-green.svg?style=flat)](http://opensource.org/licenses/gpl-2.0.php) This is a Payment Module for OpenCart, that gives you the ability to process payments through emerchantpay's Payment Gateway - Genesis. @@ -7,7 +8,7 @@ Requirements ------------ * OpenCart 4.0.2.X (due to architectural changes, this module is __incompatible__ with older OpenCart versions) -* [GenesisPHP v1.24.2](https://github.com/GenesisGateway/genesis_php/tree/1.24.2) - (Integrated in Module) +* [GenesisPHP v1.24.6](https://github.com/GenesisGateway/genesis_php/tree/1.24.6) - (Integrated in Module) * PCI-certified server in order to use ```emerchantpay Direct``` GenesisPHP Requirements @@ -135,4 +136,22 @@ _Note_: If you have trouble with your credentials or terminal configuration, get You're now ready to process payments through our gateway. +Development +------------ +* Install dev packages +```shell +composer install +``` +* Run PHP Code Sniffer +```shell +composer php-cs +``` +* Run PHP Mess Detector +```shell +composer php-md +``` +* Pack installation archive (Linux or macOS only) +```shell +composer pack +``` [support]: mailto:tech-support@emerchantpay.net diff --git a/admin/controller/payment/emerchantpay_checkout.php b/admin/controller/payment/emerchantpay_checkout.php index e27f421..d167d3e 100644 --- a/admin/controller/payment/emerchantpay_checkout.php +++ b/admin/controller/payment/emerchantpay_checkout.php @@ -40,8 +40,7 @@ class EmerchantpayCheckout extends BaseController * * @return bool */ - protected function isModuleRequiresSsl(): bool - { + protected function isModuleRequiresSsl(): bool { return false; } } diff --git a/admin/controller/payment/emerchantpay_direct.php b/admin/controller/payment/emerchantpay_direct.php index 51e2d5a..182206e 100644 --- a/admin/controller/payment/emerchantpay_direct.php +++ b/admin/controller/payment/emerchantpay_direct.php @@ -40,8 +40,7 @@ class EmerchantpayDirect extends BaseController * * @param $registry */ - public function __construct($registry) - { + public function __construct($registry) { parent::__construct($registry); // TODO array_push with single element array_push($this->error_field_key_list, 'token'); @@ -52,24 +51,17 @@ public function __construct($registry) * * @return bool */ - protected function isModuleRequiresSsl(): bool - { + protected function isModuleRequiresSsl(): bool { return true; } /** * Ensure that the current user has permissions to see/modify this module * - * @return bool + * @return void */ - protected function validate(): bool - { - parent::validate(); - - if (empty($this->request->post["{$this->module_name}_token"])) { - $this->error['token'] = $this->language->get('error_token'); - } - - return !$this->error; + protected function validateRequiredFields(?array $required_fields = []): void { + $required_fields["{$this->module_name}_async_order_status_id"] = 'order_async_status'; + parent::validateRequiredFields($required_fields); } } diff --git a/admin/language/en-gb/payment/emerchantpay_direct.php b/admin/language/en-gb/payment/emerchantpay_direct.php index ac322ba..f68d3d0 100644 --- a/admin/language/en-gb/payment/emerchantpay_direct.php +++ b/admin/language/en-gb/payment/emerchantpay_direct.php @@ -127,6 +127,7 @@ // Help $_['help_total'] = 'Minimum Order Amount required, in order to activate this payment method.'; $_['help_sandbox'] = 'Use Sandbox (Test) or Production (Live) environment.'; +$_['help_token'] = 'This is your Gateway token. If you do not have a token, contact tech-support@emerchantpay.com to enable Smart Router for your account.'; $_['help_order_status'] = 'Order status for successfully completed transactions'; $_['help_async_order_status'] = 'Order status for initiated asynchronous (3D) transaction'; $_['help_failure_order_status'] = 'Order status for failed transactions'; diff --git a/admin/model/payment/emerchantpay/base_model.php b/admin/model/payment/emerchantpay/base_model.php index 30fefe2..fca5adb 100644 --- a/admin/model/payment/emerchantpay/base_model.php +++ b/admin/model/payment/emerchantpay/base_model.php @@ -19,7 +19,11 @@ namespace Opencart\Admin\Model\Extension\Emerchantpay\Payment\emerchantpay; +use Genesis\API\Constants\Endpoints; +use Genesis\API\Constants\Environments; use Genesis\API\Constants\Transaction\Parameters\ScaExemptions; +use Genesis\Config; +use Genesis\Exceptions\InvalidArgument; use Opencart\System\Engine\Model; /** @@ -35,15 +39,14 @@ class BaseModel extends Model * * @var string */ - protected $module_version = '1.1.4'; + protected $module_version = '1.1.5'; /** * Returns formatted array with available SCA Exemptions * * @return array */ - public function getScaExemptions(): array - { + public function getScaExemptions(): array { $data = []; $sca_exemptions = [ ScaExemptions::EXEMPTION_LOW_RISK => 'Low risk', @@ -59,4 +62,33 @@ public function getScaExemptions(): array return $data; } + + /** + * Bootstrap Genesis Library + * + * @return void + * + * @throws InvalidArgument + */ + protected function bootstrap(): void { + if (!class_exists('\Genesis\Genesis', false)) { + include DIR_STORAGE . 'vendor/genesisgateway/genesis_php/vendor/autoload.php'; + } + + Config::setEndpoint( + Endpoints::EMERCHANTPAY + ); + + Config::setUsername( + $this->config->get("{$this->module_name}_username") + ); + + Config::setPassword( + $this->config->get("{$this->module_name}_password") + ); + + Config::setEnvironment( + $this->config->get("{$this->module_name}_sandbox") ? Environments::STAGING : Environments::PRODUCTION + ); + } } diff --git a/admin/model/payment/emerchantpay_checkout.php b/admin/model/payment/emerchantpay_checkout.php index ec827d4..d8d92f3 100644 --- a/admin/model/payment/emerchantpay_checkout.php +++ b/admin/model/payment/emerchantpay_checkout.php @@ -29,6 +29,7 @@ use Genesis\API\Constants\Transaction\Parameters\Wallets\PayPal\PaymentTypes as PayPalPaymentTypes; use Genesis\API\Request\Financial\Alternatives\Klarna\Items as KlarnaItems; use Genesis\Config; +use Genesis\Exceptions\InvalidArgument; use Genesis\Genesis; use Opencart\Admin\Model\Extension\Emerchantpay\Payment\emerchantpay\BaseModel; use Opencart\Extension\Emerchantpay\System\DbHelper; @@ -41,15 +42,14 @@ */ class EmerchantpayCheckout extends BaseModel { - protected $module_name = 'emerchantpay_checkout'; + protected string $module_name = 'emerchantpay_checkout'; /** * Perform installation logic * * @return void */ - public function install(): void - { + public function install(): void { $this->db->query(" CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "emerchantpay_checkout_transactions` ( `unique_id` VARCHAR(255) NOT NULL, @@ -102,8 +102,7 @@ public function install(): void * * @return void */ - public function uninstall(): void - { + public function uninstall(): void { // Keep transaction data //$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "emerchantpay_checkout_transactions`;"); @@ -119,8 +118,7 @@ public function uninstall(): void * * @return mixed bool on fail, row on success */ - public function getTransactionById($reference_id): mixed - { + public function getTransactionById($reference_id): mixed { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_checkout_transactions` WHERE `unique_id` = '" . $this->db->escape($reference_id) . "' LIMIT 1 @@ -143,8 +141,7 @@ public function getTransactionById($reference_id): mixed * * @return float */ - public function getTransactionsSumAmount($order_id, $reference_id, $types, $status): float - { + public function getTransactionsSumAmount($order_id, $reference_id, $types, $status): float { $transactions = $this->getTransactionsByTypeAndStatus($order_id, $reference_id, $types, $status); $total_amount = 0; @@ -168,8 +165,7 @@ public function getTransactionsSumAmount($order_id, $reference_id, $types, $stat * * @return array|false */ - public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transaction_types, $status): array|false - { + public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transaction_types, $status): array|false { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_checkout_transactions` AS t @@ -193,8 +189,7 @@ public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transa * * @return mixed bool on fail, rows on success */ - public function getTransactionsByOrder($order_id): mixed - { + public function getTransactionsByOrder($order_id): mixed { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_checkout_transactions` WHERE `order_id` = '" . abs(intval($order_id)) . "' @@ -220,8 +215,7 @@ public function getTransactionsByOrder($order_id): mixed * * @return object|string */ - public function capture($type, $reference_id, $amount, $currency, $usage, $order_id, $token = null): object|string - { + public function capture($type, $reference_id, $amount, $currency, $usage, $order_id, $token = null): object|string { try { $this->bootstrap($token); @@ -269,8 +263,7 @@ public function capture($type, $reference_id, $amount, $currency, $usage, $order * * @return object|string */ - public function refund($type, $reference_id, $amount, $currency, $usage = '', $token = null, $order_id = 0): object|string - { + public function refund($type, $reference_id, $amount, $currency, $usage = '', $token = null, $order_id = 0): object|string { try { $this->bootstrap($token); @@ -314,8 +307,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = '', $t * * @return object|string */ - public function void($reference_id, $usage = '', $token = null): object|string - { + public function void($reference_id, $usage = '', $token = null): object|string { try { $this->bootstrap($token); @@ -347,8 +339,7 @@ public function void($reference_id, $usage = '', $token = null): object|string * * @return array */ - public function getTransactionTypes(): array - { + public function getTransactionTypes(): array { $data = array(); $this->bootstrap(); @@ -452,8 +443,7 @@ function ($type) { * * @return array */ - public function getBankCodes(): array - { + public function getBankCodes(): array { $data = []; $available_bank_codes = EmerchantpayHelper::getAvailableBankCodes(); @@ -472,8 +462,7 @@ public function getBankCodes(): array * * @return array */ - public function getRecurringTransactionTypes(): array - { + public function getRecurringTransactionTypes(): array { $data = []; $this->bootstrap(); @@ -523,49 +512,12 @@ public function getRecurringTransactionTypes(): array * * @return string */ - public function genTransactionId($prefix = ''): string - { + public function genTransactionId($prefix = ''): string { $hash = md5(microtime(true) . uniqid() . mt_rand(PHP_INT_SIZE, PHP_INT_MAX)); return (string)$prefix . substr($hash, -(strlen($hash) - strlen($prefix))); } - /** - * Bootstrap Genesis Library - * - * @param string $token Terminal token - * - * @return void - * - * @throws \Genesis\Exceptions\InvalidArgument - */ - public function bootstrap($token = null): void - { - if (!class_exists('\Genesis\Genesis', false)) { - include DIR_STORAGE . 'vendor/genesisgateway/genesis_php/vendor/autoload.php'; - - Config::setEndpoint( - Endpoints::EMERCHANTPAY - ); - - Config::setUsername( - $this->config->get('emerchantpay_checkout_username') - ); - - Config::setPassword( - $this->config->get('emerchantpay_checkout_password') - ); - - Config::setEnvironment( - $this->config->get('emerchantpay_checkout_sandbox') ? Environments::STAGING : Environments::PRODUCTION - ); - } - - if (isset($token)) { - Config::setToken((string)$token); - } - } - /** * Proxy method for logEx * @@ -573,8 +525,7 @@ public function bootstrap($token = null): void * * @return void */ - public function logEx(\Exception $exception): void - { + public function logEx(\Exception $exception): void { $db_helper = new DbHelper($this->module_name, $this); $db_helper->logEx($exception); } @@ -584,8 +535,7 @@ public function logEx(\Exception $exception): void * * @return string */ - public function getVersion(): string - { + public function getVersion(): string { return $this->module_version; } @@ -598,8 +548,7 @@ public function getVersion(): string * * @throws \Exception */ - public function populateTransaction($data): void - { + public function populateTransaction($data): void { $db_helper = new DbHelper($this->module_name, $this); $db_helper->populateTransaction($data); } @@ -612,8 +561,7 @@ public function populateTransaction($data): void * * @throws \Genesis\Exceptions\ErrorParameter */ - protected function getKlarnaReferenceAttributes($currency, $order_id): KlarnaItems - { + protected function getKlarnaReferenceAttributes($currency, $order_id): KlarnaItems { $this->load->model('sale/order'); $product_order_info = $this->model_sale_order->getOrderProducts($order_id); @@ -640,4 +588,20 @@ function ($value) { ) ); } + + /** + * Bootstrap Genesis Library + * + * @param string|null $token Terminal token + * + * @return void + * + * @throws InvalidArgument + */ + protected function bootstrap(?string $token = null): void { + parent::bootstrap(); + if (isset($token)) { + Config::setToken((string)$token); + } + } } diff --git a/admin/model/payment/emerchantpay_direct.php b/admin/model/payment/emerchantpay_direct.php index 7a05e8e..23f0b45 100644 --- a/admin/model/payment/emerchantpay_direct.php +++ b/admin/model/payment/emerchantpay_direct.php @@ -36,15 +36,14 @@ */ class EmerchantpayDirect extends BaseModel { - protected $module_name = "emerchantpay_direct"; + protected string $module_name = "emerchantpay_direct"; /** * Perform installation logic * * @return void */ - public function install(): void - { + public function install(): void { $this->db->query(" CREATE TABLE IF NOT EXISTS `" . DB_PREFIX . "emerchantpay_direct_transactions` ( `unique_id` VARCHAR(255) NOT NULL, @@ -87,8 +86,7 @@ public function install(): void * * @return void */ - public function uninstall(): void - { + public function uninstall(): void { // Keep transaction data //$this->db->query("DROP TABLE IF EXISTS `" . DB_PREFIX . "emerchantpay_direct_transactions`;"); @@ -104,8 +102,7 @@ public function uninstall(): void * * @return mixed bool on fail, row on success */ - public function getTransactionById($reference_id): mixed - { + public function getTransactionById($reference_id): mixed { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_direct_transactions` WHERE `unique_id` = '" . $this->db->escape($reference_id) . "' LIMIT 1 @@ -126,8 +123,7 @@ public function getTransactionById($reference_id): mixed * @param string $status * @return float */ - public function getTransactionsSumAmount($order_id, $reference_id, $types, $status): float - { + public function getTransactionsSumAmount($order_id, $reference_id, $types, $status): float { $transactions = $this->getTransactionsByTypeAndStatus($order_id, $reference_id, $types, $status); $total_amount = 0; @@ -152,8 +148,7 @@ public function getTransactionsSumAmount($order_id, $reference_id, $types, $stat * @return array|false */ - public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transaction_types, $status): array|false - { + public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transaction_types, $status): array|false { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_direct_transactions` AS t @@ -177,8 +172,7 @@ public function getTransactionsByTypeAndStatus($order_id, $reference_id, $transa * * @return mixed bool on fail, rows on success */ - public function getTransactionsByOrder($order_id): mixed - { + public function getTransactionsByOrder($order_id): mixed { $query = $this->db->query(" SELECT * FROM `" . DB_PREFIX . "emerchantpay_direct_transactions` WHERE `order_id` = '" . intval($order_id) . "' @@ -201,8 +195,7 @@ public function getTransactionsByOrder($order_id): mixed * * @return object|string */ - public function capture($type, $reference_id, $amount, $currency, $usage): object|string - { + public function capture($type, $reference_id, $amount, $currency, $usage): object|string { try { $this->bootstrap(); @@ -243,8 +236,7 @@ public function capture($type, $reference_id, $amount, $currency, $usage): objec * * @return object|string */ - public function refund($type, $reference_id, $amount, $currency, $usage = ''): object|string - { + public function refund($type, $reference_id, $amount, $currency, $usage = ''): object|string { try { $this->bootstrap(); @@ -283,8 +275,7 @@ public function refund($type, $reference_id, $amount, $currency, $usage = ''): o * * @return object|string */ - public function void($reference_id, $usage = ''): object|string - { + public function void($reference_id, $usage = ''): object|string { try { $this->bootstrap(); @@ -316,8 +307,7 @@ public function void($reference_id, $usage = ''): object|string * * @return array */ - public function getTransactionTypes(): array - { + public function getTransactionTypes(): array { return array( Types::AUTHORIZE => array( 'id' => Types::AUTHORIZE, @@ -355,8 +345,7 @@ public function getTransactionTypes(): array * * @throws \Genesis\Exceptions\InvalidArgument */ - public function getRecurringTransactionTypes(): array - { + public function getRecurringTransactionTypes(): array { // TODO: Should we move out this to a trait or another class to avoid duplicate code $data = array(); @@ -390,47 +379,12 @@ public function getRecurringTransactionTypes(): array * * @return string */ - public function genTransactionId($prefix = ''): string - { + public function genTransactionId($prefix = ''): string { $hash = md5(microtime(true) . uniqid() . mt_rand(PHP_INT_SIZE, PHP_INT_MAX)); return (string)$prefix . substr($hash, -(strlen($hash) - strlen($prefix))); } - /** - * Bootstrap Genesis Library - * - * @return void - * - * @throws \Genesis\Exceptions\InvalidArgument - */ - public function bootstrap(): void - { - // Look for, but DO NOT try to load via Auto-loader magic methods - if (class_exists('\Genesis\Genesis')) { - - Config::setEndpoint( - Endpoints::EMERCHANTPAY - ); - - Config::setUsername( - $this->config->get('emerchantpay_direct_username') - ); - - Config::setPassword( - $this->config->get('emerchantpay_direct_password') - ); - - Config::setToken( - $this->config->get('emerchantpay_direct_token') - ); - - Config::setEnvironment( - ($this->config->get('emerchantpay_direct_sandbox')) ? Environments::STAGING : Environments::PRODUCTION - ); - } - } - /** * Proxy method for logEx * @@ -438,8 +392,7 @@ public function bootstrap(): void * * @return void */ - public function logEx(\Exception $exception): void - { + public function logEx(\Exception $exception): void { $db_helper = new DbHelper($this->module_name, $this); $db_helper->logEx($exception); } @@ -449,8 +402,7 @@ public function logEx(\Exception $exception): void * * @return string */ - public function getVersion(): string - { + public function getVersion(): string { return $this->module_version; } @@ -463,9 +415,28 @@ public function getVersion(): string * * @throws \Exception */ - public function populateTransaction($data): void - { + public function populateTransaction($data): void { $db_helper = new DbHelper($this->module_name, $this); $db_helper->populateTransaction($data); } + + /** + * Bootstrap Genesis Library + * + * @return void + * + * @throws \Genesis\Exceptions\InvalidArgument + */ + protected function bootstrap(): void { + parent::bootstrap(); + + $token = $this->config->get("{$this->module_name}_token"); + if (empty($token)) { + Config::setForceSmartRouting(true); + + return; + } + + Config::setToken($token); + } } diff --git a/admin/view/template/extension/payment/emerchantpay_direct.twig b/admin/view/template/extension/payment/emerchantpay_direct.twig index 06a3fd2..6744e61 100644 --- a/admin/view/template/extension/payment/emerchantpay_direct.twig +++ b/admin/view/template/extension/payment/emerchantpay_direct.twig @@ -79,9 +79,11 @@ placeholder="{{ entry_password }}" class="form-control"/> -
-