文件操作 - PaymentHub.php
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/tutor/ecommerce/PaymentGateways/Paypal/src/PaymentHub.php
编辑文件内容
<?php namespace Ollyo\PaymentHub; use Ollyo\PaymentHub\Core\Factory; use Ollyo\PaymentHub\Core\Application; use Ollyo\PaymentHub\Core\Support\Uri; use Ollyo\PaymentHub\Core\Support\System; use Ollyo\PaymentHub\Core\Payment\BaseConfig; use Ollyo\PaymentHub\Core\Payment\BasePayment; use Ollyo\PaymentHub\Exceptions\InvalidConfigurationException; define('PAYMENT_HUB_ROOT', __DIR__); class PaymentHub { /** * the payment class name * * @var object */ protected $payment; /** * The payment config class associate with the payment * * @var object */ protected $config; public function __construct($payment, $config) { $this->payment = $payment; $this->config = $config; $this->boot(); } /** * Boot the payment client along with the config and setting the container services. * * @return void */ protected function boot() { $container = Factory::getContainer(); $container->set(Application::class, function() { $app = new Application(); $app->makeRepository(Application::class); return $app; }); $container->set($this->payment, function() { /** @var BaseConfig */ $configInstance = System::createClassInstance($this->config); $configInstance->createConfig(); /** @var BasePayment */ $paymentInstance = System::createClassInstance($this->payment); $paymentInstance->setConfigInstance($configInstance); // Set the Repository version of the ConfigContract to the payment instance $paymentInstance->setConfig( $configInstance->toRepository() ); if (!$paymentInstance->check()) { throw new InvalidConfigurationException( esc_html( sprintf('%s payment method is not configured properly! Contact with Site Administrator.', ucfirst($configInstance->getName() ) ) ) ); } $paymentInstance->setup(); return $paymentInstance; }); } /** * Make and return the payment class instance stored into the container * * @return BasePayment */ public function make(): BasePayment { return Factory::getContainer()->get($this->payment); } /** * Make the payment instance with order ID and return the instance. * * @return BasePayment */ public function makeWith($orderId = null): BasePayment { $payment = $this->make(); if (!is_null($orderId)) { $config = $payment->getConfig(); $configInstance = $payment->getConfigInstance(); $successUrl = Uri::getInstance($config->get('success_url')); $successUrl->setVar('order_id', $orderId); $cancelUrl = Uri::getInstance($config->get('cancel_url')); $cancelUrl->setVar('order_id', $orderId); $configInstance->updateConfig([ 'success_url' => $successUrl->toString(), 'cancel_url' => $cancelUrl->toString(), ]); } return $payment; } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件