CoinRemitter / opencart

Coinremitter Official plugin for opencart
3 stars 3 forks source link

Unable to see in payment options #1

Open jamjamjakjak opened 1 year ago

jamjamjakjak commented 1 year ago

Hello,

(I suck at github - sorry - solution is detailed throughout my postings)

There must be some slight variation in the new version: Version 4.0.2.2 of opencart. The module installs as expected however there it does not display as a payment method.

I have a valid shipping option and all other details are present and it should display itself.

Everything is configured correctly as per documentation. No errors in logs. OpenCart itself and all of its features are working as intended.

Any information I can provide?

jamjamjakjak commented 1 year ago

Further debugging has lead me to a new install, which functions as intended until I enable the coinremitter extension under 'Extension > Payments' which stops any payment options from displaying. Upon disabling fixes the issue and payment options are displayed.

jamjamjakjak commented 1 year ago

Error in log: 2023-06-08 18:46:16 - Exception: Notice: Undefined property: Proxy::getMethods in /home/kitkit/web/shop.bob.com/public_html/catalog/model/checkout/payment_method.php on line 15 in /home/kitkit/web/shop.bob.com//public_html/system/engine/proxy.php on line 83

Also the same error is produced in the inspect window of firefox as JSON response error, right after clicking payment option on checkout page.

jamjamjakjak commented 1 year ago

Upon comparing the oc_payment_example I noticed that they had renamed: public function getMethod to getMethods

so changing this in https://github.com/CoinRemitter/opencart/blob/master/catalog/model/payment/coinremitter.php I now get COD and an 'undefined' in the payment option selection (this is progress)

`cod: Object { code: "cod", name: "Cash On Delivery", sort_order: "5", … } ​​​ code: "cod" ​​​ name: "Cash On Delivery" ​​​ option: Object { cod: {…} } ​​​ sort_order: "5" ​​​

: Object { … } ​​ coinremitter: Object { code: "coinremitter", title: "Payment with cryptocurrency's", sort_order: 15, … } ​​​ code: "coinremitter" ​​​ sort_order: 15 ​​​ terms: "" ​​​ title: "Payment with cryptocurrency's"` I've also had to update it from 'title' to 'name' inside this file on line 19. Now it says Payment with cryptocurrency's instead of undefined. Still no radio or usable data after this - continuing now. Cheers
jamjamjakjak commented 1 year ago

Right, this is by no means elegant, but for those of you who can build from this, a elegant solution, we love you :)

`<?php namespace Opencart\Catalog\Model\Extension\Coinremitter\Payment; class Coinremitter extends \Opencart\System\Engine\Model { public function getMethods($address, $total=0) { $this->load->language('extension/coinremitter/payment/coinremitter');

            if ($total <= 0.00) {
                    $status = true;
            } else {
                    $status = false;
    }
    $status = true;

            $method_data = array();

            if ($status) {
                    $option_data['coinremitter'] = [
                            'code' => 'coinremitter.coinremitter',
                            'name' => "Pay with crypto options"
                    ];
                    $method_data = array(
                            'code'       => 'coinremitter',
                            'name'      => $this->config->get('payment_coinremitter_title'),
                            'terms'      => '',
                            'option'     => $option_data,
                            'sort_order' => 15
                    );
            }

            return $method_data;
    }

`

I've had to add the 'option' tag to get a radio with a selector called "pay with crypto options"

Choosing this make 'XMR' show up underneath the confirm button with the words: I will pay using: On to testing

jamjamjakjak commented 1 year ago

So where I left off will give you an error upon clicking confirm, saying please select coinremitter as payment option.

Soooo basically few things have changed in the opencart it seems. Here are the next steps i took to get it going.

On line 56 of file: https://github.com/CoinRemitter/opencart/blob/master/catalog/controller/payment/coinremitter.php if ($this->session->data['payment_method'] == 'coinremitter') { to be updated to: if ($this->session->data['payment_method']['code'] == 'coinremitter.coinremitter') {

and the rest seems to work, producing an invoice with what seems all relevant data.

To everyone who this helped- you are welcome.

jamjamjakjak commented 1 year ago

So out of two currencies only the second one is showing. I'm working now to get both displayed (BTC and XMR in my case)

EDIT: I'm not sure why but if the minimum value set in the coinremitter admin section for BTC is set at 0.01 (the minimum) then the BTC value of the product must be 0.01 or higher (which is alot of $$ in some cases) so I've changed it to read, if the fiat amount is greater than the minimum amount in set against the crypto then display it in the list. So to me: the minimum value in the crypto setting is in dollars. (say no btc option unless they spend $100 minimum) if fiat_amount is equal or higher than that crypto can be chosen.

I do not understand its purpose but this is how I have this functioning as intended.

Solution: // if($fiat_to_crypto_response['data']['crypto_amount'] >= $value['minimum_value']){ if($fiat_to_crypto_response['data']['fiat_amount'] >= $value['minimum_value']){

I have not tested a real world payment, next will be using the coinremitter test token/coin.

Good news, its working:

Coinremitter Order - #3 Paid

Base Currency : USD Coin : TCN Created Date : 2023-06-08 20:42:28 (UTC) Expiry Date : 2023-06-08 21:12:28 (UTC) Description : Order Id #3

Transaction Ids: edbf58ba1372e168015610d9d16da4d72d8f8b663d94c01dbe9a22b5f67c2d7a - 2.25000000 TCN Date : 2023-06-08 08:01:05

Order Amount: 2.25000000 TCN

Paid Amount: 2.25000000 TCN

Pending Amount: 0.00000000 TCN

Chow!

jamjamjakjak commented 1 year ago

Pull request added from a cloned fork: https://github.com/jamjamjakjak/opencart/tree/master