How to create In-App purchase based on country currency & location?

Hi,

I have 5 in app purchase options with different values, for Example :
$0.99 : 1000 chips
$1.99 : 5000 chips etc.

In UI that I create in cocos2d-x using different sprites & buttons, they are always shown in $, I use Label to show amount on screen, but I want to show them based on country, like many other games (clash of clans, candy crush saga) are showing it, i.e. if country is India then amount will be shown in Rs, for China it will be shown in Yuan likewise.

How can I do it? is there any method to do it or it will be great help if you can give some suggestions?

You can try using the country code from Application::getCurrentLanguage()

thanks Ajas,
but how can I set amount depending on location? since value for $1 is varies depending on country.

What platform are you targetting ?

For that, you generally want to use native methods to convert the price and currency to a string.

For example, on iOS, you need to do a request to get the SKProduct and then use that (remove the release if you are using ARC):

@implementation SKProduct (priceAsString)
- (NSString *) priceAsString
{
    NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
    [formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
    [formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
    [formatter setLocale:[self priceLocale]];
    
    NSString *str = [formatter stringFromNumber:[self price]];
    [formatter release];
    return str;
}
@end
1 Like

thanks Fradow, I am working on iOS only.
I will try this.