Im trying to support the checkout of ZAR (South African Rand).
So far i have enabled $, this enables the paypal module however the conversion isn't being completed.
The site simply checkout to the value. Eg: R1500.00 = $1500.00 when checking out through paypal.
What is the correct way to do the currency conversion using the built in convertor?
Ok found the solution:
Taken from Opencart Forum by user Qphoria
Q: How can I use paypal if my currency isn't supported?
Q: How can I use a payment gateway that doesn't support my currency?
Q: Paypal doesn't support my currency?
A:
You are limited to what the payment gateway supports. However, you can add code to auto-convert your currency to the current exchange rate of a supported currency fairly easy.
(v1.5.x)
1. EDIT: catalog/controller/payment/.php
FIND (FIRST INSTANCE ONLY):
Code: Select all
$order_info = $this->model_checkout_order->getOrder
AFTER, ADD (Replace USD with your choice of valid currency):
Code: Select all
$order_info['currency_code'] = 'USD';
Whatever currency you choose to use, be sure you have it in your list of currencies on your store in the Admin->System->Localisation->Currency page. It doesn't need to be enabled, just has to exist so that the conversion calculation can be done.
This will then auto convert the amount before it is sent to the gateway. The customer won't likely notice this.
They will see, for example, 1000 AED on the checkout page
But you will see $272.25 USD (based on the current conversion rate) in your paypal account.
Up til 1.5.1.3, Paypal Standard did this automatically
In 1.5.2, it was changed (not for the better) to simply disable itself from the list of payments if using an unsupported currency. So that will need special instruction and maybe should be changed back in the core.
For now:
1. EDIT: catalog/model/payment/pp_standard.php
FIND AND REMOVE:
Code: Select all
if (!in_array(strtoupper($this->currency->getCode()), $currencies)) {
$status = false;
}
EDIT: catalog/controller/payment/pp_standard.php
FIND (THE FIRST INSTANCE ONLY):
Code: Select all
$order_info = $this->model_checkout_order->getOrder
AFTER, ADD:
Code: Select all
$currencies = array('AUD','CAD','EUR','GBP','JPY','USD','NZD','CHF','HKD','SGD','SEK','DKK','PLN','NOK','HUF','CZK','ILS','MXN','MYR','BRL','PHP','TWD','THB','TRY');
if (!in_array(strtoupper($this->currency->getCode()), $currencies)) {
$order_info['currency_code'] = 'USD';
}
Change "USD" with your choice of supported currency.
for opencart 2 or 3
the first step is the same
EDIT: catalog/model/extension/payment/pp_standard.php
FIND AND REMOVE:
if (!in_array(strtoupper($this->currency->getCode()), $currencies)) { $status = false; }
the second step is
at catalog/controller/extension/payment/pp_standard.php
find
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
after it ,and
$order_info['currency_code'] = 'USD';
this solution will exchange all currencies to USD and then go to paypal.com to pay
Related
Recurly Create Subscription. It doesn’t seem like they allow multiple coupons to be allowed added to the account during creation, but am I wrong? Or is there another way to add a coupon to the account subscription?
I already have multiple coupons setting in Recurly turned on, I'm just not sure how to apply them. I'm also using the PHP library if that makes any difference.
I found out you can actually create subscription with multiple coupons at once. All you need to do is organize coupon codes into comma separated list.
You must use the redeem subscription endpoint (rather than the create subscription endpoint) if you wish to apply multiple coupons
<?php
$coupon = Recurly_Coupon::get('special');
$redemption = $coupon->redeemCoupon('1', 'USD');
?>
More information here
You should work with Redeem a Coupon on an Account
Definition
https://:subdomain.recurly.com/v2/coupons/:coupon_code/redeem
PHP Examples
<?php
$coupon = Recurly_Coupon::get('special');
$redemption = $coupon->redeemCoupon('1', 'USD');
?>
Result Format
<redemption href="https://your-subdomain.recurly.com/v2/accounts/1/redemptions/316a4213e8fa9e97390aff4995bda9e6">
<coupon href="https://your-subdomain.recurly.com/v2/coupons/special"/>
<account href="https://your-subdomain.recurly.com/v2/accounts/1"/>
<subscription href="https://your-subdomain.recurly.com/v2/subscriptions/315fbd7a25b04f1333ea9f4418994fb5"/>
<uuid>316a4213e8fa9e97390aff4995bda9e6</uuid>
<single_use type="boolean">false</single_use>
<total_discounted_in_cents type="integer">0</total_discounted_in_cents>
<currency>USD</currency>
<state>active</state>
<created_at type="datetime">2015-09-23T17:13:30Z</created_at>
</redemption>
I was trying setup a paypal gateway but I was getting an error:
Gateway Disabled: PayPal does not support your store currency
By default, I have an AED Currency so I'm trying to convert it to USD when checking out to paypal but right now it is not working.
I have this in my theme's functons.php file:
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) {
$currencies['AED'] = __( 'Emirati Dirham', 'woocommerce' );
return $currencies;
}
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'AED': $currency_symbol = 'AED'; break;
}
return $currency_symbol;
}
add_filter( 'loop_shop_per_page', create_function( '$cols', 'return 12;' ), 20 );
add_filter( 'woocommerce_billing_fields', 'wc_billing_fields_state_filter', 10, 1 );
function wc_billing_fields_state_filter( $address_fields ) {
$address_fields['billing_state']['label'] = 'Emirate';
$address_fields['billing_state']['placeholder'] = 'Emirate';
return $address_fields;
}
EDIT: I've deactivated the plugin "All Currencies for WooCommerce" and the settings menu is now showing. But PayPal Gateway is still not allowed since AED is not a supported currency. How do I convert it to USD upon paying with PayPal?
The code above doesn't seem to work
The code you have adds AED to the list of the currencies "supported" by the PayPal gateway, but it doesn't perform any conversion to USD. To perform a conversion, you will need a couple of things:
A currency conversion function. WooCommerce, by itself, is "single currency" and it doesn't perform conversions, nor it provides or handles exchange rates. For that, you will need a multi-currency solution.
Once you have a multi-currency solution in place, you will have to add the code to invoke the currency conversion to transform AED to USD before the PayPal gateway sends the data to the PayPal servers.
Last, but not least, you will have to intercept the payment notification sent by PayPal, so that the cross checks are successful. That is, you will have an order for an amount in AED in your database, and the payment confirmation will send you an amount in USD. You will need a way to prevent such discrepancy from causing the payment validation to fail. Without this step, the orders will be left pending, or on hold, and you will have to "unblock" them manually.
Depending on the multi-currency solution in use, the exact approach could be slightly different. As the developer of the Currency Switcher for WooCommerce, I solved all of the above for my clients, using the plugins I developed and some custom code.
You can find the custom code that applies to our plugins in our knowledge base: Is it possible to use the Currency Switcher to allow Users to select a currency, but force payment in base currency, or an arbitrary currency?.
Whether you decide to use our plugins or not, the code should be a good starting point to implement a solution.
I have a magento website
We have a store
In a store we have multiple store views (US, EU and UK)
Each store view has it's own currency, etc.
The base currency is GBP at the default config (main)
My problem is that the display currencies work well. Each store view has it's own individual price (no automatic conversion). Everything seems to be working and in order. However, on the final payment emails and actual connection with payment providers (PayPal/Sage). The base currency is always used. Although the display appears in the currency for each store view.
My question is why are the store view currencies not used with PayPal, emails, etc. Although the amounts, display currency, etc work fine?
It turns out that Base Currency can be set on each Store View. However, this option was not presented on the admin side. I had to change the system.xml
app/code/core/Mage/Directory/etc/system.xml
<label>Base Currency</label>
I have to set the appropriate to change from 0 to 1
<show_in_store>1</show_in_store>
Once this was done, I could see Base Currency under "Currency Options" even within a store view. This now works well and everything seems to be working fine.
No PHP code changes or any additional plugins required.
When I had run into this issue with a rather large Magento store, this quick fix worked pretty well for me: Magento knowledge-base paypal base currency tweak
Just note that, that fix probably won't work out of the box but it'll take some tweaking
Here it is some solutions.
You might custom some codes
If you are using Paypal Express,
\app\code\core\Mage\Paypal\Model\Express.php
protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount)
{
$order = $payment->getOrder();
// prepare api call
$token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
$api = $this->_pro->getApi()
->setToken($token)
->setPayerId($payment->
getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID))
->setAmount($amount)
->setPaymentAction($this->_pro->getConfig()->paymentAction)
->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
->setInvNum($order->getIncrementId())
**->setCurrencyCode($order->getOrderCurrencyCode())** // should be used getOrderCurrencyCode();
->setPaypalCart(Mage::getModel('paypal/cart', array($order)))
->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled)
;
if ($order->getIsVirtual()) {
$api->setAddress($order->getBillingAddress())->setSuppressShipping(true);
} else {
$api->setAddress($order->getShippingAddress());
$api->setBillingAddress($order->getBillingAddress());
}
// call api and get details from it
$api->callDoExpressCheckoutPayment();
$this->_importToPayment($api, $payment);
return $this;
}
\app\code\core\Mage\Paypal\Model\Standard.php
public function getStandardCheckoutFormFields()
{
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
/* #var $api Mage_Paypal_Model_Api_Standard */
$api = Mage::getModel('paypal/api_standard')->setConfigObject($this->getConfig());
$api->setOrderId($orderIncrementId)
**->setCurrencyCode($order->getOrderCurrencyCode())** // should be used getOrderCurrencyCode();
//->setPaymentAction()
->setOrder($order)
->setNotifyUrl(Mage::getUrl('paypal/ipn/'))
->setReturnUrl(Mage::getUrl('paypal/standard/success'))
->setCancelUrl(Mage::getUrl('paypal/standard/cancel'));
// export address
$isOrderVirtual = $order->getIsVirtual();
$address = $isOrderVirtual ? $order->getBillingAddress() : $order->getShippingAddress();
if ($isOrderVirtual) {
$api->setNoShipping(true);
} elseif ($address->validate()) {
$api->setAddress($address);
}
// add cart totals and line items
$api->setPaypalCart(Mage::getModel('paypal/cart', array($order)))
->setIsLineItemsEnabled($this->_config->lineItemsEnabled)
;
$api->setCartSummary($this->_getAggregatedCartSummary());
$api->setLocale($api->getLocaleCode());
$result = $api->getStandardCheckoutRequest();
return $result;
}
I've got a problem integrating PayPal Express Checkout. I want to disable the possibility to add a note to the buyer during the checkout process.
I'm using the PHP SOAP SDK (merchant-php-1.1.93_0.zip).
service.EndPoint targets to https://api.sandbox.paypal.com/2.0/.
In the first step of the order, where I make the SetExpressCheckout.. call I set the following value:
$SetECReqDetails->AllowNote = 0;
$SetEcReqDetails is the instance of \SetExpressCheckoutRequestDetailsType. But the customer is still able the enter a note at the PayPal site.
You're setting AllowNote to 0, not "0".
var_dump(0 == null) //outputs: boolean true
Code in the PayPalAPIInterfaceService, line 2436, has the following:
if($this->AllowNote != null) {
//prop is not a collection
//prop not complex
//prop is not value
So basically, you are not defining AllowNote.
I have verified that with the SDK you are using, currently offered on x.com for EC, your code does not work, and the following does work:
$setECReqDetails->AllowNote = "0";
In PHP I do a simple calculation. Where we are, tax (GST) is charged at 10%. So, What I'm doing in my php code is:
$a=$_REQUEST["amount"]; // this contains 504.95
$amount = $a*.10;
BUT, When I click "Purchase" and it takes me to PayPal, instead of showing up with order details, PayPal says:
"The link you have used to enter the
PayPal system contains an incorrectly
formatted item amount."
Here's what I've tried:
I have tried making a purchase WITHOUT tax. And it worked.
I have tried making a purchase with a value of 504 INSTEAD OF 504.95 and it worked.
So, how can I charge 10% tax on 504.95?
Here's my code:
$amnt = $_REQUEST['amount'];
$amount = $amnt*.10;
$p->add_field('tax', $amount);
Any help at all is appreciated.
Thank you
UPDATE:
Okay,
So I think I may have figured out how to get the right way to send the data, by using
number_format($price*0.10);
But, it's not calculating properly on the paypal webpage!
I have a sample item priced at $504.85, and it is supposed to be taxed 10%.
But PayPal is only charging $50 (that does not equal 10%)
What the!?
Ok cool, I've got it.
I am now using:
$amnt = $_REQUEST['amount'];
$ship = $_REQUEST['freight'];
$comb = $amnt+$ship;
$amount = $comb*0.10;
$p->add_field('tax', number_format($amount,2,'.',''));
And it works perfectly. Thanks!