Skip to content

Instantly share code, notes, and snippets.

shared_secret = None
use_sandbox = False
try:
opts, args = getopt.getopt(sys.argv[2:],"s:", ["secret=", "use_sandbox"])
except getopt.GetoptError:
print(help_message)
sys.exit(2)
for opt, arg in opts:
verify_receipt(receipt_data, shared_secret, use_sandbox)
@HelloNamiML
HelloNamiML / NamiAppDelegate.swift
Last active October 6, 2020 19:01
Set up Nami in your App Delegate
import Nami
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func namiSetup() {
let namiConfig = NamiConfiguration(appPlatformID: "YOUR_NAMI_APP_ID_HERE")
Nami.configure(namiConfig: namiConfig)
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
namiSetup()
return true
@HelloNamiML
HelloNamiML / raiseTipJar.swift
Created October 6, 2020 19:03
Raise the tipjar paywall
import Nami
class AboutViewController: UIViewController {
@IBAction func donateTapped(_ sender: Any) {
NamiPaywallManager.raisePaywall(fromVC: self)
}
}
@HelloNamiML
HelloNamiML / PurchaseChangeHandler.swift
Created October 6, 2020 20:48
Respond to a successful purchase on a tip jar paywall.
NamiPurchaseManager.register { (purchases, state, error) in
if state == .purchased {
if let purchase = purchases.first {
NamiPurchaseManager.consumePurchasedSKU(skuID: purchase.skuID)
}
// Make sure Nami paywall is closed before we put up thank you message.
NamiPaywallManager.dismissNamiPaywallIfOpen(animated: true) {
let alertController = UIAlertController(title: "Thank You", message: "Thank you so much for your donation! We will work hard to continue to bring you great updates.", preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default) { alertAction in
self.dismiss(animated: true, completion:{})
@HelloNamiML
HelloNamiML / appleResponseBody.json
Last active March 2, 2024 21:32
App Store Decoded Receipt Response Body
{
"environment": "Sandbox",
"receipt": {
"receipt_type": "ProductionSandbox",
"adam_id": 0,
"app_item_id": 0,
"bundle_id": "com.namiml.NamiRadio",
"application_version": "25",
"download_id": 0,
"version_external_identifier": 0,
@HelloNamiML
HelloNamiML / appleResponseBodyStub.json
Last active December 9, 2020 22:24
A stub of the top-level keys in an Apple verifyReceipt responseBody
{
"status": 21100,
"is-retryable": 1,
"environment": "Sandbox",
"receipt": {},
"latest_receipt": "",
"latest_receipt_info": [{}],
"pending_renewal_info": [{}],
}
@HelloNamiML
HelloNamiML / java_playbilling.gradle
Created December 23, 2020 20:03
Add Play Billing library to java android project build.gradle file.
dependencies {
def billing_version = "3.0.0"
implementation "com.android.billingclient:billing:$billing_version"
}
@HelloNamiML
HelloNamiML / kotlin_playbilling.gradle
Created December 23, 2020 20:06
Add Play Billing library to Kotlin project build.gradle.
dependencies {
def billing_version = "3.0.0"
implementation "com.android.billingclient:billing-ktx:$billing_version"
}
@HelloNamiML
HelloNamiML / appleResponseBody.receipt.json
Last active March 2, 2021 20:12
An example of an Apple responseBody's receipt data structure.
{
"receipt": {
"receipt_type": "ProductionSandbox",
"adam_id": 0,
"app_item_id": 0,
"bundle_id": "com.namiml.NamiRadio",
"application_version": "25",
"download_id": 0,
"version_external_identifier": 0,
"receipt_creation_date": "2020-07-23 19:32:51 Etc/GMT",