Git Product home page Git Product logo

aepricematrix's Introduction

AEPriceMatrix

Tier based currency conversion for iOS based on the App Store Pricing Matrix.

Overview

Example usage:

NSNumber *converted = [AEPriceMatrix convert:@0.99 from:@"USD" to:@"EUR"];
NSLog(@"converted to %@", converted);

Output:

converted to 0.89

In-App Purchase Tracking

This can be used for In-App Purchase tracking in a specific currency regardless of the local currency that the purchase was paid in. The following example tracks all revenue in EUR. See the In-App Purchase Programming Guide for details on how to implement a method like productForId: that finds an SKProduct by its product identifier.

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchased:
                [self finishTransaction:transaction];

                NSString *productId = transaction.payment.productIdentifier;
                SKProduct *product = [self productForId:productId];
                NSString *currency = [product.priceLocale objectForKey:NSLocaleCurrencyCode];
                NSNumber *price = product.price;

                NSNumber *revenue = [AEPriceMatrix convert:price from:currency to:@"EUR"];
                [self trackRevenue:revenue];

                break;
            // more cases
        }
    }
}

Available Currency Codes

Instead of plain currency code strings like @"USD" you can also use the following string constants:

kAECurrencyUSD    // U.S.
kAECurrencyCAD    // Canada
kAECurrencyMXN    // Mexico
kAECurrencyAUD    // Australia
kAECurrencyNZD    // New Zealand
kAECurrencyJPY    // Japan
kAECurrencyEUR    // Europe
kAECurrencyCHF    // Switzerland
kAECurrencyNOK    // Norway
kAECurrencyGBP    // U.K
kAECurrencyDKK    // Denmark
kAECurrencySEK    // Sweden
kAECurrencyCNY    // China
kAECurrencySGD    // Singapore
kAECurrencyHKD    // Hong Kong
kAECurrencyTWD    // Taiwan
kAECurrencyRUB    // Russia
kAECurrencyTRY    // Turkey
kAECurrencyINR    // India
kAECurrencyIDR    // Indonesia
kAECurrencyILS    // Isreal
kAECurrencyZAR    // South Africa
kAECurrencySAR    // Saudi Arabia
kAECurrencyAED    // UAE

aepricematrix's People

Contributors

billtt avatar fedya-l avatar wellle avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.