Skip to content

Commit 93b6e94

Browse files
Merge branch 'hotfix/2.0.7'
2 parents 1592ca5 + eeaaaac commit 93b6e94

8 files changed

Lines changed: 74 additions & 59 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2.0.7, 2023-04-26:
2+
- Bug fix: Update order balance in case of online refund.
3+
- Improve module documentation management field.
4+
15
2.0.6, 2023-01-04:
26
- Consider IPN on operations from merchant Back Office.
37
- Update list of supported payment means.

commerce_payzen/commerce_payzen.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ dependencies:
66
- commerce_payment
77

88
# information about project
9-
version: "8.x-9.x-2.0.6"
9+
version: "8.x-9.x-2.0.7"
1010
core: "8.x"
1111
core_version_requirement: ^8 || ^9
1212
project: "commerce_payzen"

commerce_payzen/src/Includes/Form/Api.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,8 @@ public static function getSuccessStatuses()
257257
'AUTHORISED',
258258
'AUTHORISED_TO_VALIDATE', // TODO is this a pending status?
259259
'CAPTURED',
260-
'ACCEPTED'
260+
'ACCEPTED',
261+
'PARTIALLY_AUTHORISED'
261262
);
262263
}
263264

@@ -274,7 +275,8 @@ public static function getPendingStatuses()
274275
'WAITING_AUTHORISATION_TO_VALIDATE',
275276
'UNDER_VERIFICATION',
276277
'PRE_AUTHORISED',
277-
'WAITING_FOR_PAYMENT'
278+
'WAITING_FOR_PAYMENT',
279+
'PENDING'
278280
);
279281
}
280282

@@ -409,4 +411,18 @@ public static function getOverseasCountries()
409411
'TF', 'WF', 'YT'
410412
);
411413
}
414+
415+
/**
416+
* Returns an array of the online documentation URI of the payment module.
417+
*
418+
* @return array[string][string]
419+
*/
420+
public static function getOnlineDocUri()
421+
{
422+
return array(
423+
'fr' => 'https://payzen.io/fr-FR/plugins/',
424+
'en' => 'https://payzen.io/en-EN/plugins/',
425+
'es' => 'https://payzen.io/es-ES/plugins/'
426+
);
427+
}
412428
}

commerce_payzen/src/Plugin/Commerce/PaymentGateway/Payzen.php

Lines changed: 40 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -134,37 +134,27 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
134134
];
135135

136136
// Get documentation links.
137-
$filenames = glob(drupal_get_path('module', 'commerce_payzen') . '/installation_doc/' . Tools::DOC_PATTERN);
138-
139137
$doc_langs = array(
140138
'fr' => 'Français',
141139
'en' => 'English',
142-
'es' => 'Español'
143-
// complete when more languages are managed.
140+
'es' => 'Español',
141+
'pt' => 'Português'
142+
// Complete when more languages are managed.
144143
);
145144

146-
$doc_files = array();
147-
foreach ($filenames as $filename) {
148-
$base_filename = basename($filename, '.pdf');
149-
$lang = substr($base_filename, -2); // Extract language code.
145+
$docs = '<span class="payzen-doc-links">' . $this->t('Click to view the module configuration documentation: ');
150146

151-
$doc_files[$base_filename . '.pdf'] = $doc_langs[$lang];
147+
foreach (PayzenApi::getOnlineDocUri() as $lang => $docUri) {
148+
$docs .= '<a href="' . $docUri . 'drupal-commerce2/sitemap.html" target="_blank">' . $doc_langs[$lang] . '</a>';
152149
}
153150

154-
if (! empty($doc_files)) {
155-
$doc = '<span class="payzen-doc-links">' . $this->t('Click to view the module configuration documentation :');
156-
foreach ($doc_files as $file => $lang) {
157-
$doc .= '<a href="' . base_path() . drupal_get_path('module', 'commerce_payzen') . '/installation_doc/' . $file . '" target="_blank">' . $lang . '</a>';
158-
}
159-
160-
$doc .= '</span>';
151+
$docs .= '</span>';
161152

162-
$form['module_info']['doc_links'] = [
163-
'#type' => 'item',
164-
'#title' => '',
165-
'#markup' => $doc
166-
];
167-
}
153+
$form['module_info']['doc_links'] = [
154+
'#type' => 'item',
155+
'#title' => '',
156+
'#markup' => $docs
157+
];
168158

169159
// Payment gateway access.
170160
$form['gateway_access'] = [
@@ -664,6 +654,9 @@ public function onNotify(Request $request)
664654
$order->getState()->applyTransitionById('cancel');
665655
$order->save();
666656
}
657+
} else {
658+
$payment_order_updater = \Drupal::service('commerce_payment.order_updater');
659+
$payment_order_updater->updateOrder($order, true);
667660
}
668661

669662
die($response->getOutputForPlatform('payment_ok_already_done'));
@@ -717,42 +710,44 @@ private function savePayment($order, $response)
717710

718711
$payment->setRemoteId($trans_uuid);
719712
$payment->setRemoteState($response->getTransStatus());
713+
$timestamp = \Drupal::time()->getRequestTime();
720714

