How to edit Paypal API error messages? - magento

In Magento when there's Paypal transaction error, it outputs a message like this:
This transaction cannot be processed (#15005: Processor Decline)
Since the message doesn't originate in Magento, it cannot be updated via translate.csv.
What are options available for developer to make these messages more user friendly?

This will not be easy but I think it's doable.
My guess would be to rewrite method
_processPaypalApiError($exception) in Mage_Paypal_Controller_Express_Abstract.
Since it's in an abstract class, you will have to rewrite one of the method (Express for example).
Also look at _setApiProcessableErrors

Related

Is this issue due to bots?

In our MVC website log I can see lot of errors with message "A public action method was not found". Requests are coming with junk action method name.
For example if I have action name "GetProducts" then requests are coming with actiona name as "GetProducts AND 1=1" , "GetProducts;id'" , "GetProductswhscheck".
is this because of internet bots are trying to access my website with junk values?
It may be bots, it may be script kiddies, or it may be crackers. Either way - somebody is trying to find vulnerabilities on your site.
Let's look at the first one:
GetProducts AND 1=1"
This looks like an attempt at SQL Injection. There was probably a longer query after the "1=1", trying to get information out of your database - like usernames, e-mail addresses, and so on.
To defend yourself, make sure your queries are parameterized. You may also want to add some form of rate-limiting on your system; if possible, see if you can add captchas.
You may also want to look at this answer on Information Security Stack Exchange, and the OWASP top 10 security vulnerabilities.
Do this as soon as possible, because somebody's trying to break in to your system.

Restrict or Obscure data sent to Application Insights

we have just added Application Insights to our WebAPI 2.2 application and it looks like a winner.
However, we have some controllers that receive sensitive information that we cannot store due to compliance regulations, even in Application Insights. We want to capture information level trace events on some of our controllers, but we need to not capture or obscure the information when sent through other controllers. Can anyone suggest a way that we can achieve that?
Since you're using the Microsoft.ApplicationInsights.TraceListener package, I don't think there's any way to directly filter the data. If you can add something special to the Trace.WriteXxx() call, then one option might be to implement a TraceFilter and register it through your configuration for the ApplicationInsights Trace Writer.
Then in your TraceFilter.ShouldTrace(), you could check for that special value (maybe it's the event ID, maybe some prefix in the trace message, or something like that) and simply return false to cause it to be skipped.
I asked the same question on the Azure MS website and got a reply that works well.
Anyone looking here for an answer should look there.
https://azure.microsoft.com/en-us/documentation/articles/app-insights-get-started/#comment-2309233065

How to organize my code?

I'm still in a learning phase with PHP and Laravel 5 and since I upgraded to L5, I struggle with where my code belongs to. There are so many files and folders which seem to have the same purpose or at least are very similar. There are Commands, Controllers, Events, Services, Requests, etc. I give an example with my workflow and where I would place the code and I hope you guys can comment on that and correct/help me.
Situation
I want to register a new user in my application and send a welcome e-mail when he registered successfully.
Workflow
Controller (UserController): Returns requested view (register).
Request (RegisterRequest): The "RegisterRequest" validates the entered data.
Controller (UserController): Passes the validated data to the "UserRegistrar" (service) in 'App/Services'.
Service (UserRegistrar): Creates a new user and saves it to the database.
Controller (UserController): Fires the "UserWasRegistered" Event.
Event (UserWasRegistered): This Event call the "SendWelcomeEmail" Command.
Command (SendWelcomeEmail): This Command will send/queue the welcome e-mail.
Controller (UserController): Redirects the user to a view with the information that he has been registerd successfully and a message has been send to him.
Logic
Okay, let's discuss some logic:
Controller:
Doesn't hold much code.
Mainly there to return views (with requested data).
Handles workflow and "connects" modules (Services, Requests, Events).
Request: Validates the data for a specified request
Service: A service "does" something. For example it's doing requests to the database.
Event: An Event is a central place to call one or more tasks if it is fired (SendConfirmationMail, SendWelcomeMail).
Command: Mainly there to handle the logic for ONE certain task. For example sending a confirmation mail. Another command will hold the logic for sending the welcome mail. Both commands are called in the Event described before.
Repositories: What is that?!
So this is what I understand. Please help me and feed me with information.
Thanks,
LuMa
Your question is a little vague and will likely attract downvotes as being "too broad". That said, here's my take on this...
The biggest issue I see is that your application structure is very different from the recommended L5 structure - or even the standard MVC structure - that it's no wonder you're getting confused.
Let's talk about your "Logic" section:
controller - you're on the right track here. The controller is the glue between your models and your views. It can do some processing, but most should be offloaded to classes that handle specific tasks.
request - what is this? L5 includes a Request class that includes methods for examining the HTTP request received from the client. Are you talking about subclassing that? Why? If your idea of a "request" class is primarily concerned with examining input, you can either do that in your model (ie. validating stuff before sticking it in the database) or in your controller (see the L5 docs on controller validation)
service - again, what is this? You talk about "doing requests to the database", but L5 provides a class for that (DB). At a higher level, database access should primarily be done through models, which abstract away most of the low level database access. As for other services, what I usually do is create libraries to perform specific processing. For example, my application has a particular third party project management application that it accesses via an API. I have a library for that, with methods such as getProject or createProject.
event - An event is a way of ensuring that some code is called when the event happens, without a whole lot of messing about. It sounds like you have the right idea about events.
command - again, it sounds like you have the basic idea about commands.
repositories - these are way of abstracting the connection between a resource (primarily the database, but it can apply to other resources too) and the code that uses the resource. This gives a way to switch the underlying resource more easily if you (for example) decide to change database servers in the future. They are optional.
You also haven't mentioned anything about models. L5 provides an excellent way to deal with your data in understandable chunks via Eloquent models - this will make your life much easier.
My suggestion is this: start small. Build a simple MVC application with L5 - A model (to save some data), a view (to display the data), and a controller (to put the model & view together by handling the client request). Once you have that, start extending it.
There are tutorials out there that will give you this basic structure for Laravel - most are for Laravel 4, but see if you can follow the basic ideas and build something similar for Laravel 5.

magento payment gateway custom method return

I am doing a magento gateway for paysolution for 1.4 and 1.5 and i am stack in the return from the bank. It is my firs module an I confusing about the way MVC works.
The admin configuration part works perfect
the redirect to the bank works fine and the bank show the data from the order
I have the php code to analyze the return but i don't understand where to put it.
The problem is i don't know wich url i have to configure in the paysolution account and how I create the page in the module to get the return from the bank.
I you can point me the right direction I will really apriciate.
Regards,
Eduardo
you have to write a custom controller within your module in order to give the Payment Gateway a redirection URL to call.
Some gateways also requires server to server communication so they will require another URL the will call asynchronously in order to communicate transaction result.
In order to understand what is a controller I suggest you to carefully read the following tutorials:
http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-1-introduction-to-magento#3
http://blog.baobaz.com/en/blog/magento-module-create-your-own-controller
According to the fact that the transaction is successful or not, you will end your controller method with one of the following redirections:
$this->_redirect('checkout/onepage/success');
or
$this->_redirect('checkout/onepage/failure');
I suggest you to take a look at the Paypal StandardController.php under [mageinstalldir]/app/code/core/Mage/Paypal/controllers and the OnepageController.php under [mageinstalldir]/app/code/core/Mage/Checkout/controllers
Best wishes,
Alessandro
Give this a try:
http://colourgray.wordpress.com/2009/11/11/magento-create-a-custom-payment-method/

Magento - Send emails for different order status

I am currently building an online store using magento.
After placing an order, customers automatically receive an "order confirmation". However, I would like to check first first if this order can be processed (for several reasons) and after that, send an "order acceptance" email saying that we accepted the order starting to process it.
I cant believe that magento lacks this feature.
However I also need to send several other emails:
when payment is received
when more preoducts need to be ordered
when we received the products otderd by the customer..
Does anybody have any clue, how something like this can be accomplished?
Thanks in advance!
do you know any other e-commerce platform on php that has this feature ?
You most certainly can
overwrite the saveOrder() method in Mage_Checkout_Model_Type_Onepage that calls out the sending of this e-mail
overwrite sendNewOrderEmail() method in Mage_Sales_Model_Order that defines this method
overwrite the canSendNewOrderEmail() method in Mage_Sales_Helper_Data that handles the validation if sending this mail is allowed
edit the sales_email/order/enabled config value, that is used to control the condition on helper method, to be false from admin page
After that you have to implement your own status based e-mail sending in your extension observer . You can observe the save_order_after event to do that and you can call for the same method as it is accessible from order object
Note : This is commercial software
We have used this extension by amasty called order status. It works very well. It will fire off an email from the transactional emails when a certain status has been changed.

Resources