Skip to content

albeebe/php-appstore-matrix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-appstore-matrix

PHP class with a bunch of functions to help you use the App Store price matrix in your code

Uses

Let's say you lowered an in-app purchase to $0.99 (USD) and you want to send a push notification to user in Japan, but you want to display the price as it would be displayed in Japan.

First you get the tier for $0.99 USD.

  • tierForPriceWithCurrency("0.99", "USD")
  • returns 1


Next you get the currency code for Japan
  • currencyForCountry("JA")
  • returns JPY


Now you get the price for JPY in tier 1
  • priceForCurrencyInTier("JPY", "1")
  • returns 85


Finally you can format the price as it would be displayed in Japan
  • formatPriceWithCurrency("85", "JPY")
  • returns ¥85

Examples

<TR>
	<TD VALIGN="top">
		<PRE>proceedsForCurrencyInTier("USD", "1")<BR>proceedsForCurrencyInTier("GBP", "5")<BR>proceedsForCurrencyInTier("EUR", "11")<BR>proceedsForCurrencyInTier("JPY", "20")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>0.70<BR>1.82<BR>6.08<BR>1190</PRE>
	</TD>
</TR>

<TR>
	<TD VALIGN="top">
		<PRE>tierForPriceWithCurrency("0.99", "USD")<BR>tierForPriceWithCurrency("2.99", "GBP")<BR>tierForPriceWithCurrency("9.99", "EUR")<BR>tierForPriceWithCurrency("1700", "JPY")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>1<BR>5<BR>11<BR>20</PRE>
	</TD>
</TR>

<TR>
	<TD VALIGN="top">
		<PRE>tierForProceedWithCurrency("0.70", "USD")<BR>tierForProceedWithCurrency("1.82", "GBP")<BR>tierForProceedWithCurrency("6.08", "EUR")<BR>tierForProceedWithCurrency("1190", "JPY")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>1<BR>5<BR>11<BR>20</PRE>
	</TD>
</TR>

<TR>
	<TD VALIGN="top">
		<PRE>currencyForCountry("US")<BR>currencyForCountry("GB")<BR>currencyForCountry("FR")<BR>currencyForCountry("JA")<BR></PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>USD<BR>GBP<BR>EUR<BR>JPY</PRE>
	</TD>
</TR>

<TR>
	<TD VALIGN="top">
		<PRE>formatPriceWithCurrency("0.99", "USD")<BR>formatPriceWithCurrency("2.99", "GBP")<BR>formatPriceWithCurrency("9.99", "EUR")<BR>formatPriceWithCurrency("1700", "JPY")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>$0.99<BR>£2.99<BR>9,99 €<BR>¥1,700</PRE>
	</TD>
</TR>

<TR>
	<TD VALIGN="top">
		<PRE>pricesForTier("1")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>Array

( [USD] => 0.99 [CAD] => 0.99 [MXN] => 13.00 [AUD] => 0.99 [NZD] => 1.29 [JPY] => 85 [EUR] => 0.89 [DKK] => 7.00 [SEK] => 7.00 [CHF] => 1.00 [NOK] => 7.00 [GBP] => 0.69 [CNY] => 6.00 [SGD] => 1.28 [HKD] => 8.00 [TWD] => 30 [RUB] => 33 [TRY] => 1.79 [INR] => 55 [IDR] => 9500 [ILS] => 3.90 [ZAR] => 7.99 [SAR] => 3.69 [AED] => 3.69 )

<TR>
	<TD VALIGN="top">
		<PRE>proceedsForTier("1")</PRE>
	</TD>
	<TD VALIGN="top">
		<PRE>Array

( [USD] => 0.70 [CAD] => 0.70 [MXN] => 9.10 [AUD] => 0.63 [NZD] => 0.90 [JPY] => 60 [EUR] => 0.54 [DKK] => 4.26 [SEK] => 4.26 [CHF] => 0.65 [NOK] => 3.92 [GBP] => 0.42 [CNY] => 4.20 [SGD] => 0.9 [HKD] => 5.60 [TWD] => 21 [RUB] => 23.10 [TRY] => 1.25 [INR] => 38.50 [IDR] => 6650.00 [ILS] => 2.73 [ZAR] => 5.59 [SAR] => 2.58 [AED] => 2.58 )

priceForCurrencyInTier("USD", "1")
priceForCurrencyInTier("GBP", "5")
priceForCurrencyInTier("EUR", "11")
priceForCurrencyInTier("JPY", "20")
0.99
2.99
9.99
1700

License

The MIT License

Copyright (c) 2013 Alan Beebe

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

PHP class with a bunch of functions to help you use the App Store price matrix in your code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages