News:

Support the VirtueMart project and become a member

Main Menu

Create a fake payment Method plugin

Started by smalldragoon, September 18, 2020, 09:00:20 AM

Previous topic - Next topic

smalldragoon

Hi,
I'm using VirtueMart for demos and I would need today a fake payment method ( fake as there will be no real payment nor money sent and received )
Note that I can not use paypal in sandbox mode ( this is what I was doing till now ...)
Here would be the flow :

Customer select payment Method and click chekckout

New window/ pop-up is displayed with HTML/php/JS ..etc..  inside
user "is paying "
go back to virtuemart with  payment OK / KO
Virtuemart order is updated
anyone would have some insights doing this, keeping in mind that I'm not a great coder.

I checked the "standard" payemnt method but seems that there is no "payment feedback" done no ?
Thanks in advance

pinochico

QuoteNew window/ pop-up is displayed with HTML/php/JS ..etc..  inside
user "is paying "

Custom developing for every payments method
www.minijoomla.org  - new portal for Joomla!, Virtuemart and other extensions
XML Easy Feeder - feeds for FB, GMC,.. from products, categories, orders, users, articles, acymailing subscribers and database table
Virtuemart Email Manager - customs email templates
Import products for Virtuemart - from CSV and XML
Rich Snippets - Google Structured Data
VirtueMart Products Extended - Slider with products, show Others bought, Products by CF ID and others filtering products

smalldragoon

hi,

in can be in the same window...
In fact I'm looking for some samples or insghts of the plugin itself.
having a pop up is just a detail ...

jenkinhill

Easier just to use the standard payment plugin, as used in VM demo for Cash on delivery
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

smalldragoon

Hi jenkinhill,
thanks for your attention
That was my first understanding yes.
But how can I do that ?

I can "duplicate" the standard plugin with a different name and update everything accordingly ( name, variables ...etc.). This should be fine
Now, how /where can I trigger my code ( for example for me to start, jsut a javascript like "console.log("blablabla" )  ?
Thx

AH

You are likely to need to develop functionality in the trigger function:

function plgVmConfirmedOrder ($cart, $order) {
Regards
A

Joomla 4.4.5
php 8.1

smalldragoon

Hi AH,
sorry for my dummy quesiton I guess, but to be sure

I "just" to add code in this function and that's it ?
it will take care about the feedback and update the cart / payement in virtuemart ? ( means I shoudl have to do somehting no ? like a return type or content ? )

like

function plgVmConfirmedOrder ($cart, $order) {

echo " hello world" ;

}

AH

It might need to be a little more complex than that

e.g.  You could clear data, set cart session "stuff, set vars - whatever..

$html .= $this->renderByLayout($layout, SOME STUFF IF REQUIRED));
$cart->_confirmDone = FALSE;
$cart->_dataValidated = FALSE;
$cart->setCartIntoSession ();
vRequest::setVar ('html', $html);


Regards
A

Joomla 4.4.5
php 8.1

smalldragoon

I was doing some tests in the meantime

I tried to have a look at the documentation but far to be clear for me ...
thanks for the info

in your SOME STUFF IS REQUIRED, from what I see in the code , I must put :

array(
                        'order_number' =>$order['details']['BT']->order_number,
                        'order_pass' =>$order['details']['BT']->order_pass,
                        'payment_name' => $dbValues['payment_name'],
                        'displayTotalInPaymentCurrency' => $totalInPaymentCurrency['display'])


right ?
Now I assume this is that line qhich updates the order status

$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);

Should I change it to something else to get the payment status to "paid" ?

Osrry again for all these basic and dummies questions, I guess it
sounds obvious but my plan is not to become an expert coder on Virtuemart but to have somehting
basic working

thanks !




AH

right?

It depends on what you want to achieve

Should I change it to something else to get the payment status to "paid" ?

No - this should be handled by the plugin configuration for a confirmed order
Regards
A

Joomla 4.4.5
php 8.1

Jörgen

The basics are working.  8)
What you are trying to Will probably be a Long Journey for you. The plugins are self explanatory. You might want to look Up basics Joomla plugin programming before you go any further. Plenty of examples if you just Google.

Jörgen @ Kreativ Fotografi
Joomla 3.9.18
Virtuemart 3.4.x
Olympiantheme Hera (customized)
This reflects current status when viewing old post.

smalldragoon

Hello,
Using the standard payment plugin, I finally managed to get what I needed ( and using code example from the forum on other dicussions)
remains just 1 point I do not get and make it working : change the order status as confirmed through a javascript function.
I found that code in ajax , this update the status when payment is ok

jQuery(document).ready(function ($) {
        $('#checkout-payment-ok').click(function () {
           
            $.ajax({
                url: '<?php echo $redirect_emtry_cart?>',
                type: 'post',
                data: {'type': $('#type_success').val()},
                dataType: 'html',
                success: function (data, textStatus, jqXHR) {
                    $('#type_success').val('none');
                    $('.message-thankyou').show();
                    $('#checkout-payment-ok').unbind('click');
                    console.log('payment OK');
                }
            })
        })


How can I change this to a basic function like

set_payment_ok ()
{
XXX
}

I tried replacing some stuff , but it is not working.
I have see as well some API calls, which coudl be fine to me as well ( very easy for me to do an API call during the fake payment process )
Thanks for your insights !


GJC Web Design

why not use the native php payment confirm status change?

$modelOrder = VmModel::getModel ('orders');
$order['order_status'] = $this->getNewStatus ($method);
$order['customer_notified'] = 1;
$order['comments'] = '';
$modelOrder->updateStatusForOneOrder ($order['details']['BT']->virtuemart_order_id, $order, TRUE);


or have I misunderstood?
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

smalldragoon

Because my "payment method confirmation " is done trough javascript, that's why I can not use PHP :(