Skip to content

Commit

Permalink
Release 6.0.1
Browse files Browse the repository at this point in the history
* Fix gift products only for 1.7.5
refs #34471

* refs #35787 fixbug. wrong order status

* version

* refs #35926 the typo in an upgrade script

* refs #35853 webhook functionality. customization of the order status

* refs #35989
Fix prices sent in HT when group displaying price HT

* version

* refs #35967 missing transaction id

* refs #35927 webhook functionality. Check the event state

* refs #36106
Fix round total on handlings discounts

* refs #36276 webhook functionality. necessity of the employee in context

* small fix

* refs #36159 shortcut on signup page

* small fix

* refs #36457 webhookfunctionality. small fix

* refs #35927 webhooks. order status managing

* module version

* refs #35623 tracking info

* module version

* refs #36733 white list. option enabled

* refs #36733 white list. option list of ips

* refs #36733 paypal availability according to the ip white list

* php-cs-fixer

* Update bug report issue form

* Fix exception thrown on confirmation page (#139)

* Fix exception thrown on confirmation page (#139)

* refs #37072 warning during order creation

* refs #34920 Payment via CB does not work in "IN CONTEXT" mode

* refs #36628 PUI. onboarding button

* webhook. small fix

* refs #37078 paypal checkout. sending address

* refs #37272 compatible with PS 8.0

* refs #37262 compatibility with PS8

* small fix

* compatibility with php 5.6

* small fix

* refs #37369 warnings

* phpstan

* Add lintner php 8.0 and 8.1 (#144)

Co-authored-by: bogdan202 <byampolskiy@202-ecommerce.com>

* refs #37416 warning during webhook-event handling

* refs #37569 option show benefits

* collate cause error during installation (#146)

* refs #37083 MySQL COLLATE causes an error during a module installation

* refs #37083 backward-compatibility.php

* refs #37083 phpcsfixer

* refs #35971 webhook notifications. response code

* refs #37360 IP white-list. style

* refs #35623 tracking info. paypal carriers by country (#148)

* module version

* refs #37735 webhook event handling. order state (#152)

* refs #37879 translations

* refs #35048 translations

* refs #37743 handling the exceptions (#153)

* translations

* refs #34923 use default status if customize one is not set (#155)

* Create SECURITY.md

* refs #37203 test for webhook event. types COMPLETED and PENDING

* refs #37203 unit test for webhook. refund and partial refund

* refs #37203 Readme.md

* refs #37203 unit tests for webhook. events: authorization.voided, capture.denied, capture.reversed

* refs #37203 github workflows

* refs #37203 small fix

* refs #38144 small fix

* refs #37203 test for completed event when a current order state is PS_OS_OUTOFSTOCK_UNPAID

* refs #37203 small modification in Readme.md

* license update

* refs #38341 the alias list for PrestaShop iso country codes (#164)

* Add TLS 1.3 checks (33017) (#160)

* refs #33017 tls verification

* small fix

* Define webhook unit tests (37203) (#158)

* refs #37203 test for webhook event. types COMPLETED and PENDING

* refs #37203 unit test for webhook. refund and partial refund

* refs #37203 Readme.md

* refs #37203 unit tests for webhook. events: authorization.voided, capture.denied, capture.reversed

* refs #37203 github workflows

* refs #37203 small fix

* refs #37203 test for completed event when a current order state is PS_OS_OUTOFSTOCK_UNPAID

* refs #37203 small modification in Readme.md

* refs #36734 test for a case #37743

* module version

* small fix

* composer json settings

* small fix

* Feature/38361 admin page message (#166)

* refs #38361 admin page message

* php-cs-fixer

* refs #38526 wrong paypal-metadata-id

* refs #38628 - FraudNet clientId
Add ClientId for FraudNet Form PUI

* refs #38649 mysql errors (#175)

* refs #38495 redirection mode

* refs #38685 compatibility with PS 8 (#178)

SQL error during updating/installation

* module version

* Feature/38360 card mark (#167)

* refs #38360 mark for credit card

* refs #38360 marks for paypal wallet and pay later

* refs #38360 small fix

* Feature/38495 put paypal button at end (#181)

* refs #38495 move paypal button at end of the page

* refs #38495 credit card

* refs #38495 translations

* php-cs-fixer

* refs #39105 js errors

* refs #38364 redirect mode for alternative method (#180)

* module version

* Payment buttons - on checkout loading (#183)

* refs #38495 - Payment buttons
Check if the conditions approved and enable buttons on payment selection
This is now done when checkbox is hit and when a payment is selected.

* refs #38495 - Payment buttons and loading
Fix BNPL is not correctly loading if payment method selected on loading.
Fix a template variables problem too

* refs #39439 fix typo

* refs #39442 js errors (#186)

* refs #39443 mobile view (#185)

* refs #39297 logo for giropay and sofort

* Add diagnostic tab (36732) (#161)

* refs #36732 diagnostic tab

* refs #36732 diagnostic tab

* ppbtlib. small modif

* refs #36732 diagnostic tab. verification of a  module version and md5 verification

* refs #36732 remove unuseful

* license

* license

* refs #36732 remove connect.tpl

* refs #36732 diagnostic tab. order states comparing

* refs #36732 script upgrade + adding known conflicts info

* refs #36732 order_state.tpl

* refs #36732 respository link

* refs #39445 deleted export button

* refs #39436 removed button "Help" on the Diagnostic page

* refs #39426 diagnostic tab is not visible

* refs #39549 refacto

* refs #39549 remover useless

* refs #39549 remove db optimization

* Update DatabaseStubHandler.php

* refs #39549 refacto

* module version

* Update CacheStorage.php

* refs #39426 error during update

* refs #39549

---------

Co-authored-by: Clotaire <52157233+clotairer@users.noreply.github.com>

* refs #39502 module version

* refs #39623 package-lock.json (#191)

* Bump axios from 0.19.2 to 0.21.2 (#195)

Bumps [axios](https://github.com/axios/axios) from 0.19.2 to 0.21.2.
- [Release notes](https://github.com/axios/axios/releases)
- [Changelog](https://github.com/axios/axios/blob/v0.21.2/CHANGELOG.md)
- [Commits](axios/axios@v0.19.2...v0.21.2)

---
updated-dependencies:
- dependency-name: axios
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump scss-tokenizer and node-sass (#194)

Bumps [scss-tokenizer](https://github.com/sasstools/scss-tokenizer) to 0.4.3 and updates ancestor dependency [node-sass](https://github.com/sass/node-sass). These dependencies need to be updated together.


Updates `scss-tokenizer` from 0.2.3 to 0.4.3
- [Release notes](https://github.com/sasstools/scss-tokenizer/releases)
- [Commits](sasstools/scss-tokenizer@v0.2.3...v0.4.3)

Updates `node-sass` from 4.14.1 to 8.0.0
- [Release notes](https://github.com/sass/node-sass/releases)
- [Changelog](https://github.com/sass/node-sass/blob/master/CHANGELOG.md)
- [Commits](sass/node-sass@v4.14.1...v8.0.0)

---
updated-dependencies:
- dependency-name: scss-tokenizer
  dependency-type: indirect
- dependency-name: node-sass
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump postcss and css-loader (#193)

Bumps [postcss](https://github.com/postcss/postcss) to 7.0.39 and updates ancestor dependency [css-loader](https://github.com/webpack-contrib/css-loader). These dependencies need to be updated together.


Updates `postcss` from 6.0.23 to 7.0.39
- [Release notes](https://github.com/postcss/postcss/releases)
- [Changelog](https://github.com/postcss/postcss/blob/7.0.39/CHANGELOG.md)
- [Commits](postcss/postcss@6.0.23...7.0.39)

Updates `css-loader` from 1.0.1 to 6.7.3
- [Release notes](https://github.com/webpack-contrib/css-loader/releases)
- [Changelog](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/css-loader@v1.0.1...v6.7.3)

---
updated-dependencies:
- dependency-name: postcss
  dependency-type: indirect
- dependency-name: css-loader
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump node-forge and webpack-dev-server (#192)

Bumps [node-forge](https://github.com/digitalbazaar/forge) to 1.3.1 and updates ancestor dependency [webpack-dev-server](https://github.com/webpack/webpack-dev-server). These dependencies need to be updated together.


Updates `node-forge` from 0.10.0 to 1.3.1
- [Release notes](https://github.com/digitalbazaar/forge/releases)
- [Changelog](https://github.com/digitalbazaar/forge/blob/main/CHANGELOG.md)
- [Commits](digitalbazaar/forge@0.10.0...v1.3.1)

Updates `webpack-dev-server` from 3.11.3 to 4.13.2
- [Release notes](https://github.com/webpack/webpack-dev-server/releases)
- [Changelog](https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md)
- [Commits](webpack/webpack-dev-server@v3.11.3...v4.13.2)

---
updated-dependencies:
- dependency-name: node-forge
  dependency-type: indirect
- dependency-name: webpack-dev-server
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refs #39502 improve quick payment (#189)

* refs #39758 track only paypal orders (#197)

Co-authored-by: bogdan202 <byampolskiy@202-ecommerce.com>

* refs #39623 package.json (#201)

* refs #39623 package.json

* refs #39623 build.xml

* refs #39623 build.xml

* refs #39623 - fix Node version to 14.17.3

* refs #39623 - rebuild node-sass for v.14.17.3

* refs #39623 - Fix totbuilder
Remove package.json after NPM build to avoid to do it two times

* refs #39623 - Fix totbuilder
Remove package.json after NPM build to avoid to do it two times

---------

Co-authored-by: kgleizes <kgleizes@202-ecommerce.com>

* refs #39736 enable fix db (#190)

* Bump guzzlehttp/psr7 from 1.9.0 to 1.9.1 (#200)

Bumps [guzzlehttp/psr7](https://github.com/guzzle/psr7) from 1.9.0 to 1.9.1.
- [Release notes](https://github.com/guzzle/psr7/releases)
- [Changelog](https://github.com/guzzle/psr7/blob/1.9.1/CHANGELOG.md)
- [Commits](guzzle/psr7@1.9.0...1.9.1)

---
updated-dependencies:
- dependency-name: guzzlehttp/psr7
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refs #39671 - Fix build jenkins

* Feature/36736 UI (#209)

* refs #36736 cleaning

* refs #36736 CheckoutForm, FormInstallement

* refs #36736 form decription

* refs #36736 AccountForm

* refs #36736 OrderStatusForm

* refs #36736 OrderStatusForm

* refs #36736 ShortcutConfigurationForm

* refs #39429 - Start FO integration

* refs #39429 - Fix forms + styles

* refs #39429 - Add dashboard section

* refs #39429 ShortcutConfigurationForm

* refs #39429 - Modal steps configuration integration

* refs #39439 save Checkout Form

* refs #39439 save Tracking Form

* refs #39439 save BNPL form

* refs #39439 save order status form

* refs #39439 save shortcut config form

* refs #39439 show modal after installation

* build.xml

* refs #39439 account form

* refs #39439 apm methods

* refs #39439

* refs #39439 technical checklist

* refs #39429 feature checklist

* refs #39429 pui link

* refs #39429 dashboard links

* refs #39429 dashboard

* refs #39429 remove AdminPaypalGetCredentialsController

* refs #39429 merchant id

* refs #39429 - Finalize reintegration

* refs #39429 - Show size fields for shortcut button

* refs #39429 - Remove 'Check the claims' action from dashboard

* refs #40300 warnings on the admin setting page

* refs #40326 widget code for banner

* refs #40322 button preview should be unclickable

* refs #40320 bug. reseting order status settings

* refs #40320 save order status form

* refs #40318 order status configurations

* refs #40301 the configurations order

* refs #40295 default style configuration of preview

* refs #40269 removes a button "Help"

* refs #40294 refresh button for technical/feature checklist

* refs #40360 feature checklist

* refs #40359 feature checklist

* refs #40270 sandbox mode indication

* refs #40357 order status form

* refs #40356 bnpl form

* refs #40355 checkout form

* refs #40355 checkout form. default values

* refs #40355 checkout form in boarding process

* refs #40354 account form. texts

* refs #40349 translations

* refs #40302 checkout form. texts

* refs #40293 admin configuration page navigation

* refs #40358 dashboard

* refs #40215 configurations. texts

* refs #40212 feature checklist

* refs #40215 texts

* refs #40208 availability by IP

* refs #40212 feature checklist

* refs #40277 texts

* refs #40291 verification rounding settings

* refs #40312 shortcut configuration form

* refs #40348 help info

* refs #40418 shortcut configuration form

* refs #40418 shortcut configuration form

* refs #40413 technical checklist

* refs #40407 default configurations

* refs #40405 default configurations

* refs #40402 texts

* refs #40392 translations

* refs #40425 refresh forms after save

* refs #40409 reload page after boarding

* refs #40408 bnpl form

* refs #40417 form "Restriction mode"

* refs #40411 refresh dashboard

* refs #40478 preview shortcut button

* refs #40265 - Show placeholders on some Checkout / Shortcut form fields

* refs #40406 help info for a customer instruction

* refs #40265 - Remove some unnecessary comments

* refs #39919 the error handle

* refs #40486 feature checklist

* refs #40427 customized shortcut button

* refs #40403 1st boarding step

* refs #40520 texts

* refs #40402 texts

* refs #40601 remove .map files

* refs #40601 remove old images

* refs #40594 banner color configuration

* refs #40607 checkout form

* refs #40604 texts

* refs #40609 bnpl form

* refs #40611 Mexico. card + paypal wallet

* refs #40392 translations

* php-cs-fixer

* phpstan

---------

Co-authored-by: Natalia <nprokopenko@202-ecommerce.com>

* refs #40816 enable banner by default

* validation

* refs #40859 script update

* PS validator modification (#213)

* ps validator

* refs #40980 check of a context

* refs #40962 welcome board

* refs #40962 welcome board

* refs #40980 small fix

* phpstan

* merge release/x into deveop

* Hotfixes/41114 bnpl form error500 if not eligible (#221)

* refs #41037 - Compatibility old versions
Fetch admin template to stay compatible with PS 1.7.5-
Bump version to 6.0.1

* refs #41037 - Fix modal configuration
Fix version 6.0.1

* refs #41122 - Fix templates PS1.7.3-

* refs #41129 - Fix configuration saving ajax

* refs #41129 - Fix configuration saving ajax
Fix close modal after save

* refs #41114 - Fix error 500 for countries not BNPL
On onboarding modal, the installmentForm was called iven if not injected
in the smarty variables.
The step max number is now updated depending the count of forms

* refs #41114 - Small fix on step number
Now displayed when the popup is opened (and not on second step).

* refs #40922 build optimization (#225)

* refs #41033 translations (#224)

* refs #41033 translations

* refs #40773 texts

* refs #40772 texts

* refs #40771 texts

* refs #40770 texts

* refs #40769 texts

* refs #40767 texts

* refs #40604 texts

* refs #40765 merchant id label (#223)

* refs #40102 processing instruction for alternative methods (#222)

* Bump engine.io from 6.4.1 to 6.4.2 (#202)

Bumps [engine.io](https://github.com/socketio/engine.io) from 6.4.1 to 6.4.2.
- [Release notes](https://github.com/socketio/engine.io/releases)
- [Changelog](https://github.com/socketio/engine.io/blob/main/CHANGELOG.md)
- [Commits](socketio/engine.io@6.4.1...6.4.2)

---
updated-dependencies:
- dependency-name: engine.io
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump socket.io-parser from 4.2.2 to 4.2.4 (#210)

Bumps [socket.io-parser](https://github.com/socketio/socket.io-parser) from 4.2.2 to 4.2.4.
- [Release notes](https://github.com/socketio/socket.io-parser/releases)
- [Changelog](https://github.com/socketio/socket.io-parser/blob/main/CHANGELOG.md)
- [Commits](socketio/socket.io-parser@4.2.2...4.2.4)

---
updated-dependencies:
- dependency-name: socket.io-parser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refs #39975 compatible with PS 8.x (#227)

* refs #39949 warning on diagnostic page (#228)

* refs #39893 validation for a string field in db (#229)

* Bump tough-cookie from 4.1.2 to 4.1.3 (#220)

Bumps [tough-cookie](https://github.com/salesforce/tough-cookie) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/salesforce/tough-cookie/releases)
- [Changelog](https://github.com/salesforce/tough-cookie/blob/master/CHANGELOG.md)
- [Commits](salesforce/tough-cookie@v4.1.2...v4.1.3)

---
updated-dependencies:
- dependency-name: tough-cookie
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Feature/39893 db string validation (#231)

* refs #39893 upgrade script

* refs #40765 wrong location of a save button (#232)

* Bugfix/texts (#234)

refs #40768 texts

* refs #41320 smarty error on some PS versions (#235)

* refs #40774 checklist (#233)

* refs #40774 checklist

* refs #40941 feature checklist

* refs #40102 handling completed payments (#236)

* Bugfix/texts (#237)

refs #40994 translations

* Bugfix/texts (#238)

 refs #40994 translations

* Bugfix/texts (#240)

refs #40994 translations

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: kgleizes <kgleizes@202-ecommerce.com>
Co-authored-by: Clotaire <52157233+clotairer@users.noreply.github.com>
Co-authored-by: Lorenz Meyer <lorenz@meyer.tl>
Co-authored-by: 202 ecommerce <202-ecommerce@users.noreply.github.com>
Co-authored-by: 202 - Kévin Gleizes <98040531+kgleizes@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Natalia <nprokopenko@202-ecommerce.com>
  • Loading branch information
8 people authored Jul 21, 2023
1 parent 477116f commit 784602d
Show file tree
Hide file tree
Showing 104 changed files with 1,349 additions and 317 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions _dev/js/admin/steps.js → 202/_dev/js/admin/steps.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,19 @@ class Steps {
this.btn = '[data-btn-action]';
this.content = '[data-step-content]';
this.currentStepBadge = '[data-badge-current-step]';
this.maxStepBadge = '[data-badge-max-step]';
this.stepsProgress = '[data-steps-progress]';
this.controller = document.location.href;
}

init() {
this.registerEvents();
this.$stepsContainer.find(this.maxStepBadge).html($(this.content).length);
}

registerEvents() {
$(document).on('afterFormSaved', (e) => {
if (e.detail.form.classList.contains('form-modal') == false) {
if (e.originalEvent.detail.form.classList.contains('form-modal') == false) {
return;
}

Expand All @@ -23,7 +25,7 @@ class Steps {
this.updateStepsProgress();

if (this.getCurrentStepIndex() == -1) {
$(e.detail.form).closest('.modal').modal('hide');
$(e.originalEvent.detail.form).closest('.modal').modal('hide');
document.location.reload();
}
});
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion 202/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<property name="src-dir" value="${basedir}" />
<property name="TARGETNAME" value="paypal" />
<property name="TARGETBRANCH" value="${env.GIT_BRANCH}" />
<property name="TARGETVERSION" value="6.0.0" />
<property name="TARGETVERSION" value="6.0.1" />
<property name="PHPVERSION" value="5.6" />
<property name="PSVERSION" value="1.7.5.2" />

Expand Down
66 changes: 65 additions & 1 deletion classes/API/Request/PaypalOrderGetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ public function execute()
$orderGetRequest = new OrdersGetRequest($this->idPayment);
$orderGetRequest->headers = array_merge($this->getHeaders(), $orderGetRequest->headers);
$exec = $this->client->execute($orderGetRequest);

if (in_array($exec->statusCode, [200, 201, 202])) {
$response->setSuccess(true)
->setData($exec);
Expand All @@ -79,6 +78,12 @@ public function execute()
$response->setPurchaseUnit($this->getPurchaseUnit($exec));
$response->setStatus($this->getStatus($exec));
$response->setDepositBankDetails($this->getDepositBankDetails($exec));

$response->setTransactionId($this->getTransactionId($exec))
->setPaymentMethod($this->getPaymentMethod($exec))
->setPaymentTool($this->getPaymentTool())
->setMethod($this->getMethodTransaction())
->setDateTransaction($this->getDateTransaction($exec));
} else {
$error = new Error();
$resultDecoded = json_decode($exec->message);
Expand Down Expand Up @@ -241,4 +246,63 @@ protected function getDepositBankDetails(\PayPalHttp\HttpResponse $exec)

return $bankDetails;
}

protected function getTransactionId($exec)
{
if (false === empty($exec->result->purchase_units[0]->payments->captures[0]->id)) {
return $exec->result->purchase_units[0]->payments->captures[0]->id;
}

if (false === empty($exec->result->purchase_units[0]->payments->authorizations[0]->id)) {
return $exec->result->purchase_units[0]->payments->authorizations[0]->id;
}

return '';
}

protected function getPaymentTool()
{
return '';
}

protected function getPaymentMethod($exec)
{
if (false === empty($exec->result->payment_source->sofort)) {
return 'sofort';
}

if (false === empty($exec->result->payment_source->giropay)) {
return 'giropay';
}

return 'paypal';
}

protected function getDateTransaction($exec)
{
$payments = $exec->result->purchase_units[0]->payments;
$transaction = $payments->captures[0];
$date = \DateTime::createFromFormat(\DateTime::ATOM, $transaction->create_time);

return $date;
}

protected function getMethodTransaction()
{
switch (get_class($this->method)) {
case 'MethodEC':
$method = 'EC';
break;
case 'MethodMB':
$method = 'MB';
break;
case 'MethodPPP':
$method = 'PPP';
break;
default:
$method = '';
}

return $method;
}
}
115 changes: 115 additions & 0 deletions classes/API/Response/ResponseOrderGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ class ResponseOrderGet extends Response
/** @var string */
protected $status;

/** @var string */
protected $transactionId;

/** @var \DateTime */
protected $dateTransaction;

/** @var string */
protected $paymentMethod;

/** @var string */
protected $paymentTool;

/** @var string */
protected $method;

public function __construct()
{
$this->setClient(new Client());
Expand Down Expand Up @@ -130,4 +145,104 @@ public function getDepositBankDetails()
{
return $this->depositBankDetails;
}

/**
* @return string
*/
public function getTransactionId()
{
return $this->transactionId;
}

/**
* @param string $transactionId
*
* @return ResponseOrderGet
*/
public function setTransactionId(string $transactionId)
{
$this->transactionId = $transactionId;

return $this;
}

/**
* @return \DateTime
*/
public function getDateTransaction()
{
return $this->dateTransaction;
}

/**
* @param \DateTime $dateTransaction
*
* @return ResponseOrderGet
*/
public function setDateTransaction(\DateTime $dateTransaction)
{
$this->dateTransaction = $dateTransaction;

return $this;
}

/**
* @return string
*/
public function getPaymentMethod()
{
return $this->paymentMethod;
}

/**
* @param string $paymentMethod
*
* @return ResponseOrderGet
*/
public function setPaymentMethod(string $paymentMethod)
{
$this->paymentMethod = $paymentMethod;

return $this;
}

/**
* @return string
*/
public function getPaymentTool()
{
return $this->paymentTool;
}

/**
* @param string $paymentTool
*
* @return ResponseOrderGet
*/
public function setPaymentTool(string $paymentTool)
{
$this->paymentTool = $paymentTool;

return $this;
}

/**
* @return string
*/
public function getMethod()
{
return $this->method;
}

/**
* @param string $method
*
* @return ResponseOrderGet
*/
public function setMethod(string $method)
{
$this->method = $method;

return $this;
}
}
52 changes: 47 additions & 5 deletions classes/AbstractMethodPaypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
use Module;
use PayPal;
use PaypalAddons\classes\API\PaypalApiManagerInterface;
use PaypalAddons\classes\API\Response\Error;
use PaypalAddons\classes\API\Response\Response;
use PaypalAddons\classes\API\Response\ResponseOrderCapture;
use PaypalAddons\classes\API\Response\ResponseOrderGet;
use PaypalAddons\classes\API\Response\ResponseOrderRefund;
use PaypalAddons\classes\PUI\SignupLink;
Expand All @@ -46,6 +48,7 @@
use PaypalAddons\classes\Shortcut\ShortcutSignup;
use PaypalAddons\classes\Webhook\WebhookOption;
use PaypalAddons\services\Order\RefundAmountCalculator;
use PaypalAddons\services\PaypalContext;
use PaypalAddons\services\StatusMapping;
use PaypalPPBTlib\AbstractMethod;
use PrestaShopLogger;
Expand Down Expand Up @@ -153,6 +156,7 @@ public function init()
*/
public function initApm($method)
{
PaypalContext::getContext()->set('processing_instruction', 'ORDER_COMPLETE_ON_PAYMENT_APPROVAL');
$response = $this->init();
$confirmation = $this->paypalApiManager->getConfirmPaymentSourceRequest($response->getPaymentId(), $method)->execute();

Expand Down Expand Up @@ -186,11 +190,7 @@ public function validation()
throw new Exception('The elements in the shopping cart were changed. Please try to pay again.');
}

if ($this->getIntent() == 'CAPTURE') {
$response = $this->paypalApiManager->getOrderCaptureRequest($this->getPaymentId())->execute();
} else {
$response = $this->paypalApiManager->getOrderAuthorizeRequest($this->getPaymentId())->execute();
}
$response = $this->completePayment();

if ($response->isSuccess() == false) {
throw new Exception($response->getError()->getMessage());
Expand All @@ -214,6 +214,48 @@ public function validation()
);
}

/**
* @return ResponseOrderCapture
*/
protected function completePayment()
{
/** @var ResponseOrderGet $getOrderResponse */
$getOrderResponse = $this->paypalApiManager->getOrderGetRequest($this->getPaymentId())->execute();

if ($getOrderResponse->getStatus() === 'APPROVED') {
if ($this->getIntent() == 'CAPTURE') {
return $this->paypalApiManager->getOrderCaptureRequest($this->getPaymentId())->execute();
} else {
return $this->paypalApiManager->getOrderAuthorizeRequest($this->getPaymentId())->execute();
}
}

$response = new ResponseOrderCapture();

if ($getOrderResponse->getStatus() !== 'COMPLETED') {
$error = new Error();
$error->setMessage('Payment was not approved');
$response->setError($error)->setSuccess(false);

return $response;
}

$response->setSuccess(true)
->setData($getOrderResponse->getData())
->setPaymentId($this->getPaymentId())
->setTransactionId($getOrderResponse->getTransactionId())
->setCurrency($getOrderResponse->getPurchaseUnit()->getCurrency())
->setCapture($this->getIntent() !== 'CAPTURE')
->setTotalPaid($getOrderResponse->getPurchaseUnit()->getAmount())
->setStatus($getOrderResponse->getStatus())
->setPaymentMethod($getOrderResponse->getPaymentMethod())
->setPaymentTool($getOrderResponse->getPaymentTool())
->setMethod($getOrderResponse->getMethod())
->setDateTransaction($getOrderResponse->getDateTransaction());

return $response;
}

/**
* @param \PaypalAddons\classes\API\Response\ResponseOrderCapture $data
*
Expand Down
2 changes: 1 addition & 1 deletion classes/Form/CheckoutForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function getDescription()
'label' => $this->module->l('Brand name', 'CheckoutForm'),
'name' => PaypalConfigurations::BRAND_NAME,
'value' => Configuration::get(PaypalConfigurations::BRAND_NAME),
'placeholder' => $this->module->l('Leave it empty to use your Shop name setup on your PayPal account', 'AdminPayPalCustomizeCheckoutController'),
'placeholder' => $this->module->l('Leave it empty to use your shop name', 'AdminPayPalCustomizeCheckoutController'),
'hint' => $this->module->l('A label that overrides the business name in the PayPal account on the PayPal pages. If logo is set, then brand name won\'t be shown.', 'AdminPayPalCustomizeCheckoutController'),
];

Expand Down
2 changes: 1 addition & 1 deletion classes/Form/FormInstallment.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function getDescription()

$fields[ConfigurationMap::ENABLE_INSTALLMENT] = [
'type' => 'switch',
'label' => $this->module->l('Pay later messaging', $this->className),
'label' => $this->module->l('Display Pay Later Messaging on your site', $this->className),
'name' => ConfigurationMap::ENABLE_INSTALLMENT,
'hint' => $this->module->l('Let your customers know about the option \'Pay 4x PayPal\' by displaying banners on your site.', $this->className),
'values' => [
Expand Down
14 changes: 10 additions & 4 deletions classes/Form/TechnicalChecklistForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,17 @@ public function getDescription()
'localizationUrl' => $this->context->link->getAdminLink('AdminLocalization', true),
];

if ($this->webhookOption->isEnable() && $this->webhookOption->isEligibleContext()) {
$webhookCheck = $this->checker->checkWebhook();
if ($this->webhookOption->isEligibleContext()) {
$tpl_vars['showWebhookState'] = true;
$tpl_vars['webhookState'] = $webhookCheck['state'];
$tpl_vars['webhookStateMsg'] = $webhookCheck['message'];

if ($this->webhookOption->isEnable()) {
$webhookCheck = $this->checker->checkWebhook();
$tpl_vars['isWebhookEnabled'] = true;
$tpl_vars['webhookState'] = $webhookCheck['state'];
$tpl_vars['webhookStateMsg'] = $webhookCheck['message'];
} else {
$tpl_vars['isWebhookEnabled'] = false;
}
}

return [
Expand Down
2 changes: 1 addition & 1 deletion classes/PaypalCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class PaypalCapture extends ObjectModel
'id_capture' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'id_paypal_order' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId'],
'capture_amount' => ['type' => self::TYPE_FLOAT, 'size' => 10, 'scale' => 2],
'result' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'result' => ['type' => self::TYPE_STRING, 'validate' => 'isCleanHtml'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat'],
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat'],
],
Expand Down
4 changes: 2 additions & 2 deletions classes/PaypalIpn.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ class PaypalIpn extends ObjectModel
'multilang' => false,
'fields' => [
'id_transaction' => ['type' => self::TYPE_STRING, 'validate' => 'isGenericName'],
'status' => ['type' => self::TYPE_STRING, 'validate' => 'isString'],
'response' => ['type' => self::TYPE_HTML, 'validate' => 'isString'],
'status' => ['type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 50],
'response' => ['type' => self::TYPE_HTML, 'validate' => 'isCleanHtml'],
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDateFormat'],
],
'collation' => 'utf8_general_ci',
Expand Down
Loading

0 comments on commit 784602d

Please sign in to comment.