Skip to content

Commit

Permalink
Merge pull request #269 from gobitfly/BIDS-2913/fix-ios-purchases
Browse files Browse the repository at this point in the history
Bids 2913/fix ios purchases
  • Loading branch information
manuelsc authored Jan 15, 2024
2 parents e627247 + e76fa12 commit 10b519b
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 48 deletions.
16 changes: 8 additions & 8 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,15 @@
CODE_SIGN_ENTITLEMENTS = App/App.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 3HYX3N9WTV;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.5.4;
MARKETING_VERSION = 4.5.5;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = in.beaconcha.mobile;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -535,15 +535,15 @@
CODE_SIGN_ENTITLEMENTS = App/AppRelease.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 3HYX3N9WTV;
INFOPLIST_FILE = App/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 4.5.4;
MARKETING_VERSION = 4.5.5;
PRODUCT_BUNDLE_IDENTIFIER = in.beaconcha.mobile;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -566,7 +566,7 @@
CODE_SIGN_ENTITLEMENTS = "Beaconchain WidgetExtension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 3HYX3N9WTV;
INFOPLIST_FILE = "Beaconchain Widget/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand All @@ -575,7 +575,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 4.5.4;
MARKETING_VERSION = 4.5.5;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "in.beaconcha.mobile.Beaconchain-Widget";
Expand All @@ -598,7 +598,7 @@
CODE_SIGN_ENTITLEMENTS = "Beaconchain WidgetExtension.entitlements";
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 109;
CURRENT_PROJECT_VERSION = 110;
DEVELOPMENT_TEAM = 3HYX3N9WTV;
INFOPLIST_FILE = "Beaconchain Widget/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
Expand All @@ -607,7 +607,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 4.5.4;
MARKETING_VERSION = 4.5.5;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "in.beaconcha.mobile.Beaconchain-Widget";
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"bignumber.js": "^9.1.2",
"canvas-confetti": "^1.3.3",
"capacitor-navigationbarnx": "0.1.6",
"cordova-plugin-purchase": "^13.8.6",
"cordova-plugin-purchase": "^13.10.0",
"cordova-res": "^0.15.2",
"ethereum-blockies": "^0.1.1",
"hammerjs": "^2.0.8",
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/subscribe/subscribe.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class SubscribePage implements OnInit {
return
}

await this.merchant.restore()
await this.merchant.restore(this.selectedPackage.purchaseKey)
}

const currentPackage = await this.merchant.getCurrentPlanConfirmed()
Expand Down
20 changes: 0 additions & 20 deletions src/app/requests/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,26 +561,6 @@ export class NotificationGetRequest extends APIRequest<NotificationGetResponse>
}
}

export class NotificationSubsRequest extends APIRequest<ApiTokenResponse> {
private subscribe = 'subscribe'
private unsubscribe = 'unsubscribe'

resource = 'user/notifications/'
method = Method.POST
requiresAuth = true
postData = {}
ignoreFails = true

constructor(eventName: string, filter: string = null, enabled: boolean) {
super()
if (filter != null) {
this.resource += (enabled ? this.subscribe : this.unsubscribe) + '?event=' + eventName + '&filter=' + filter
} else {
this.resource += (enabled ? this.subscribe : this.unsubscribe) + '?event=' + eventName
}
}
}

export interface BundleSub {
event_name: string
event_filter: string
Expand Down
2 changes: 1 addition & 1 deletion src/app/tab-preferences/tab-preferences.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@
<p class="heart">
<ion-icon name="heart" (click)="notAnEasterEgg()"></ion-icon>
</p>
<p class="company">2020 - 2023 © Bitfly GmbH</p>
<p class="company">2020 - {{ currentYear }} © Bitfly GmbH</p>
<p class="appversion" (click)="openLogSessionDialog()">Version {{ appVersion }}</p>
<p class="appversion">{{ package }}</p>
</ion-content>
2 changes: 2 additions & 0 deletions src/app/tab-preferences/tab-preferences.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export class Tab3Page {
protected package = ''
protected currentFiatCurrency

protected currentYear = new Date().getFullYear()

constructor(
protected api: ApiService,
protected oauth: OAuthUtils,
Expand Down
21 changes: 11 additions & 10 deletions src/app/utils/MerchantUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export class MerchantUtils {

currentPlan = PRODUCT_STANDARD // use getCurrentPlanConfirmed instead

purchaseIntent = '' // temp workaround until new api is live

constructor(private alertService: AlertService, private api: ApiService, private platform: Platform, private storage: StorageService) {
if (!this.platform.is('ios') && !this.platform.is('android')) {
console.info('merchant is not supported on this platform')
Expand Down Expand Up @@ -124,7 +126,7 @@ export class MerchantUtils {
product: CdvPurchase.Validator.Request.Body,
callback: CdvPurchase.Callback<CdvPurchase.Validator.Response.Payload>
) => {
if (this.restorePurchase && product.id != 'in.beaconcha.mobile') {
if (this.restorePurchase) {
this.restorePurchase = false
await this.confirmPurchaseOnRemote(product)
}
Expand Down Expand Up @@ -238,19 +240,20 @@ export class MerchantUtils {
CdvPurchase.store.manageSubscriptions()
}

async restore() {
async restore(product: string) {
this.restorePurchase = true
this.purchaseIntent = product
await CdvPurchase.store.restorePurchases()
}

async purchase(product: string) {
const offer = CdvPurchase.store.get(product).getOffer()
const loading = await this.alertService.presentLoading('')
loading.present()
this.restorePurchase = true
this.purchaseIntent = product
CdvPurchase.store.order(offer).then(
() => {
this.restorePurchase = true

setTimeout(() => {
loading.dismiss()
}, 1500)
Expand All @@ -265,15 +268,13 @@ export class MerchantUtils {
}

private async confirmPurchaseOnRemote(product) {
if (product.id == 'in.beaconcha.mobile') {
this.alertService.showError('Purchase Error', 'Invalid product, try again later or report this issue to us if persistent.', PURCHASEUTILS + 4)
return
}

const isIOS = this.platform.is('ios')

// TODO in the future replace isIOS ? product.transaction.appStoreReceipt : product.transaction.purchaseToken
// with isIOS ? product.id : product.transaction.purchaseToken
const purchaseData = {
currency: product.currency,
id: product.id,
id: isIOS ? this.purchaseIntent : product.id,
priceMicros: product.priceMicros,
valid: product.valid,
transaction: {
Expand Down

0 comments on commit 10b519b

Please sign in to comment.