Magento pass extra info to payment gateway - magento

I am trying to follow http://excellencemagentoblog.com/magento-create-custom-payment-method-api-based to build a payment gateway.
Everything is ok. But I need to pass a digital signature to payment gateway.
I think I should add it in the class Excellence_Pay_Model_Pay assignData($data)
info = $this->getInfoInstance();
$info->setCcType($data->getCcType())
->setCcOwner($data->getCcOwner())
->setCcLast4(substr($data->getCcNumber(), -4))
->setCcNumber($data->getCcNumber())
->setCcCid($data->getCcCid())
->setCcExpMonth($data->getCcExpMonth())
->setCcExpYear($data->getCcExpYear())
->setCcSsIssue($data->getCcSsIssue())
->setCcSsStartMonth($data->getCcSsStartMonth())
->setCcSsStartYear($data->getCcSsStartYear())
->setCcsignature($data->getCcsignature());
I have added one more field : ->setCcsignature($data->getCcsignature());
But I am not able to retrieve it on capture() or callApi() function. It is empty all the time. I thought ->setSsignature will use php magic set function, isn't it?
Any hint and advise will be appreciated.
Thanks guys!

Looks like you have to check if the value is being set or not by using $info->getCcsignature(). After the value has been set, if it is being passed on to capture() or callApi() function. You just need to follow the basic steps of debugging. echo-die, echo-die and so on. Good Luck.

Related

Putting groovy gorm code in config file error?

