Skip to content

Commit 122abe2

Browse files
authored
Merge pull request #1740 from numbersprotocol/fix-send-half-of-recipt-id-to-add-num-points
Fix send half of recipt id to add num points
2 parents d9a4adc + ef08ad9 commit 122abe2

File tree

7 files changed

+23
-10
lines changed

7 files changed

+23
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.59.4 - 2022-06-28
9+
10+
### Fixed
11+
12+
- Truncate reciept_id from in app purchase
13+
814
## 0.59.3 - 2022-06-27
915

1016
### Added
@@ -13,7 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1319

1420
## 0.59.2 - 2022-06-22
1521

16-
#### Changed
22+
### Changed
1723

1824
- Revert Show capture options menu regardless of backend response. #1703
1925

android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ android {
66
applicationId "io.numbersprotocol.capturelite"
77
minSdkVersion rootProject.ext.minSdkVersion
88
targetSdkVersion rootProject.ext.targetSdkVersion
9-
versionCode 413
10-
versionName "0.59.3"
9+
versionCode 414
10+
versionName "0.59.4"
1111
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1212
}
1313
buildFeatures {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "capture-lite",
3-
"version": "0.59.3",
3+
"version": "0.59.4",
44
"author": "numbersprotocol",
55
"homepage": "https://numbersprotocol.io/",
66
"scripts": {

src/app/shared/dia-backend/num/dia-backend-num.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { HttpClient } from '@angular/common/http';
22
import { Injectable } from '@angular/core';
33
import { defer } from 'rxjs';
44
import { concatMap } from 'rxjs/operators';
5+
import { truncateReceipt } from '../../../utils/in-app-purchase';
56
import { DiaBackendAuthService } from '../auth/dia-backend-auth.service';
67
import { BASE_URL, BUBBLE_API_URL } from '../secret';
78

@@ -19,7 +20,7 @@ export class DiaBackendNumService {
1920
concatMap(headers => {
2021
const formData = new FormData();
2122
formData.set('points', pointsToAdd.toString());
22-
formData.set('receipt_id', receiptId);
23+
formData.set('receipt_id', truncateReceipt(receiptId));
2324
return this.httpClient.post<DiaBackendNumPointPurchaseResult>(
2425
`${BASE_URL}/api/v3/num/points/purchase/`,
2526
formData,

src/app/shared/in-app-store/in-app-store.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class InAppStoreService implements OnDestroy {
7171

7272
this.store.refresh();
7373
} catch (error) {
74-
const errorMessage = this.translocoService.getTranslation(
74+
const errorMessage = this.translocoService.translate(
7575
'inAppPurchase.failedToInitInAppStore'
7676
);
7777
this.errorService.toastError$(errorMessage).toPromise();
@@ -131,7 +131,7 @@ export class InAppStoreService implements OnDestroy {
131131
})
132132
);
133133
} catch (error) {
134-
const errorMessage = this.translocoService.getTranslation(
134+
const errorMessage = this.translocoService.translate(
135135
'wallets.buyNum.failedToAddPoints'
136136
);
137137
this.errorService.toastError$(errorMessage).toPromise();
@@ -175,7 +175,7 @@ export class InAppStoreService implements OnDestroy {
175175
}
176176

177177
private readonly onStoreError = (_: IAPError) => {
178-
const errorMessage = this.translocoService.getTranslation(
178+
const errorMessage = this.translocoService.translate(
179179
'inAppPurchase.inAppPurchaseErrorOcurred'
180180
);
181181
this.errorService.toastError$(errorMessage).toPromise();

src/app/utils/in-app-purchase.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import { isDevMode } from '@angular/core';
22
import { IAPProduct } from '@awesome-cordova-plugins/in-app-purchase-2/ngx';
33
import { CaptureInAppProductIds } from '../shared/in-app-store/in-app-store.service';
44

5+
export function truncateReceipt(recipt: string) {
6+
const preferredMaxLength = 1024;
7+
const receiptMaxLength = Math.min(recipt.length, preferredMaxLength);
8+
return recipt.substring(0, receiptMaxLength);
9+
}
10+
511
/**
612
* Usefull to see in app product state changes in console for better debugging.
713
* It will pring to console only in dev mode aka isDevMode() === true

0 commit comments

Comments
 (0)