Braintree create subscription with dynamic price - braintree

I am building a donation page where I want the user to decide the amount and frequency of the donation for hisself.
I looked up in the Braintree documentation, and I couldn't find out if and how to pass the amount of the subscription.
I am asking now how can I override the amount of the subscription. I am using Cashier/Braintree.
Should I apply them in the add-ons?

Full disclosure, I work at Braintree. If you have any further questions, contact support
You can change the default price of a subscription by passing the price parameter in your Subscription.create() API request. This will override the default price set by the plan you've configured. As an example, your API request may look something similar to this if you wanted to change the price of a single subscription to $20:
$result = $gateway->subscription()->create([
'paymentMethodToken' => 'the_token',
'planId' => 'the_plan_id',
'price' => '20'
]);
I've found that it is much easier to manage the price of subscriptions by using this method, however, you may also find it easier to use add-ons instead. If you choose to use add-ons, you'll need to create each add-on in the Control Panel.

Related

Magento Shipping Exception

I've been trying for the last week to find a way in Magento to have some conditions for shipping. What I mean:
whenever a certain product is shipped to a certain country I want Magento to use a specific courier but I don't want it to be shown on any other products.
The problem is that we don't have one storage place, we have many in different countries. Let's take England as an example. I have a bag that is made in UK. Worldwide delivery is set to a fixed amount using UPS. But I have another deal with a local courier. And I want these products (that are made in UK) to be shipped with this courier IF they are shipped in the UK.
I tried adding an attribute to these, but I don't find an action to show this method. Also, for other products or if the address is not in England this method should not be displayed.
It is possible do it with Magento shipping extension. You can try those free shipping extensions, or ask for trial of extensions that need pay.
I recommend use Owebia Shipping 2 which need a lit bit 'code' to program your shipments.
and you also need add new product attribute for define where this product made. Usually this attribute select type is a drop-down list.
Assume this product attribute code is made_from and attribute value is UK. here is the simple code for condition you mentioned:
Let's take England as an example. I have a bag that is made in UK. Worldwide delivery is set to a fixed amount using UPS. But I have another deal with a local courier. And I want these products (that are made in UK) to be shipped with this courier IF they are shipped in the UK.
here is the code for this example:
{
"outsideUK": {
"label": "UK local carrier",
"conditions": "{shipto.country_id} == 'GB'",
"fees": "1000"
}
}
Play with this extension if you interesting. I will update more detail if I got time.

Magento adding Cash on Delivery fee when user select paypal

i encountered an issue that sometimes arises on my Magento Community Edition 1.8 Store. The problem is that sometimes Magento adds the Cash on Delivery fee, to the order grand total, in spite of the user had selected Paypal as payment method. This happen only if the user selects Paypal as payment method and happen rarely. Sometimes even the amounts of the items through Paypal and Magento are not in compliance. Contact Paypal Support was not helpful.
Any help will be appreciate
Thanks in advance to everyone
Kind Regards
Steelwork Media Solutions
I feel like some necroposter, but I want to share some thoughts about solving this issue.
Recently I got the very same problem: user has chosen PayPal as payment method, but got charged with cash on delivery fee. After some investigating, I found out that cash on delivery module itself was a culprit.
The problem is in module's logic: it adds up COD fee when COD payment method is selected, but it DOES NOT clear that fee from quote, when payment method is changed to another one. So, when order is being created, fields with COD fee are being copied as is to order. And client gets charged for nothing.
The worst thing in this situation is that you don't see that fee applied in checkout. It pops up only in order.
For example, there is a part of code from MSP_CashOnDelivery module:
if (
($_helper->getQuote()->getPayment()->getMethod() == $_model->getCode()) &&
($address->getAddressType() == Mage_Sales_Model_Quote_Address::TYPE_SHIPPING)
) {
$address->setGrandTotal($address->getGrandTotal() + $amount);
$address->setBaseGrandTotal($address->getBaseGrandTotal() + $baseAmount);
$address->setMspCashondelivery($amount);
$address->setMspBaseCashondelivery($baseAmount);
$address->setMspCashondeliveryInclTax($amountInclTax);
$address->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
$quote->setMspCashondelivery($amount);
$quote->setMspBaseCashondelivery($baseAmount);
$quote->setMspCashondeliveryInclTax($amountInclTax);
$quote->setMspBaseCashondeliveryInclTax($baseAmountInclTax);
}
To solve the problem, you need to add following code below:
if ($_helper->getQuote()->getPayment()->getMethod() != $_model->getCode())
{
$address->setMspCashondelivery(0);
$address->setMspBaseCashondelivery(0);
$address->setMspCashondeliveryInclTax(0);
$address->setMspBaseCashondeliveryInclTax(0);
$quote->setMspCashondelivery(0);
$quote->setMspBaseCashondelivery(0);
$quote->setMspCashondeliveryInclTax(0);
$quote->setMspBaseCashondeliveryInclTax(0);
}
As mentioned in above answer, setting the fields to zero works perfectly. However, it will add a row in invoice and order with a zero charge and that may sound weird to customers. so just add a simple if condition for checking if charge is zero in all the Totals.php block files.
$amt = $this->getSource()->getServiceCharge();
$nameAmt = $this->getSource()->getServiceChargeName();
if ($amt && $amt!=0) {
$this->addTotalBefore(new Varien_Object(array(
'code' => 'service_charge',
'value' => $amt,
'base_value'=> $this->getSource()->getBaseServiceCharge(),
'label' => $nameAmt,
)), 'service_charge');
}

