Need some help with a payment plugin.
They send back a response url with some parameters and I have some problems on how to pick them up.
I guess this line is the start of the code handling this in the "onPaymentNotification" function:
I need advise on where to put in the parameters I get in the returning URL.
They are as follows:
Merchant_id=_HIDDEN_&
Version=3&
Customer_refno=B5A4W8&
Status=A&
Status_code=0&
Currency=SEK&
MAC=_HIDDEN_
Customer_refno is the Hikashop $order->order_number
Status and Status_code are especially important since they show if the payment were successful or not.
This payment plugin will with a few tweaks also work for a few other Swedish payment services like Payson. When I am done with this I will make a Payson variant, I will share both to the Hikashop team.
Thanks
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
$url = parse_url($element->payment_params->url);
will give you the parameters of the URL you configured in the plugin.
If you want the parameters returned by the payment gateway, they are all in the variable $_REQUEST.
Please Log in or Create an account to join the conversation.
So they will be in the array of $url then?
I have debug on but the log is empty, what can I do to get entries in to the log?
Thanks
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
If you look at all the other plugins, they echo variables and text when you turn on the debug mode.
Where is $url coming from ? I'm talking about the variable $_REQUEST which is where you will have to parameters.
Please Log in or Create an account to join the conversation.
The $url I was refering to was from $url = parse_url($element->payment_params->url);
So If I have this line in the PaymentParams the return URL will be parsed?
$element->payment_params->url=$this->return_url;
is the codeline correct?
return_url will be:
$return_url = HIKASHOP_LIVE.'index.php?option=com_hikashop%26ctrl=checkout%26task=after_end%26order_id='.$order->order_id.$url_itemid;
Thanks
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
In the notification function you don't need to deal with the return URL.
All you need to do is to get the parameters your payment gateway is sending you in the $_REQUEST array variable.
I don't understand why you keep trying to parse the return URL in the notification function ?
Please Log in or Create an account to join the conversation.
nicolas wrote: Mmm.
I don't understand why you keep trying to parse the return URL in the notification function ?
I don't understand either :lol:
I am trying to do this on a trial and error basis...
What I need to do is based on the two keys "Status" and "Status_code" (from the payment service) that is returned set the order status to confirmed or cancelled.
In the PayPal plugin I found this in the notification function:
That part will create the $_REQUEST variable, right?
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
This is returned from the var_dump of $_REQUEST
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
So it's really easy to get them:
echo $_REQUEST;
Please Log in or Create an account to join the conversation.
I have been looking thru the PayPal.php, the onPaymentNotification is used in its entirety and I have trouble to find where I should enter the statuses to switch between successful order or cancelled order.
In the VM plugin they have this line:
if (($Status == "A") AND ($Status_code == 0))
Then the order would be successful else cancelled.
Can you have some more patience with me, please...
Thanks
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
nicolas wrote: It's simple really:
Easy for you to say :lol:
Thanks a lot, I'll try it soon.
Hope to get this working, I think it would be great for Hikashop for the Swedish market. It's a unfortunatelly for Hikashop that there are so few payment modules for us here in Sweden.
Only option is VM and that is not an option anymore IMHO
Thanks again
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
Since this is a Swedish site the Order statuses names have been changed to the equivalent Swedish names. Does this affect the coding? Or is it using the Order Status ID?
For example "Cancelled" is changed to "Avbeställd".
Thanks
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
However the import from VM apparently fouls that up.
And if you add some other statuses, should they also be in English and translated in the Language file?
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
But the default statuses are in english in the database and should be left like that.
Please Log in or Create an account to join the conversation.
What is triggering the notification function? Is it the notify_url ?
The payment service I am working on only send back a Cancel_url and a Return_url.
I still have a problem with the payment service, I'm not getting the parameters approved all though everything is as the example they provide. I'm waiting for them to response on that.
Since I'm not getting thru to the payment service I'm expecting a cancellation when I'm making the order it's being processed but with a status of None. I would expect a status of cancelled.
I have added this to the If statement you earlier did provide, i.e when Status is not A.
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
In order to know the URL, you either have to give the URL to the payment gateway via a parameter in the form which is displayed at the end of the checkout, or configure it in the settings of your account in your payment gateway (it depends on how they handle it).
Sometimes, like with authorize.net, they use the return URL to directly notify the shopping cart while redirecting the user back to the shop. So in such case, you should give the notification URL in the return URL variable of the form at the end of the checkout.
Since I don't know how that payment gateway works I can't say if that's the case though, but it should be explained in their documentation.
By default the orders are created with the status "created" (if you selected that order status in the configuration for new orders).
Then, with the code I provided and your addition, it will set the status to cancelled or confirmed when a notification is received.
If you have another status, all I can think of is that you changed the new order status of the configuration and that you are not getting the notification, or that you got the notification and that you have some other code in the notification function which changes the status to none.
Please Log in or Create an account to join the conversation.
The default settings for orderstatus was not the correct one, again something from the VM import. So now I at least get the status Created for the order.
This is the return_url I get from the gateway:
It directs me to the After_end page, and so it does, but page is blank. It catches the Status_code and Status all right.
Would you like to see the notification code I have?
Jan
Jan Suhr
www.colorconsult.se www.jansuhr.se
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.