Magento; Modifying a payment module changing name in "method" field - magento

Modifying a payment module I'm not having any success changing the "payment name" that is placed in table sales_flat_order_payment in field "method".
For example if payment is check, it is populated with checkmo.
I've tried changing
protected $_code = '.........'; in payment.php with no success.
I'm guessing this name may need changing in multiple places?
I have researched this but any answers I can find are assuming I have the skill level to know how to duplicate or modify the extension.
magento ver 1.4.1.1
more info; I'm using a Western Union payment extension as a Bpay payment extension and that field method is used to SMS payment type to me (and it would be more elegant it said what it really was!)

It's better to have a separate payment method for this. You can duplicate some existing method, and use your custom name.

Create a new payment module by duplicate one of your other payment module that closest matches what you are trying to do.
If you are trying to create a payment module for check then take a look at create a new payment method

Related

Laravel Paypal checkout

Json view of my paypal after payment is made
I am desperately trying to access the description which is under the transactions array but can't seem to find a way!
It's totally different if I want to access payment_method for instance all I do is this:
(By the way, I assigned this array to $method)
$method->payer->payment_method , but the same thing doesn't work if I want to access description. All I get is an error.
I'm using laravel 5.5, in case that makes a difference.
I'm doing this because I need to find a way to reference my product in the final page after the paypal payment has been made.
Looks like transactions in an array so if you would like the description of the first one that would look like this.
$method->transactions[0]->description

Magento one-page checkout showing no payment method

Am creating a module to add an additional payment system to Magento after creating the module. It is appearing in the admin panel and I have enabled it, but it is showing no payment method.
So payment methods are shown on the checkout page after they pass the function Mage_Checkout_Block_Onepage_Payment_Methods::_canUseMethod now this function basically checks if the method itself is setup and if it is valid against the current quote via two calls.
The payment methods own function canUseCheckout. Now since you are creating your own method I dont know what you function here looks like but I guess it would not be too complex to debug by yourself.
The payment forms Mage_Payment_Block_Form_Container::_canUseMethod. Now what this function does is check the payment method against the country, currency and quote total.
With the following
return $method->isApplicableToQuote($this->getQuote(), Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
| Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
| Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
);
Now if your payment method does not override anything here then it simply checks the config values of min_order_total, max_order_total, specificcountry and if you have any special currency checks.

Braintree's Dropin UI, How to remove payment method

We are using braintree's dropin UI to help save time in having to create custom payment entry pages. What is hard to understand is why you can only add new payment method and not remove. I understand being able to add, but if there was a problem with a given payment method (later on). It is there forever because the customer cannot remove a payment method. I guess the only way to remove a payment method, is for us write a custom UI (thus defeating the purpose of using the dropin UI to begin with). Is there no way for a customer to remove a payment method using the dropin UI?
Braintree's DropIn UI doesn't allow users to remove or update saved payment method.
But there's a way to do that. For example, if you have a customer profile page where they can manage their settings, you can simply add a menu that shows all the payment methods associated with the customer.
To do this, you can simply use some Braintree functions which are explained here: https://developers.braintreepayments.com/guides/payment-methods/php
The idea is to get all the payment method associated with the customer using something like:
$customer = Braintree_Customer::find('a_customer_id');
$customer->paymentMethods // array of Braintree_PaymentMethod instances
It will return an object for all the payment methods. Then you can check the response of that object from the same page by clicking the specific payment method type here (credit card, paypal...)
Once you have these values, you can display them in a table for example, and add a simply button or whatever you want to delete that payment method.
To do this, you can use the following function passing the TOKEN as an argument
$result = Braintree_PaymentMethod::delete('the_token');
/*(token is a value of the object that comes from $customer->paymentMethods*/
Finally, you can check the response controlling the value of $result (true or false)
Hope this helps.
The ability to delete vaulted payment methods using the Braintree drop-in UI has been added around August 7, 2018 and is available in braintree-web-drop-in 1.12.0+. This feature is now listed in their documentation:
Name: vaultManager
Type: boolean
Attributes: optional
Default: false
Description:
Whether or not to allow a customer to delete saved payment methods when used with a client token with a customer id. Note: Deleting a payment method from Drop-in will permanently delete the payment method, so this option is not recomended for merchants using Braintree's recurring billing system. This feature is not supported in Internet Explorer 9.
To enable the "Vault Manager" (the ability to delete vaulted payment methods), set vaultManager: true when creating the drop-in:
braintree.dropin.create({
authorization: 'CLIENT_AUTHORIZATION',
vaultManager: true,
/* your other braintree options */
})

Using customer first name in order confirmation email

I've seen a bunch of articles (mostly 3-5 years old) detailing various methods of getting the customer's first name into the order confirmation email but I just get either a blank, or unparsed PHP.
For example this:
<?php echo $this->__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Renders in the email like this:
__('Hello, %s', Mage::getSingleton('customer/session')->getCustomer()->getFirstname()); ?>
Could somebody point me in the right direction? This is on Community Edition 1.7.
Thanks
[EDITED] You can't use PHP code in your email-templates directly. If you want to insert dynamic data into your email-templates, you have two possibilities:
a) In every transactional email you can access the methods of the model, which is in charge for the transactional email, it is: for mails dealing with orders, this is the order-Model, for mails dealing with newsletters, this is the newsletter-model and so on. You can access the methods with the syntax:
{{var model.method()}}
So, in your case, to access the customer's first name in an order confirmation email, you need to look for a suiting method in the order Model, which is getCustomerFirstname() .
Then you can call it, following the given syntax:
{{var order.getCustomerFirstname()}}
b) You can include dynamic data into your email-template by creating a custom phtml-template and including it into your email-template via the {{block}} directive (as pointed out by benmarks in the comment below)

Magento variable to display payment method in email subject

I'm trying to display the payment method in the email subject for new order emails in Magento. The reason being is so that our client can easily determine from the subject of emails send from Magento whether the order came via the payment gateway or Paypal Express.
I'm not entirely sure of the best way to achieve this, I would like to think there is already something available I could use for this.
{{var payment_html}}
returns the payment method block for email templates...
{{var paymentMethod}}
returns absolutely nothing in the email subject so unsure whether this is a depreciated variable now.
I suppose there is also the option of creating a custom attribute, calling it in a static block and then displaying this as a custom variable in the email templates but it seems a rather long winded approach just to purely get a text string of "via SagePay" or "via Paypal Express".
Any help would be greatly appreciated.
Thanks in advance.
You actually don't need to perform any customization, this variable is already available in the template though the object chain. This chain is supported by Magento template and allows usage of getters of the object.
In this case you need to retrieve order's payment object, then retrieve its method instance and retrieve method title from method instance. It is very simple construction:
{{var order.getPayment().getMethodInstance().getTitle()}}
This should help you!
Method Mage_Sales_Model_Order::sendNewOrderEmail() is responsible for sending new ordr emails.
$paymentBlock = Mage::helper('payment')->getInfoBlock($this->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
...
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
)
payment_html is rendered html output of the block, so you can not use it.
You can add one more assoc key (using rewite or local/mage trick) with the payment method and add this param to the subject using transactional emails.

Resources