How to add currency converter to my flutter e-commerce app? - flutter

I'm creating an app where users can upload products in their country's currency and the product will be visible for other users in their own country's currency.
For example, a user from France should be able to set the price of the product in Euros and other users viewing the product, say one of them is viewing the product from Australia then the price should be converted to Australian dollars.
How do I achieve this with flutter?
If I have the user's country details already, is there any converter plugin or API that does this?
The plugin or API should obviously update with rates. I'm using Firebase for the database to store the uploaded product and details. Or maybe I can save the product price in multiple currencies with their current rates at the time of upload and the price wont change with the change in rates after upload.

use the api to get the updated conversion rates. You can use this api

You can use the forex package to access exchange rates easily.
From their examples section:
quotes = await Forex.fx(
quoteProvider: QuoteProvider.ecb,
base: 'JPY',
quotes: <String>['EUR', 'USD']);
print('Number of quotes retrieved: ${quotes.keys.length}.');
print('Exchange rate JPYEUR: ${quotes['JPYEUR']}.');
print('Exchange rate JPYUSD: ${quotes['JPYUSD']}.');
Please note that getting the exchange rates of currency is the easy part in the mess that banking is... be sure to think about all the edge cases in your application if you want to do more than just display a price tag.

Related

Facebook graph api doesn't return currency

I have problem getting user local currency and usd-exchange rate from facebook, so this one: https://developers.facebook.com/docs/graph-api/reference/currency/
I'm trying to show my shop prices in local currency, just like fb shows prices in local currency in its own purchase dialog after facebook-purchase is launched.
I'm trying to get currency like this:
https://graph.facebook.com/v2.12/me?fields=id,name,currency&access_token=...
(Actually using Unity and Facebook's Unity SDK to do this, but exactly same thing happens when using url above.)
That have definitely worked before. I've also tried api version 3.2. It returns id and name, but no currency info of any kind. But it doesn't give any error message either, as it does with invalid fields.
I really can't find any useful info or help to this. Does getting currency require special permissions these days? But I can't find anything currency related from FB dev console App Review / Permissions and Features either.
Thanks!
Answering to my own question. It just seems that currency info is no longer available.
Starting from January 8th (2019) that field is no longer available for any apps:
https://developers.facebook.com/blog/post/2018/05/01/facebook-login-updates-further-protect-privacy/
There's discussion about this issue here, without any solution so far (may require having FB developer account to access):
https://developers.facebook.com/bugs/285780305453757/
There are some workarounds to get user currency like:
New way to detect Facebook API user currency
But that doesn't give you exchange rate to USD, so that isn't too helpful showing prices in local currency before Facebook's own purchase dialog is displayed.
Very unfortunate. Still, if someone knows way to get local currency and exchange rate that will surely match exchange rates used by FB, please let me know.

Magento2 currency switcher using rest API

I am creating a Magento website with currency switcher, It works fine in webview. I need the same for mobile app. If the user changed the currency once, all the prices should change to selected currency.
Are we need to add any extra parameter on every API call to get chosen currency value?
You can create multiple store views for each currency. When user change currency you can simply load that store view via API.

Is there a notification for when the user changes App Stores?

I'm testing an in-app purchase and have been jumping between the French, UK and Australian app stores to do so. I know it's a edge case but I'd like to be able to update the price of the purchase on the screen when the user changes stores as I have been. Is there a notification for this or do I have to poll the product's priceLocal property?
You shouldn't hard code the prices anyway. Use the products local price.
If apple changed the price tiers, or exchange rates changed dramatically and apple changed a locale price, then your app would have the wrong prices in it.
It should be possible to register an observer on the property as on all other properties with addObserver:forKeyPath:.

Facebook Credits and Foreign currency

I am developing an application that uses FB Credits as a currency, however, my clients are going to be paying in their local currency (ILS, israeli sheqel).
I know the rate for 1 credit is 10 cents, however, the price in ILS seems to be changing according to changes in the exchange-rates of USD-ILS.
Is there a way to query Facebook Server to know the prices users are going to be charged in their local money? Like a way to query the pricelist. Many new users don't understand the concept of credits and i'd like to show them what they're about to pay in local money.
The Facebook Credits API doesn't have exchange rate information available. You could request this feature on their developer group. You're best bet would be to pull down an exchange rate feed (there are tons available if you search) and display that with a warning that it is just an estimated rate and that it is dependent on the actual exchange rate Facebook uses.
xe.com is a great feed , you can also pull data from yahoo or google finance
As stated by OffBySome, Facebook do not have exchange rate information available. Thinking about this, I can see why they don't have this as they do not want you to display the local currency price for items. Although at the moment Facebook Credits are relatively new, and there is a lot of confusion for end users, eventually when it becomes widespread there won't be these issues.
I would suggest for now (as that is what I have done - here one Facebook Credit is currently ~7p) that you just hard code in your app the price of 1 Facebook Credit in your local currency, and if required display this. I think one of the reasons why Facebook don't support this is that they didn't envisage apps using Credits to be restricted to one territory, however in reality not everything is a game to be used worldwide. :)
Just to sum this question up, I tried two methods. One was to pull the rate every 10 minutes from openexchange using this python function:
def update_ils_rate():
print "Updating ILS/USD exchange rate"
url = 'http://openexchangerates.org/latest.json'
response = requests.request('get', url)
content = response.content
data = loads(content)
return data['rates']['ILS']
However it seems that facebook credits calculates ILS(israeli sheqel) rate according to a different rate (calculations were off by a little). So we have decided to pull xml data from israel's central bank, using this function:
import requests, BeautifulSoup
def get_ils_rate():
response = requests.request('get', 'http://www.bankisrael.gov.il/currency.xml')
content = response.content
soup = BeautifulSoup(content)
currencies = soup.findAll('currency')
for c in currencies:
if c.currencycode.contents[0]=='USD':
return float(c.rate.contents[0])

iPhone Native Stocks Application

Anyone know how apple uses yahoo finance api to get the historical data for stocks at different times of the dat. Also, how to get the quote price for a given stock at different times of the day for today instead of just the current quote?
It seems that the yahoo finance api can be used to get the current price, and the iChart.yahoo.. can be used to get closing prices for stocks each day. Thanks!
Josh
Try the Mergent Historical Securities Data API - http://www.mergent.com/servius