Post by radact » Sat Feb 01, 2020 12:57 pm

Hi,
I've made a custom payment method for a bitcoin payment by renaming the Bank_Transfer option.
At the moment it displays the link correctly, but it's not a clickable URL. Also is it possible to convert this to a QR code to display as well?

Code: Select all

<?php

class ControllerExtensionPaymentSatoshi extends Controller {
	public function index() {
		$this->load->language('extension/payment/satoshi');

		$data['text_instruction'] = $this->language->get('text_instruction');
		$data['text_description'] = $this->language->get('text_description');

// Old Payment Info
//		$data['text_payment'] = $this->language->get('text_payment');
// Satoshi Payment Info
		$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
		$total = $this->currency->format($order_info['total'], $this->config->get('config_currency'));
		$total = filter_var($total, FILTER_SANITIZE_NUMBER_FLOAT,FILTER_FLAG_ALLOW_FRACTION);

		$data['text_payment'] = nl2br($this->config->get('satoshi_satoshi' . $this->config->get('config_language_id'))) . '?amount=' .  $total . '&reference=' . $this->session->data['order_id'] . '-' . $this->customer->getFirstName() . $this->customer->getLastName();

		$data['text_loading'] = $this->language->get('text_loading');

		$data['button_confirm'] = $this->language->get('button_confirm');

// Old Link Data
//		$data['satoshi'] = nl2br($this->config->get('satoshi_satoshi' . $this->config->get('config_language_id')));

// Satoshi Data Adjustment
		$data['satoshi'] = ' ';

		$data['continue'] = $this->url->link('checkout/success');

		return $this->load->view('extension/payment/satoshi', $data);
	}

	public function confirm() {
		if ($this->session->data['payment_method']['code'] == 'satoshi') {
			$this->load->language('extension/payment/satoshi');

			$this->load->model('checkout/order');

			$comment  = $this->language->get('text_instruction') . "\n\n";

//			$comment .= $this->language->get('text_payment');
			$comment .= $this->config->get('satoshi_satoshi' . $this->config->get('config_language_id')) . '?amount=' . $this->cart->getTotal() . '&reference=' . $this->customer->getFirstName() . $this->customer->getLastName() . "\n\n";
			
			$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('satoshi_order_status_id'), $comment, true);
		}
	}
}

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am

Post by straightlight » Fri Feb 14, 2020 9:27 am

By converting the bank_transfer into your custom payment method, you'd need to use JSON encoding headers to return the results which is being called with AJAX from jQuery in your custom payment method's TPL file.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.


Regards,
Straightlight
Opencart.com Administrator / Quality Assurance Analyst / Programmer


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by radact » Fri Feb 14, 2020 11:32 am

That's abit past my ability, but it's working now, so I ain't fiddling with it anymore!

New member

Posts

Joined
Fri Nov 25, 2016 11:36 am
Who is online

Users browsing this forum: No registered users and 5 guests