ChikabuZ
ChikabuZ

Reputation: 10195

How to calculate net revenue from in-app purchase price programmatically?

I want to get price tier from SKProduct, and calculate net revenue from AppStore price.

For example, from 0.99 USD I got 0.7 USD, from 1.29 AUD - 0.82 AUD. Can I calculate it programmatically?

Upvotes: 0

Views: 528

Answers (2)

ChikabuZ
ChikabuZ

Reputation: 10195

For now it looks like this:

var netRevenue = 0.0

switch currency
{
    case "USD", "CAD", "NZD":
    netRevenue = (price + 0.01) * 0.7

    case "EUR", "DKK", "SEK", "GBP":
    netRevenue = price * 0.70 / 1.15

    case "AUD":
    netRevenue = price * 0.70 / 1.11

    case "CHF":
    netRevenue = price * 0.70 / 1.08

    case "NOK":
    netRevenue = price * 0.70 / 1.25

    case "ZAR":
    netRevenue = price * 0.70 / 1.14

    default:
    netRevenue = 0.7 * price;
}
netRevenue.roundTo(".2")

//.roundTo
extension Double
{
    mutating func roundTo(f: String)
    {
        self = NSString(format: "%\(f)f", self).doubleValue
    }
}

Upvotes: 1

Istvan
Istvan

Reputation: 1627

Yes you can calculate it programatically. You get 70% of the revenue so the code should be

 float revenue = price * 0.7f

Upvotes: 0

Related Questions