how to add cash on delivery charges by my custom module magento

HI I want to add some charges on cash on delivery, I dont know where to do that
what I need to extend or what observer I need to call and how I can get and update quote price can any body explain briefly to me.
Thanks in advance
Before you start thinking about code you need to describe (if only to yourself) how your new "cash on delivery" feature will work with Magento. When will users be prompted for this choice? What needs to be added to the backend order information panes? etc.
Once you know that, you can start to identify the blocks/phtml and model logic you'll need to change/add-to in order to implement your feature.

fedex integration to Magento not showing Discount rate

My integration with fedex is completed...auth key, meter # ect. Fedex had offered adiscount rate which is already programmed on their side and I can see in my account. However when i do a test, it shows me The LIST rate not the DISCOUNT rate which I want it offered to the clients as well. I need the total net FEDEX charge shown. Another problem is that it is not able to calculate the # of pcs purchased. Example if I bought1 stool the shipping rate is $100 and if i bought 4 stools the shipping cost is the same $100.
My developer seems to give up on this and says i hjust have to use the table> Please rea below what he is saying. I apolgize im not well versed at this. Please HELP ME.
Hi Susan,
After doing more research and talking with FedEx tech support executive and Magento support , I reached at this conclusion. I am describing the conclusion details below:
When I talked with tech support guy , he said me to contact with Magento team . I had also consult with them and scrutinize the code in programming label. I got that FedEx is giving only a API access to Magento. I am making it easy to understand you. FedEx is giving some access to us to get their shipping rates to show on our site. If we make a account specifies, I mean they are giving some discount only on your account or any specified account . FedEx has not developed this(customer specific shipping rates) type of API , which we’ll use it on micazza.net.
This account specific shipping rates can’t be applied on website.
It’ll be better if you’ll use table rates for shipping .You can modify it with respect to your requirements.
At last I want to tell you that this account specific FedEx shipping rates we can’t show on your site because FedEx shipping system has some limitations, As it is a third party site , we can’t access how much we need. So we can access those portions only, how much they’ll give access to us.
Kindly advise
There are several options for you. Unfortunately Magento isn't shipped with great support for dimensional or weight based shipping, you'll ideally want to customize the FedEx api request and read through the WSDL & FedEx API documentation. In the Mage_Usa Module's /etc folder you'll find WSDL definitions. The Out Of The Box WSDL uses a slightly older version of the FedEx api than is the most current available. It is possible to swap out the wsdl file and re-declare the version if more functionality is needed.
Webshop apps 'ShippingOverride2' module is highly effective for creating the shipping price rules you're seeking. Also I believe in your configuration you'll want to turn 'ship to residential' to false.
Additionally if you're shipping calculations require custom box sizes, you'll need to add protected variables and leverage them in the API call, such as in Mage_Usa_Model_Shipping_Carrier_Fedex or your extension of said class:
protected $_customizableContainerTypes = array('YOUR_PACKAGING');
protected $_customContainerSpecs = array(
"LARGE PARTS BOX" => array("length" => 8,
"width" => 14,
"height" => 10),
"XL PARTS BOX" => array("length" => 8,
"width" => 20,
"height" => 12),
"WHITE BAG SMALL" => array("length" => 1,
"width" => 12,
"height" => 9),
"WHITE BAG LARGE" => array("length" => 1,
"width" => 16,
"height" => 12)
);

Virtuemart Coupon Plugin based on quantity not value

I've had a look at available Virtuemart plugins and I can't find anything close to what I am after. This is what I need.
Allow admin user to create coupon codes. An import feature would be nice as there will be thousands but I can handle this bit if needed anyway.
The admin user selects the number of products the customer is allowed for each coupon code.
When the customer uses the coupon code they are allowed to choose any product on the website up to the total amount of products issued to the coupon. Regardless of the products price.
Nice extra would be to allow free shipping with the coupon.
I've looked at the possibility of extending virtuemart and I think it would be possible. It would however require quite a lot of changes and if I can find something that is halfway there it would help me on my way.
Thanks in advance.
OK well time was running out and I didn't get an answer so I rolled my own. It was actually fairly painless. I can't release the code but I can give you a good idea of the steps and a direction to go in.
extend vm_ps_coupon and override the update, add and process methods. Add and update should only require a change to the array that is sent to the DB. See here for more info on extending classes
Alter the enum in the database to allow for quantity as well as total and percent.
Within your new update method handle the variation of quantity to do as you need.
In the update method you can also set a flag for free shipping in a session variable.
In templates/checkout edit list_shipping_methods.php. Simply check for the free shipping flag and load the free_shipping class. You can then call free_shipping->list_rates($vars);
extend vm_ps_checkout, override the add method, call the parent add method and then check the result so you can delete the session variable for the free shipping.
Finally you will need to make some changes in the HTML. Unfortunatly i could not find a way to override this easily and since its only two small changes to the markup i just went ahead and hacked the core. If anyone knows of another way that would be great? I did see something online about using a Joomla hook and a System plugin but I'd rather keep it reliant on Virtuemart only.
In administrator/components/com_virtuemart/html/ edit coupon.coupon_form.php to show the new quantity radio button.
Then edit coupon.coupon_list.php to display the correct values. Currently it will only display percent and total.
Hope this helps someone in the future. If you need some assistance then post on here and I'll be happy to help.

Resources