I am using this, Saving-User-last-login-Time-in-Grails, simple tutorial to add lastLoginTime to User. So, everytime a user logs in, the last signed in date/time is saved to database. I followed the steps, provided in the tutorial, exactly. But end-up getting this error.
No signature of method: groovy.util.ConfigObject.withTransaction() is
applicable for argument types: (Config$_run_closure3_closure11)
values: [Config$_run_closure3_closure11#12fab25]
Looks like the Gorm code, in Config.groovy file, is not respected. Does anyone know, where else should I move the code to solve this problem?
Any help is much appreciated. Thanks.
Try application.groovy, instead. For details, refer registeringCallbackClosures.
For more insight, and other approaches to achieve similar behaviour, see Events.

Extending ion auth to only allow registrations from certain email addresses/domains

I want to extend Ion Auth to only allow certain email addresses to register.
I'm fairly sure I could hack this together and get something working, but as a newbie to codeigniter and ion auth I wish to find out if there is a "proper way" to be doing what I need?
For instance can I "extend" ion auth (so I can update ion auth core files without writing over my changes?).
I noticed there are also hooks including this one (in the register function):
$this->ci->ion_auth_model->trigger_events('pre_account_creation');
Where do these resolve and can I use this one in order to intercept registrations from email addresses which don't match a list of those I wish to register?
If so, how would I do it? I would need access to the $email variable from the register() function.
Or is it just a case of altering the base code from ion auth and not updating it in the future?
Thanks for any help you can give me. Don't worry about the email bit, I'm capable of working out whether an email address matches the required email domains, I'm more interested in what is the best way to go about extending the library.
Tom
EDIT: Hi Ben, thanks for your answer, and thanks for taking the time to have a look at my issue. Unfortunately this hasn't helped.
I guess what you're trying to do there is add a little bit to the sql query a "where in" clause? I guess that the where in bit is incorrect as there isn't a column name.
Also, at this point I can't modify the sql query satisfactorily to produce the required output. e.g. I can add a hook to a function which is literally $this->db->where('1=1') and this outputs this sql in the next query:
SELECT COUNT(*) AS `numrows` FROM (`users`) WHERE `1=1` AND `email` = 'rawr#rawr.com'
The AND email = 'rawr#rawr.com' bit will always still return no rows. It should be OR email = 'rawr#rawr.com', but without editing the Ion Auth core code then I won't be able to change this.
I am starting to suspect (from the last couple of hours of tinkering) that I may have to edit the ion auth core in order to achieve this.
Check out this example: https://gist.github.com/2881995
In the end I just wrote a little form_verification callback function which I put in the auth controller of ion_auth which checked through a list of allowed domains. :)
When you validate your form in the auth controller you add a callback:
$this->form_validation->set_rules('email', 'Email Address', required|callback_validate_email');
You create a method in the controller called validate_email:
function validate_email() {
if (strpos($this->input->post('email'), '#mycompany.com') === false) {
$this->form_validation->set_message('validate_email', 'Not official company email address.');
return false;
} else return true;
}
This will cause the creation of the user to fail, since all rules must pass. You also provide an error message. Just make sure to have this line on the form view side:
echo validation_errors();

Debugging Grocery_CRUD Callbacks

I have seen many people referring to the usage of call_user_func() to debug the problems in a Grocery_CRUD callback, but unfortunately no one has come off with a complete example to actually how to use it like where to to place a call to the test function [just_a_test()] in the controller an example of what I am trying to discover is here.
I am unable to understand where do we call this
just_a_test(),
how are we able to pass on the desired parameters using call_user_func(array($this,'insert_coupon_codes')); when there are no para's being passed to the just_a_test()?
how come the insert_coupon_codes will be able to get the desired para's?
Grocery CRUD add the parameters automatically from the library. You are not able (till now at version 1.1.8) to add more parameters at your callback.
Update: At the latest version of Grocery CRUD now you CAN pass as many parameters as you need. This is a functionality that PHP is offering from version PHP 5.4 or later. More specifically with the use keyword. More specifically if you have the callback callback_after_insert:
usually you would use it like this:
$crud->callback_after_insert(function ($post_array,$primary_key) {
// Your code here
});
From PHP 5.4 version and later you can add more parameters with the use so for example you could have:
$my_variable = 'test';
$another_variable = 'hello';
$crud->callback_after_insert(function ($post_array,$primary_key) use ($my_variable, $another_variable) {
// Now you can use the variables $my_variable and $another_variable at your callback
});

Magento - update order status via API

I have added a custom order status option.
Does anyone know how I can set it to my custom value via the API?
Thanks to Diglin for pointing me in the right place. Just to present the answer properly:
You can do this by using the addComment method, which also lets you specify the new order status as one of it's parameters.
$sku='100000003';
$orderStatus = 'Downloaded';
$comment = 'The order was successfully downloaded';
$sendEmailToCustomer = false;
$proxy->call($sessionId, 'sales_order.addComment', array($sku, $orderStatus, $comment, $sendEmailToCustomer));
Hope this helps someone.
After to have seen the api doc and the source code, you can get only information about an order and add a comment to it. You cannot edit or delete an order. You have to create your own API if you need that.
See this link to see what is possible with the API: Magento Core API - Mage Sales

How to get payment method in an observer in Magento?

I have an observer that handles the event: sales_payment_invoice_pay (or something like that).
What I'm trying to do is to send an invoice if the payment method is PayPal.
Everything is ok in version 1.4~ by doing $observer->getEvent()->getOrder()->getPayment->getMethodInstance().
In version 1.5+ however I can't seem to find any solutions.
I also tried with getData() but without any results.
Any help is appreciated. thanks
Calling me super desperate for an answer would be an understatement.
It looks like the only data passed in to the sales_order_invoice_pay event is $this, which will be the sales/order_invoice model. I found this by searching through the Magneto core code, it's fired off in Invoice.php like so:
Mage::dispatchEvent('sales_order_invoice_pay', array($this->_eventObject=>$this));
Looking at a similar event (sales_order_invoice_register) which has an observer in the core (of Enterprise, at least - increaseOrderGiftCardInvoicedAmount() in GiftCardAccount) you can access the Invoice object like this in your Observer method:
$invoice = $observer->getEvent()->getInvoice();
The invoice is all you will be able to get though, since it's the only thing passed to the Observers by dispatchEvent(). You cannot directly access the order, like you are trying to do.
Looking at the Invoice model, however, it appears to have a nice getOrder method, which should do the trick. I haven't tested it, but try this:
$observer->getEvent()->getInvoice()->getOrder()->getPayment->getMethodInstance();
Cheers and good luck!
i can get the payment method code using this
$observer->getEvent()->getInvoice()->getOrder()->getPayment()->getMethodInstance()->getCode()
user this code:$order->getPayment()->getMethodInstance()->getCode() ;

Resources