Post by Philm » Mon Oct 12, 2009 5:35 pm

Hi everyone!

Firstly, thank you so much for creating OpenCart. I've been looking for a replacement to oscommerce for several years and have finally found the answer! Keep up the very, very good work.

I'm looking to use OpenCart on a client's website for the first time. They've told me they use NetBanx as a payment processor who I haven't heard of before. I was just wondering if anyone has used NetBanx in conjunction with OpenCart before or if there will be a module in the future? Link: http://www1.netbanx.com

Thanks again for the time you've taken to create OpenCart :)
Phil

Newbie

Posts

Joined
Mon Oct 12, 2009 5:30 pm

Post by ThePath » Thu Nov 26, 2009 9:23 pm

I wouldnt mind seeing this one added, Ive heard some good things about them and I might sign up with them in future.

Image

OpenCart Theme Options - See All My Extensions - OpenCart Themes and Mods


User avatar
Active Member

Posts

Joined
Fri Jun 26, 2009 11:53 pm
Location - Scotland

Post by Qphoria » Thu Nov 26, 2009 11:27 pm

I could of sworn I made this module for someone a while ago. But I can't find it. I recognize their website, but maybe the deal never went through.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by simonrichards » Fri Apr 22, 2016 5:39 pm

I tried for Opencart V2 but gave up and went with PayPal, you're welcome to the attempted code.

Code: Select all

<?php

require_once 'netbanx.php';

class ControllerPaymentPerpetualPayments extends Controller {

    public function index() {
		$this->load->language('payment/perpetual_payments');
        $data['text_wait'] = $this->language->get('text_wait');
        $this->load->model('checkout/order');
        $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
        $nbx_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
        $nbx_uri = 'https://api.netbanx.com';
        $nbx_payment_amount = (int) ($order_info['total'] * 100);
        $nbx_currency_code = 'GBP';
        $nbx_merchant_reference = $order_info['order_id'];
        $nbx = new NetbanxAPI(array(
            "key" => $nbx_key,
            "uri" => $nbx_uri
                )
        );

        $order = $nbx->create_order(
                array(
                    'total_amount' => $nbx_payment_amount,
                    'currency_code' => $nbx_currency_code,
                    'customerNotificationEmail' => $order_info['email'],
                    'merchant_notification_email' => $this->config->get('config_email'),
                    'merchant_ref_num' => $nbx_merchant_reference,
                    'link' =>
                    array(
                        array(
                            'rel' => 'return_url',
                            'uri' => "https://www.website.com/index.php?route=checkout/checkout"
                        ),
                        array(
                            'rel' => 'cancel_url',
                            'uri' => "https://www.website.com/index.php?route=checkout/checkout"
                        )
                    ),
                    'callback' => // cgi callback      		
                    array(
                        array(
                            'format' => 'form-urlencoded',
                            'rel' => 'on_success',
                            'synchronous' => true,
                            'retries' => 1,
                            'returnKeys' =>
                            array(
                                'id',
                                'transaction.merchantRefNum',
                                'transaction.errorMessage',
                                'transaction.amount',
                                'transaction.status'
                            ),
                            'uri' => "https://www.website.com/index.php?route=payment/perpetual_payments/callback"
                        ),
                        array(
                            'format' => 'form-urlencoded',
                            'rel' => 'on_hold',
                            'synchronous' => true,
                            'retries' => 1,
                            'returnKeys' =>
                            array(
                                'transaction.merchantRefNum',
                                'id',
                                'transaction.errorMessage',
                                'transaction.amount',
                                'transaction.status',
                            ),
                            'uri' => "https://www.website.com/index.php?route=payment/perpetual_payments/callback"
                        ),
                        array(
                            'format' => 'form-urlencoded',
                            'rel' => 'on_decline',
                            'synchronous' => true,
                            'retries' => 1,
                            'returnKeys' =>
                            array(
                                'transaction.merchantRefNum',
                                'id',
                                'transaction.errorMessage',
                                'transaction.amount',
                                'transaction.status',
                            ),
                            'uri' => "https://www.website.com/index.php?route=payment/perpetual_payments/callback"
                        )
                    ),
                )
        );

        $data['button_continue_action'] = $order->link[0]->uri;
        return $this->load->view('payment/perpetual_payments', $data);
        $this->model_checkout_order->updatenetbanx($nbx_merchant_reference, $order->id);
    }

    public function callback() {
		$this->load->language('payment/perpetual_payments');
        $this->load->model('checkout/order');
        // Check Post for Shop Order Number | Assign Order number to variable
        // Load OpenCart Order | Compare Netbanx Hash      
        if (isset($_POST['transaction_merchantRefNum'])) {
            $netbanxreply = $_POST['transaction_merchantRefNum'];
            $order_info = $this->model_checkout_order->getOrder($netbanxreply);

            if ($order_info['invoice_prefix'] === $_POST['id']) {
                // Log Transaction Details into the Order Notes Field
                $message = "NETBANX RESPONSE VALIDATED" . " | ";

                if (isset($_POST['transaction_merchantRefNum'])) {
                    $message .= 'ORDER NUMBER : ' . $_POST['transaction_merchantRefNum'] . " | ";
                }

                if (isset($_POST['transaction_amount'])) {
                    $message .= 'AMOUNT : ' . $_POST['transaction_amount'] . " | ";
                }

                if (isset($_POST['id'])) {
                    $message .= 'HASH : ' . $_POST['id'] . " | ";
                }
                // Successful order - Confirm and complete
                if (($_POST['transaction_status']) == "success") {
                    $this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('perpetual_payments_order_status_id'), $message, false);
                    $this->response->setOutput($this->load->view('checkout/success', $data));
                    unset($_POST);
                } else {
                    // Failed Order - Set to pending for further attempts
                    $message .= ("THIS TRANSACTION FAILED WITH NETBANX - " . $order_info['invoice_prefix'] ."\n");
                    if (isset($_POST['transaction.errorMessage'])) {
                    $message .= 'Netbanx Transaction Errors: ' . $_POST['transaction.errorMessage'] . "\n";
	                $this->redirect('checkout/checkout');
                    }
                }
				$this->model_checkout_order->addOrderHistory($this->session->data['order_id'], $this->config->get('perpetual_payments_order_status_id'), $message, false);
            }
        }
        unset($_POST);
    }

}

?>


Newbie

Posts

Joined
Tue Apr 01, 2014 11:05 pm

Post by Qphoria » Wed Apr 27, 2016 4:04 am

I actually made the netbanx module since 2009 but it wasn't popular.
Now it is called "Paysafe" so it all needs to be redone.. but there doesn't seem to be any interest.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am
Who is online

Users browsing this forum: No registered users and 5 guests