721715
if ($response->get('operation_type') == 'CREDIT') {
722716
$payment->setAmount(new Price('0', $currency->getAlpha3())); // It's a refund, not an actual payment.
723717
$payment->setRefundedAmount($amount);
724718
$state = 'refunded';
719+
$payment->setCompletedTime($timestamp);
725720
} elseif ($response->isAcceptedPayment() && $payment->getAmount() && $amount->lessThan($payment->getAmount())) {
726721
// Case of modification of a non-captured payment.
727722
$refunded_amount = $payment->getAmount()->subtract($amount);
728723
$payment->setRefundedAmount($refunded_amount);
729724
$state = 'partially_refunded';
730725
} else {
731-
$payment->setAmount($amount);
732-
733-
switch ($response->getTransStatus()) {
734-
case 'AUTHORISED' :
735-
case 'ACCEPTED' :
736-
case 'CAPTURED' :
737-
$state = 'completed';
738-
break;
739-
740-
case 'AUTHORISED_TO_VALIDATE' :
741-
case 'WAITING_AUTHORISATION_TO_VALIDATE' :
742-
case 'WAITING_AUTHORISATION' :
743-
case 'UNDER_VERIFICATION' :
744-
case 'INITIAL' :
745-
case 'WAITING_FOR_PAYMENT' :
746-
$state = 'pending';
747-
break;
748-
749-
default:
750-
$state = 'voided';
751-
break;
752-
}
726+
$payment->setAmount($amount);
727+
728+
switch ($response->getTransStatus()) {
729+
case 'AUTHORISED' :
730+
case 'ACCEPTED' :
731+
case 'CAPTURED' :
732+
$state = 'completed';
733+
break;
734+
735+
case 'AUTHORISED_TO_VALIDATE' :
736+
case 'WAITING_AUTHORISATION_TO_VALIDATE' :
737+
case 'WAITING_AUTHORISATION' :
738+
case 'UNDER_VERIFICATION' :
739+
case 'INITIAL' :
740+
case 'WAITING_FOR_PAYMENT' :
741+
$state = 'pending';
742+
break;
743+
744+
default:
745+
$state = 'voided';
746+
break;
747+
}
753748
}
754749

755-
$payment->setAuthorizedTime(\Drupal::time()->getRequestTime());
750+
$payment->setAuthorizedTime($timestamp);
756751
$payment->setState($state);
757752
$payment->save();
758753

commerce_payzen/src/Tools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class Tools
2424
const GATEWAY_CODE = 'PayZen';
2525
const GATEWAY_VERSION = 'V2';
2626
const CMS_IDENTIFIER = 'Drupal_Commerce_2.x';
27-
const PLUGIN_VERSION = '2.0.6';
28-
const DOC_PATTERN = '${doc.pattern}';
27+
const PLUGIN_VERSION = '2.0.7';
28+
const DOC_PATTERN = '###DOC_PATTERN###';
2929

3030
public static $pluginFeatures = array(
3131
'qualif' => false,

commerce_payzen/translations/payzen.de.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: PayZen for Drupal Commerce (8.x-"
4-
"2.0.6)\n"
4+
"2.0.7)\n"
55
"Report-Msgid-Bugs-To: \n"
66
"POT-Creation-Date: 2020-12-02 14:59+0100\n"
77
"PO-Revision-Date: 2021-01-31 15:19+0100\n"
@@ -96,8 +96,8 @@ msgid "Gateway version"
9696
msgstr "Kompatibel mit Zahlungsschnittstelle"
9797

9898
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:148
99-
msgid "Click to view the module configuration documentation :"
100-
msgstr "Klicken Sie, um die Modul-Konfigurationsdokumentation zu finden:"
99+
msgid "Click to view the module configuration documentation: "
100+
msgstr "Klicken Sie, um die Modul-Konfigurationsdokumentation zu finden: "
101101

102102
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:166
103103
msgid "PAYMENT GATEWAY ACCESS"

commerce_payzen/translations/payzen.es.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: PayZen for Drupal Commerce (8.x-"
4-
"2.0.6)\n"
4+
"2.0.7)\n"
55
"Report-Msgid-Bugs-To: \n"
66
"POT-Creation-Date: 2020-12-02 15:02+0100\n"
77
"PO-Revision-Date: 2021-01-31 15:17+0100\n"
@@ -95,8 +95,8 @@ msgid "Gateway version"
9595
msgstr "Versión del portal"
9696

9797
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:148
98-
msgid "Click to view the module configuration documentation :"
99-
msgstr "Haga clic para ver la documentación de la configuración del módulo:"
98+
msgid "Click to view the module configuration documentation: "
99+
msgstr "Haga clic para ver la documentación de la configuración del módulo: "
100100

101101
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:166
102102
msgid "PAYMENT GATEWAY ACCESS"

commerce_payzen/translations/payzen.fr.po

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: PayZen for Drupal Commerce (8.x-"
4-
"2.0.6)\n"
4+
"2.0.7)\n"
55
"Report-Msgid-Bugs-To: \n"
66
"POT-Creation-Date: 2020-12-02 15:05+0100\n"
77
"PO-Revision-Date: 2021-01-31 15:16+0100\n"
@@ -96,8 +96,8 @@ msgid "Gateway version"
9696
msgstr "Version de la plateforme"
9797

9898
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:148
99-
msgid "Click to view the module configuration documentation :"
100-
msgstr "Cliquer pour accéder à la documentation de configuration du module :"
99+
msgid "Click to view the module configuration documentation: "
100+
msgstr "Cliquer pour accéder à la documentation de configuration du module: "
101101

102102
#: src/Plugin/Commerce/PaymentGateway/Payzen.php:166
103103
msgid "PAYMENT GATEWAY ACCESS"

0 commit comments

Comments
 (0)