@@ -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
0 commit comments