diff --git a/commerce_wechat_pay.module b/commerce_wechat_pay.module
index 679f2f9..b8f5771 100644
--- a/commerce_wechat_pay.module
+++ b/commerce_wechat_pay.module
@@ -24,4 +24,4 @@ function commerce_wechat_pay_entity_load(array $entities, $entity_type_id) {
     }
   }
 
-}
\ No newline at end of file
+}
diff --git a/src/Plugin/Commerce/PaymentGateway/Micropay.php b/src/Plugin/Commerce/PaymentGateway/Micropay.php
index 47c2cb0..d222d91 100644
--- a/src/Plugin/Commerce/PaymentGateway/Micropay.php
+++ b/src/Plugin/Commerce/PaymentGateway/Micropay.php
@@ -98,7 +98,7 @@ class Micropay extends QRCodePaymentMode2 {
     /** @var \EasyWeChat\Payment\API $gateway; */
     $gateway = $this->gateway_lib;
 
-    $payment_entity=payment::load($payment_id);
+    $payment_entity=Payment::load($payment_id);
     if ($payment_entity) {
       try {
         $app = Factory::payment($gateway);
diff --git a/src/Plugin/Commerce/PaymentGateway/QRCodePaymentMode2.php b/src/Plugin/Commerce/PaymentGateway/QRCodePaymentMode2.php
index bf716fa..5e0da94 100644
--- a/src/Plugin/Commerce/PaymentGateway/QRCodePaymentMode2.php
+++ b/src/Plugin/Commerce/PaymentGateway/QRCodePaymentMode2.php
@@ -2,6 +2,7 @@
 
 namespace Drupal\commerce_wechat_pay\Plugin\Commerce\PaymentGateway;
 
+use Drupal\Core\File\FileSystemInterface;
 use Drupal\commerce_payment\Entity\Payment;
 use Drupal\commerce_payment\Entity\PaymentInterface;
 use Drupal\commerce_payment\Plugin\Commerce\PaymentGateway\OffsitePaymentGatewayBase;
@@ -118,7 +119,7 @@ class QRCodePaymentMode2 extends OffsitePaymentGatewayBase implements SupportsRe
     if (!empty($values['certpem'])) {
       // Check the file directory for storing cert/key files
       $path = self::KEY_URI_PREFIX;
-      $dir = file_prepare_directory($path, FILE_CREATE_DIRECTORY);
+      $dir = \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
       if (!$dir) {
         $form_state->setError($form['certpem'], $this->t('Commerce WeChat Pay cannot find your private file system. Please make sure your site has private file system configured!'));
         return;
@@ -131,7 +132,7 @@ class QRCodePaymentMode2 extends OffsitePaymentGatewayBase implements SupportsRe
         file_unmanaged_delete(self::KEY_URI_PREFIX . $this->configuration['certpem_uri']);
       }
       // We regenerate pem file in case the files were missing during server migration
-      $updated = file_unmanaged_save_data($values['certpem'], self::KEY_URI_PREFIX . $new_uri);
+      $updated = \Drupal::service('file_system')->saveData($values['certpem'], self::KEY_URI_PREFIX . $new_uri);
       if ($updated) {
         $values['certpem_uri'] = $new_uri;
       } else {
@@ -142,7 +143,7 @@ class QRCodePaymentMode2 extends OffsitePaymentGatewayBase implements SupportsRe
     if (!empty($values['keypem'])) {
       // Check the file directory for storing cert/key files
       $path = self::KEY_URI_PREFIX;
-      $dir = file_prepare_directory($path, FILE_CREATE_DIRECTORY);
+      $dir = \Drupal::service('file_system')->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
       if (!$dir) {
         $form_state->setError($form['keypem'], $this->t('Commerce WeChat Pay cannot find your private file system. Please make sure your site has private file system configured!'));
         return;
@@ -155,7 +156,7 @@ class QRCodePaymentMode2 extends OffsitePaymentGatewayBase implements SupportsRe
         file_unmanaged_delete(self::KEY_URI_PREFIX . $this->configuration['keypem_uri']);
       }
       // We regenerate pem file in case the files were missing during server migration
-      $updated = file_unmanaged_save_data($values['keypem'], self::KEY_URI_PREFIX . $new_uri);
+      $updated = \Drupal::service('file_system')->saveData($values['keypem'], self::KEY_URI_PREFIX . $new_uri);
       if ($updated) {
         $values['keypem_uri'] = $new_uri;
       } else {
@@ -376,10 +377,10 @@ class QRCodePaymentMode2 extends OffsitePaymentGatewayBase implements SupportsRe
       $sub_mch_id = $this->getConfiguration()['sub_mch_id'];
     }
     if (!$cert_path) {
-      $cert_path = drupal_realpath(self::KEY_URI_PREFIX . $this->getConfiguration()['certpem_uri']);
+      $cert_path = \Drupal::service('file_system')->realpath(self::KEY_URI_PREFIX . $this->getConfiguration()['certpem_uri']);
     }
     if (!$key_path) {
-      $key_path = drupal_realpath(self::KEY_URI_PREFIX . $this->getConfiguration()['keypem_uri']);
+      $key_path = \Drupal::service('file_system')->realpath(self::KEY_URI_PREFIX . $this->getConfiguration()['keypem_uri']);
     }
     if (!$mode) {
       $mode = $this->getMode();
diff --git a/src/PluginForm/MicropayForm.php b/src/PluginForm/MicropayForm.php
index 2d4d5b6..342c825 100644
--- a/src/PluginForm/MicropayForm.php
+++ b/src/PluginForm/MicropayForm.php
@@ -96,7 +96,7 @@ class MicropayForm extends PaymentOffsiteForm {
         $payment_id = $payment_ids[0];
       }
       if (count($payment_ids) > 1) {
-        drupal_set_message('Some thiings were wrong, this order has more than one payment, please check it.');
+        \Drupal::messenger()->addStatus('Some thiings were wrong, this order has more than one payment, please check it.');
         return;
       }
       if ($payment_id) {
@@ -105,7 +105,7 @@ class MicropayForm extends PaymentOffsiteForm {
         $payment_gateway_plugin->cancel($payment_id, $order_id);
         return;
       } else {
-        drupal_set_message('This order has not been paid.');
+        \Drupal::messenger()->addStatus('This order has not been paid.');
         return;
       }
     }
