Skip to content

Instantly share code, notes, and snippets.

View j3k0's full-sized avatar

Jean-Christophe Hoelt j3k0

View GitHub Profile
@j3k0
j3k0 / index.ts
Last active April 15, 2024 19:26
cordova-purchase-plugin v13 - micro example
document.addEventListener('deviceready', onDeviceReady);
function onDeviceReady() {
const store = CdvPurchase.store;
const { ProductType, Platform, LogLevel, Product, VerifiedReceipt } = CdvPurchase; // shortcuts
// We should first register all our products or we cannot use them in the app.
store.register([{
id: 'demo_monthly_basic',
import 'cordova-plugin-purchase';
document.addEventListener('deviceready', onDeviceReady);
let log: CdvPurchase.Logger;
let statusMessage: null | string = null;
function setStatusMessage(value: null | string) {
if (statusMessage !== value) {
statusMessage = value;
renderStatusUI();
@j3k0
j3k0 / index.html
Created November 8, 2022 11:48
Cordova In-App Purchase Documentation / index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body>
@j3k0
j3k0 / override-set-timeout-a.js
Last active October 28, 2022 02:24
setTimeout based on the audioContext timer
function customTimeoutFunction(audioContext) {
let tasks = [];
let nextTaskId = 1;
function now() {
return audioContext.currentTime * 1000;
}
function scheduler() {
@j3k0
j3k0 / index.html
Last active September 15, 2022 09:51
Tutorial Cordova In-App Purchase Consumable
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body>
@j3k0
j3k0 / index.html
Last active March 20, 2021 18:14
Tutorial Cordova In-App Purchase Non-Consumable
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
<title>Hello World</title>
</head>
<body>
@j3k0
j3k0 / webhook.purchases.updated.json
Created October 22, 2019 06:25
Example Fovea.Billing webhook request
{
"type": "purchases.updated",
"applicationUsername": "my_username",
"purchases": {
"apple:cc.fovea.purchase.subscription1sx": {
"productId": "apple:cc.fovea.purchase.subscription1sx",
"platform": "apple",
"sandbox": true,
"purchaseId": "apple:1000000573800707",
"purchaseDate": "2019-09-29T14:15:44.000Z",
@j3k0
j3k0 / android-release.sh
Created October 15, 2018 07:55
Generate an android release build with cordova
#!/bin/bash
cd "$(dirname "$0")"
ROOT_DIR="$(pwd)"
FINAL_APK="${FINAL_APK:-$ROOT_DIR/android-release-$(date +%Y%m%d-%H%M).apk}"
KEYSTORE="${KEYSTORE:-$ROOT_DIR/android-release.keystore}"
if test ! -e "$KEYSTORE"; then
echo "ERROR: Keystore file $KEYSTORE not found."
@j3k0
j3k0 / demo-code.js
Created May 26, 2020 07:10
angular in-app purchase example
function sync() {
$scope.ready = store.ready();
$scope.product = Object.assign({}, store.get("my_product_id"));
}
const dsync = window.debounce(sync, 50);
$scope.$on("$ionicView.beforeEnter", function () {
dsync();
store.when("my_product_id").updated(dsync);
});
@j3k0
j3k0 / response.json
Created May 25, 2020 10:18
Validate an Expired Subscription
{
"ok": false,
"route": "/v1/validate",
"status": 419,
"code": 6778003,
"message": "Transaction has expired 2020-03-09 10:24:06 Etc/GMT",
}