From 2eb937364ed5d87737948eab1950408a6f7d947e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 12 Aug 2022 16:42:12 +0000 Subject: [PATCH 1/4] chore(release): 1.9.11-alpha.5 --- CHANGELOG.md | 7 +++++++ android/app/build.gradle | 2 +- package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aff7b0853b..6895e986ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [1.9.11-alpha.5](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.4...1.9.11-alpha.5) (2022-08-12) + + +### Bug Fixes + +* versionSize name ([f83082a](https://github.com/Cap-go/capgo/commit/f83082ae2a27b41b18047a4b1a38af80f2a9d979)) + ### [1.9.11-alpha.4](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.3...1.9.11-alpha.4) (2022-08-12) diff --git a/android/app/build.gradle b/android/app/build.gradle index 46d0c6a6ba..96005b51b6 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -6,7 +6,7 @@ android { applicationId "ee.forgr.capacitor_go" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 10911400 + versionCode 10911500 versionName "1.9.11" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { diff --git a/package.json b/package.json index 9d6af10a07..7dfea1a76a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "1.9.11-alpha.4", + "version": "1.9.11-alpha.5", "scripts": { "build": "vite build", "test": "cypress open", From 69284fc018610abed4f84b3ca788f561be3e4d4f Mon Sep 17 00:00:00 2001 From: YacineMessaadi Date: Tue, 16 Aug 2022 21:24:15 +0100 Subject: [PATCH 2/4] feat: delete old subscription when upgrade --- supabase/functions/_utils/stripe.ts | 15 ++++++++++ supabase/functions/_utils/stripe_event.ts | 2 +- supabase/functions/stripe_event/index.ts | 34 ++++++++++++++++++----- 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/supabase/functions/_utils/stripe.ts b/supabase/functions/_utils/stripe.ts index 4d0e100bb1..7aa985af0a 100644 --- a/supabase/functions/_utils/stripe.ts +++ b/supabase/functions/_utils/stripe.ts @@ -67,3 +67,18 @@ export const createCustomer = async (email: string) => { return response.data } +export const removeOldSubscription = async (subscriptionId: string) => { + console.log('removeOldSubscription', subscriptionId) + const STRIPE_SECRET_KEY = Deno.env.get('STRIPE_SECRET_KEY') || '' + const STRIPE_TOKEN = `${STRIPE_SECRET_KEY}` + console.log('STRIPE_TOKEN', STRIPE_TOKEN) + const requestOptions = { + method: 'DELETE', + headers: { + Authorization: `Bearer ${STRIPE_TOKEN}`, + }, + } + + const response = await fetch(`https://api.stripe.com/v1/subscriptions/${subscriptionId}`, requestOptions) + return response.json() +} diff --git a/supabase/functions/_utils/stripe_event.ts b/supabase/functions/_utils/stripe_event.ts index d1542aec91..7fdc478d8b 100644 --- a/supabase/functions/_utils/stripe_event.ts +++ b/supabase/functions/_utils/stripe_event.ts @@ -82,7 +82,7 @@ export const extractDataEvent = (event: any): definitions['stripe_info'] => { const charge = event.data.object as any data.status = 'canceled' data.customer_id = String(charge.customer) - data.subscription_id = undefined + data.subscription_id = charge.id } else { console.log('Other event', event.type, event) diff --git a/supabase/functions/stripe_event/index.ts b/supabase/functions/stripe_event/index.ts index b7c4c345ea..711177ba12 100644 --- a/supabase/functions/stripe_event/index.ts +++ b/supabase/functions/stripe_event/index.ts @@ -4,6 +4,7 @@ import { extractDataEvent, parseStripeEvent } from '../_utils/stripe_event.ts' import { supabaseAdmin } from '../_utils/supabase.ts' import type { definitions } from '../_utils/types_supabase.ts' import { sendRes } from '../_utils/utils.ts' +import { removeOldSubscription } from '../_utils/stripe.ts' serve(async (event: Request) => { if (!event.headers.get('stripe-signature') || !Deno.env.get('STRIPE_WEBHOOK_SECRET') || !Deno.env.get('STRIPE_SECRET_KEY')) @@ -28,14 +29,15 @@ serve(async (event: Request) => { return sendRes(dbError, 500) if (!user) return sendRes('no user found', 500) - const { error: dbError2 } = await supabaseAdmin + + const { data: customer } = await supabaseAdmin .from('stripe_info') - .update(stripeData) + .select() .eq('customer_id', stripeData.customer_id) + .single() console.log('stripeData', stripeData) - if (dbError2) - return sendRes(dbError, 500) + await addDataPerson(user.email, { id: user.id, customer_id: stripeData.customer_id, @@ -50,6 +52,16 @@ serve(async (event: Request) => { .eq('stripe_id', stripeData.product_id) .single() if (plan) { + const { error: dbError2 } = await supabaseAdmin + .from('stripe_info') + .update(stripeData) + .eq('customer_id', stripeData.customer_id) + if (customer && customer.product_id !== 'free' && customer.subscription_id) + await removeOldSubscription(customer.subscription_id) + + if (dbError2) + return sendRes(dbError, 500) + const isMonthly = plan.price_m_id === stripeData.price_id await updatePerson(user.email, undefined, [plan.name, isMonthly ? 'Monthly' : 'Yearly']) await addEventPerson(user.email, { @@ -60,8 +72,16 @@ serve(async (event: Request) => { else { await updatePerson(user.email, undefined, ['Not_found']) } } else if (stripeData.status === 'canceled') { - await updatePerson(user.email, undefined, ['Canceled']) - await addEventPerson(user.email, {}, 'user:cancel', 'red') + if (customer && customer.subscription_id === stripeData.subscription_id) { + const { error: dbError2 } = await supabaseAdmin + .from('stripe_info') + .update(stripeData) + .eq('customer_id', stripeData.customer_id) + if (dbError2) + return sendRes(dbError, 500) + await updatePerson(user.email, undefined, ['Canceled']) + await addEventPerson(user.email, {}, 'user:cancel', 'red') + } } else { await updatePerson(user.email, undefined, ['Free']) @@ -72,7 +92,7 @@ serve(async (event: Request) => { catch (e) { console.log('Error', e) return sendRes({ - status: 'Error unknow', + status: 'Error unknown', error: JSON.stringify(e), }, 500) } From d1b86759fb2968c0b5dbff0ec667476d90a2e042 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 16 Aug 2022 20:24:44 +0000 Subject: [PATCH 3/4] chore(release): 1.10.0-alpha.0 --- CHANGELOG.md | 7 +++++++ android/app/build.gradle | 4 ++-- ios/App/App.xcodeproj/project.pbxproj | 8 ++++---- package.json | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6895e986ce..2899d3bf86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.10.0-alpha.0](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.5...1.10.0-alpha.0) (2022-08-16) + + +### Features + +* delete old subscription when upgrade ([69284fc](https://github.com/Cap-go/capgo/commit/69284fc018610abed4f84b3ca788f561be3e4d4f)) + ### [1.9.11-alpha.5](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.4...1.9.11-alpha.5) (2022-08-12) diff --git a/android/app/build.gradle b/android/app/build.gradle index 96005b51b6..cb89c66227 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "ee.forgr.capacitor_go" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 10911500 - versionName "1.9.11" + versionCode 1100000 + versionName "1.10.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 9ba9384a27..493809cc1f 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -349,12 +349,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "1.9.11"; + CURRENT_PROJECT_VERSION = "1.10.0"; DEVELOPMENT_TEAM = UVTJ336J2D; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = "1.9.11"; + MARKETING_VERSION = "1.10.0"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = ee.forgr.capacitorgo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -371,12 +371,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "1.9.11"; + CURRENT_PROJECT_VERSION = "1.10.0"; DEVELOPMENT_TEAM = UVTJ336J2D; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = "1.9.11"; + MARKETING_VERSION = "1.10.0"; PRODUCT_BUNDLE_IDENTIFIER = ee.forgr.capacitorgo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; diff --git a/package.json b/package.json index 7dfea1a76a..1b94b24b38 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "1.9.11-alpha.5", + "version": "1.10.0-alpha.0", "scripts": { "build": "vite build", "test": "cypress open", From e2557d405a816e082f9a9e592c30aad4a1cf6508 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 17 Aug 2022 10:27:56 +0000 Subject: [PATCH 4/4] chore(release): 1.15.0-alpha.0 --- CHANGELOG.md | 52 +++++++++++++++++++++++++++ android/app/build.gradle | 4 +-- ios/App/App.xcodeproj/project.pbxproj | 8 ++--- package.json | 2 +- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fca090d923..966854480f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,58 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.15.0-alpha.0](https://github.com/Cap-go/capgo/compare/1.10.0-alpha.0...1.15.0-alpha.0) (2022-08-17) + +### [1.14.6](https://github.com/Cap-go/capgo/compare/1.14.5...1.14.6) (2022-08-15) + + +### Bug Fixes + +* order of remove in device link ([2cf810f](https://github.com/Cap-go/capgo/commit/2cf810fb1b2812e095cffd7bdf6a5d5ec2be5b71)) + +### [1.14.5](https://github.com/Cap-go/capgo/compare/1.14.4...1.14.5) (2022-08-15) + +### [1.14.4](https://github.com/Cap-go/capgo/compare/1.14.3...1.14.4) (2022-08-12) + + +### Bug Fixes + +* issue with Foreign key ([50ba11b](https://github.com/Cap-go/capgo/commit/50ba11be9ece5fdddf1217f5b13625cb4b22d8e8)) + +### [1.14.3](https://github.com/Cap-go/capgo/compare/1.14.2...1.14.3) (2022-08-12) + + +### Bug Fixes + +* in no log today ([2f70755](https://github.com/Cap-go/capgo/commit/2f70755e9e54a99ba3fcc3b42925be2db6a43ba2)) + +### [1.14.2](https://github.com/Cap-go/capgo/compare/1.14.1...1.14.2) (2022-08-12) + + +### Bug Fixes + +* increase only if change ([6948731](https://github.com/Cap-go/capgo/commit/6948731dac1be459406161a71f322e556ad4cfa2)) + +### [1.14.1](https://github.com/Cap-go/capgo/compare/1.14.0...1.14.1) (2022-08-12) + + +### Bug Fixes + +* issue build ([c95944c](https://github.com/Cap-go/capgo/commit/c95944c3371b3c6ec8cdda5c7fb3c256a78faad5)) + +## [1.14.0](https://github.com/Cap-go/capgo/compare/1.13.14...1.14.0) (2022-08-12) + + +### Features + +* add bandwidth calc ([221abb6](https://github.com/Cap-go/capgo/commit/221abb62a05e8bff4a997e7c1383cfe8131a6d3d)) + +### [1.13.14](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.5...1.13.14) (2022-08-12) + +### [1.13.13](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.1...1.13.13) (2022-08-12) + +### [1.13.12](https://github.com/Cap-go/capgo/compare/1.9.11-alpha.0...1.13.12) (2022-08-12) + ### [1.14.6](https://github.com/Cap-go/capgo/compare/1.14.5...1.14.6) (2022-08-15) diff --git a/android/app/build.gradle b/android/app/build.gradle index 7f00452622..8b3110cdd3 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "ee.forgr.capacitor_go" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1140600 - versionName "1.14.6" + versionCode 1150000 + versionName "1.15.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/ios/App/App.xcodeproj/project.pbxproj b/ios/App/App.xcodeproj/project.pbxproj index 531b50e586..fdb0634971 100644 --- a/ios/App/App.xcodeproj/project.pbxproj +++ b/ios/App/App.xcodeproj/project.pbxproj @@ -349,12 +349,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "1.14.6"; + CURRENT_PROJECT_VERSION = "1.15.0"; DEVELOPMENT_TEAM = UVTJ336J2D; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = "1.14.6"; + MARKETING_VERSION = "1.15.0"; OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\""; PRODUCT_BUNDLE_IDENTIFIER = ee.forgr.capacitorgo; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -371,12 +371,12 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CODE_SIGN_ENTITLEMENTS = App/App.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = "1.14.6"; + CURRENT_PROJECT_VERSION = "1.15.0"; DEVELOPMENT_TEAM = UVTJ336J2D; INFOPLIST_FILE = App/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 13.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - MARKETING_VERSION = "1.14.6"; + MARKETING_VERSION = "1.15.0"; PRODUCT_BUNDLE_IDENTIFIER = ee.forgr.capacitorgo; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = ""; diff --git a/package.json b/package.json index 12aa099ae8..25c71dd42a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "private": true, - "version": "1.14.6", + "version": "1.15.0-alpha.0", "scripts": { "build": "vite build", "test": "cypress open",