feat(stars): sync implement unified purchase flow
This commit is contained in:
parent
c13fbf8885
commit
7e0f9d1e62
26 changed files with 2087 additions and 282 deletions
24
internal/compat/android/stars.go
Normal file
24
internal/compat/android/stars.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package android
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
// DirectInvoiceCurrencies are the Google Play billing currencies for which
|
||||
// DrKLO's official client must use Telegram's invoice flow. telesrv does not
|
||||
// publish or verify Google Play products, so this prevents Stars options with
|
||||
// no store_product from entering the Play Billing branch once it is ready.
|
||||
var directInvoiceCurrencies = []string{
|
||||
"AED", "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "COP", "CZK", "DKK",
|
||||
"EGP", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW",
|
||||
"KZT", "MXN", "MYR", "NGN", "NOK", "NZD", "PEN", "PHP", "PKR", "PLN",
|
||||
"QAR", "RON", "RUB", "SAR", "SEK", "SGD", "THB", "TRY", "TWD", "UAH",
|
||||
"USD", "VND", "ZAR",
|
||||
}
|
||||
|
||||
func DirectInvoiceCurrencies() []string {
|
||||
return append([]string(nil), directInvoiceCurrencies...)
|
||||
}
|
||||
|
||||
func DirectInvoiceCurrenciesJSON() string {
|
||||
body, _ := json.Marshal(directInvoiceCurrencies)
|
||||
return string(body)
|
||||
}
|
||||
30
internal/compat/android/stars_test.go
Normal file
30
internal/compat/android/stars_test.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package android
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestDirectInvoiceCurrenciesAreStableAndContainUSD(t *testing.T) {
|
||||
values := DirectInvoiceCurrencies()
|
||||
if len(values) == 0 {
|
||||
t.Fatal("direct invoice currency list is empty")
|
||||
}
|
||||
foundUSD := false
|
||||
for _, value := range values {
|
||||
if value == "USD" {
|
||||
foundUSD = true
|
||||
}
|
||||
}
|
||||
if !foundUSD {
|
||||
t.Fatalf("direct invoice currencies = %v, want USD", values)
|
||||
}
|
||||
values[0] = "MUTATED"
|
||||
if DirectInvoiceCurrencies()[0] == "MUTATED" {
|
||||
t.Fatal("DirectInvoiceCurrencies returned mutable package storage")
|
||||
}
|
||||
var decoded []string
|
||||
if err := json.Unmarshal([]byte(DirectInvoiceCurrenciesJSON()), &decoded); err != nil || len(decoded) != len(values) {
|
||||
t.Fatalf("currency JSON = %q decoded=%v err=%v", DirectInvoiceCurrenciesJSON(), decoded, err)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue