Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/13753
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Apr 22, 2024
1 parent bbff3ce commit 672b700
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
12 changes: 8 additions & 4 deletions upload/catalog/controller/account/payment_method.php
Expand Up @@ -94,8 +94,10 @@ protected function getList(): string {
if ($this->config->get('payment_' . $result['code'] . '_status')) {
$this->load->model('extension/' . $result['extension'] . '/payment/' . $result['code']);

if (is_callable([$this->{'model_extension_' . $result['extension'] . '_payment_' . $result['code']}, 'getStored'])) {
$payment_method_info = $this->{'model_extension_' . $result['extension'] . '_payment_' . $result['code']}->getStored();
$key = 'model_extension_' . $result['extension'] . '_payment_' . $result['code'];

if (isset($this->{$key}->getStored)) {
$payment_method_info = $this->{$key}->getStored();

if ($payment_method_info) {
$data['payment_methods'][] = [
Expand Down Expand Up @@ -148,8 +150,10 @@ public function delete(): void {
if (!$json) {
$this->load->model('extension/' . $payment_method_info['extension'] . '/payment/' . $payment_method_info['code']);

if (is_callable([$this->{'model_extension_' . $payment_method_info['extension'] . '_payment_' . $payment_method_info['code']}, 'delete'])) {
$this->{'model_extension_' . $payment_method_info['extension'] . '_payment_' . $payment_method_info['code']}->delete();
$key = 'model_extension_' . $payment_method_info['extension'] . '_payment_' . $payment_method_info['code'];

if (isset($this->{$key}->delete)) {
$this->{$key}->delete();
}

$json['success'] = $this->language->get('text_success');
Expand Down
6 changes: 0 additions & 6 deletions upload/catalog/controller/checkout/cart.php
Expand Up @@ -122,12 +122,6 @@ public function list(): void {
* @return string
*/
public function getList(): string {






$data['product_edit'] = $this->url->link('checkout/cart.edit', 'language=' . $this->config->get('config_language'));
$data['product_remove'] = $this->url->link('checkout/cart.remove', 'language=' . $this->config->get('config_language'));
$data['voucher_remove'] = $this->url->link('checkout/voucher.remove', 'language=' . $this->config->get('config_language'));
Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/controller/cron/subscription.php
Expand Up @@ -358,11 +358,11 @@ public function index(int $cron_id, string $code, string $cycle, string $date_ad
// Load payment method used by the subscription
$this->load->model('extension/' . $extension_info['extension'] . '/payment/' . $extension_info['code']);

$callable = [$this->{'model_extension_' . $extension_info['extension'] . '_payment_' . $extension_info['code']}, 'charge'];
$key = 'model_extension_' . $extension_info['extension'] . '_payment_' . $extension_info['code'];

if (is_callable($callable)) {
if (isset($this->{$key}->charge)) {
// Process payment
$response_info = $this->{'model_extension_' . $order_data['payment_method']['extension'] . '_payment_' . $order_data['payment_method']['code']}->charge($this->customer->getId(), $this->session->data['order_id'], $order_info['total'], $order_data['payment_method']['code']);
$response_info = $this->{$key}->charge($this->customer->getId(), $this->session->data['order_id'], $order_info['total'], $order_data['payment_method']['code']);

if (isset($response_info['order_status_id'])) {
$order_status_id = $response_info['order_status_id'];
Expand Down
6 changes: 4 additions & 2 deletions upload/catalog/model/checkout/payment_method.php
Expand Up @@ -24,8 +24,10 @@ public function getMethods(array $payment_address = []): array {
if ($this->config->get('payment_' . $result['code'] . '_status')) {
$this->load->model('extension/' . $result['extension'] . '/payment/' . $result['code']);

if (is_callable([$this->{'model_extension_' . $result['extension'] . '_payment_' . $result['code']}, 'getMethods'])) {
$payment_methods = $this->{'model_extension_' . $result['extension'] . '_payment_' . $result['code']}->getMethods($payment_address);
$key = 'model_extension_' . $result['extension'] . '_payment_' . $result['code'];

if ($this->{$key}->getMethods) {
$payment_methods = $this->{$key}->getMethods($payment_address);

if ($payment_methods) {
$method_data[$result['code']] = $payment_methods;
Expand Down
6 changes: 4 additions & 2 deletions upload/catalog/model/checkout/shipping_method.php
Expand Up @@ -24,8 +24,10 @@ public function getMethods(array $shipping_address): array {
if ($this->config->get('shipping_' . $result['code'] . '_status')) {
$this->load->model('extension/' . $result['extension'] . '/shipping/' . $result['code']);

if (is_callable([$this->{'model_extension_' . $result['extension'] . '_shipping_' . $result['code']}, 'getQuote'])) {
$quote = $this->{'model_extension_' . $result['extension'] . '_shipping_' . $result['code']}->getQuote($shipping_address);
$key = 'model_extension_' . $result['extension'] . '_shipping_' . $result['code'];

if (isset($this->{$key}->getQuote)) {
$quote = $this->{$key}->getQuote($shipping_address);

if ($quote) {
$method_data[$result['code']] = $quote;
Expand Down

0 comments on commit 672b700

Please sign in to comment.