Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand All @@ -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 = "";
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"private": true,
"version": "1.14.6",
"version": "1.15.0-alpha.0",
"scripts": {
"build": "vite build",
"test": "cypress open",
Expand Down
15 changes: 15 additions & 0 deletions supabase/functions/_utils/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
2 changes: 1 addition & 1 deletion supabase/functions/_utils/stripe_event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
34 changes: 27 additions & 7 deletions supabase/functions/stripe_event/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
Expand All @@ -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<definitions['stripe_info']>('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,
Expand All @@ -50,6 +52,16 @@ serve(async (event: Request) => {
.eq('stripe_id', stripeData.product_id)
.single()
if (plan) {
const { error: dbError2 } = await supabaseAdmin
.from<definitions['stripe_info']>('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, {
Expand All @@ -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<definitions['stripe_info']>('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'])
Expand All @@ -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)
}
Expand Down