Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
24c0f90
feat: payments v4
triniwiz Aug 12, 2025
084b582
chore(payments): clean up
triniwiz Aug 12, 2025
3687e90
chore(payments): bump
triniwiz Aug 12, 2025
50a75a4
fix(payments): purchase options
triniwiz Aug 12, 2025
3b5f1cd
chore(payments): bump
triniwiz Aug 12, 2025
f9e3ffd
fix(payment): isReady
triniwiz Aug 12, 2025
e57a3ea
fix(payment): clone
triniwiz Aug 12, 2025
fd73943
chore(payments): bump
triniwiz Aug 12, 2025
b0c9a70
feat(payments): Transaction type
triniwiz Aug 12, 2025
4479e73
chore(payment): bump
triniwiz Aug 12, 2025
665eed3
fix(payments): isAcknowledged
triniwiz Aug 12, 2025
5be4a1d
chore(payment): bump
triniwiz Aug 12, 2025
a48b638
feat(payments): isExpired, expirationDate, isRevoked & revocationDate
triniwiz Aug 13, 2025
0f3ad78
fix(payments): purchaseProduct
triniwiz Aug 13, 2025
d4998e5
fix(payments): priceAmountMicros
triniwiz Aug 13, 2025
cc1b646
fix(payments): purchase flow
triniwiz Aug 13, 2025
6b6a57e
fix(payment): purchase update listener
triniwiz Aug 13, 2025
93c6cee
feat(payments): use string for response.code
triniwiz Aug 13, 2025
bcd40ce
chore(payments): bump
triniwiz Aug 13, 2025
b7b48cd
fix(payments): onPurchase error handling
triniwiz Aug 14, 2025
3f97b83
chore(payments): bump
triniwiz Aug 14, 2025
57231da
feat(payments): show storekit version used
triniwiz Aug 14, 2025
df68216
fix(payments): iOS receipt storekit v1
triniwiz Aug 14, 2025
2225b1f
fix(payments): isExpired & isRevoked
triniwiz Aug 14, 2025
f1651a2
feat(payments): showSubscriptionsManagement
triniwiz Aug 15, 2025
f7a783f
fix(payments): purchase & restore state
triniwiz Aug 15, 2025
7e9adfb
chore(payments): bump
triniwiz Aug 15, 2025
3196aff
feat(payments): forceStoreV1Receipt
triniwiz Aug 15, 2025
ca44f0b
fix(payments): v1 store
triniwiz Aug 15, 2025
11c587e
fix(payments): callback execution
triniwiz Aug 15, 2025
9e40efd
fix(payments): callback execute
triniwiz Aug 15, 2025
1d21459
fix(payments): set alwaysStoreV1Receipt visibility as public
triniwiz Aug 18, 2025
092cbac
fix(payments): first purchase not returning v1 receipt
triniwiz Aug 19, 2025
5f87f45
feat(payments): allow optional consume for non subs
triniwiz Aug 19, 2025
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
Prev Previous commit
Next Next commit
feat(payments): use string for response.code
  • Loading branch information
triniwiz committed Aug 13, 2025
commit 93c6ceeb2f79d8c3e4e21ea1e0d0e70a3836c954
9 changes: 2 additions & 7 deletions packages/payments/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,9 @@ export class PaymentError extends Error {
this.nativeError = nativeError;
}

get code(): number {
return this.nativeError?.getCode() ?? Number.MAX_SAFE_INTEGER;
get code(): string {
return this.nativeError.getRaw();
}

get subCode(): number {
return this.nativeError?.getSubCode() ?? Number.MAX_SAFE_INTEGER;
}

get native(): any {
return this.nativeError;
}
Expand Down
8 changes: 8 additions & 0 deletions packages/payments/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
export type FailureTypes = 'DEFERRED_PAYMENT' | 'PURCHASE_NOT_ALLOWED' | 'PRODUCT_UNAVAILABLE' | 'DEVELOPER_USAGE' | 'PRODUCT_ALREADY_OWNED' | 'PRODUCT_NOT_OWNED' | 'USER_CANCELLED' | 'NETWORK_AVAILABILITY' | 'BILLING_AVAILABILITY' | 'UNSPECIFIED' | 'SERVICE_DISCONNECTED' | 'SERVICE_TIMEOUT' | 'SERVICE_UNAVAILABLE' | 'FEATURE_NOT_SUPPORTED' | 'ERROR' | 'USER_INELIGIBLE' | 'INSUFFICIENT_FUNDS';

export class PaymentError extends Error {
readonly code: FailureTypes;
readonly native: any;
readonly resolution: string;
}

export interface PurchaseOptions {
accountId?: string;
android?: {
Expand Down
8 changes: 2 additions & 6 deletions packages/payments/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,8 @@ export class PaymentError extends Error {
this.nativeError = nativeError;
}

get code(): number {
return this.nativeError?.code ?? Number.MAX_SAFE_INTEGER;
}

get subCode(): number {
return Number.MAX_SAFE_INTEGER;
get code(): string {
return this.nativeError.raw ?? 'UNSPECIFIED';
}

get native(): any {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,45 @@ class Payments(context: Context) {
val message: String,
val resolution: String,
val subCode: Int = Int.MAX_VALUE
)
) {
val raw: String
get() {
if (subCode == BillingClient.OnPurchasesUpdatedSubResponseCode.USER_INELIGIBLE) {
return "USER_INELIGIBLE"
} else if (subCode == BillingClient.OnPurchasesUpdatedSubResponseCode.PAYMENT_DECLINED_DUE_TO_INSUFFICIENT_FUNDS) {
return "INSUFFICIENT_FUNDS"
}

return when (code) {
BillingClient.BillingResponseCode.OK -> "OK"

BillingClient.BillingResponseCode.BILLING_UNAVAILABLE -> "NETWORK_ERROR"

BillingClient.BillingResponseCode.NETWORK_ERROR -> "NETWORK_ERROR"

BillingClient.BillingResponseCode.USER_CANCELED -> "USER_CANCELED"

BillingClient.BillingResponseCode.ITEM_UNAVAILABLE -> "ITEM_UNAVAILABLE"

BillingClient.BillingResponseCode.DEVELOPER_ERROR -> "DEVELOPER_ERROR"

BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED -> "FEATURE_NOT_SUPPORTED"

BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED -> "ITEM_ALREADY_OWNED"

BillingClient.BillingResponseCode.ITEM_NOT_OWNED -> "ITEM_NOT_OWNED"

BillingClient.BillingResponseCode.SERVICE_UNAVAILABLE -> "SERVICE_UNAVAILABLE"

BillingClient.BillingResponseCode.SERVICE_DISCONNECTED -> "SERVICE_DISCONNECTED"

BillingClient.BillingResponseCode.SERVICE_TIMEOUT -> "SERVICE_TIMEOUT"

BillingClient.BillingResponseCode.ERROR -> "ERROR"
else -> "UNSPECIFIED"
}
}
}

enum class Features(val value: String) {
Subscriptions(BillingClient.FeatureType.SUBSCRIPTIONS),
Expand Down
31 changes: 31 additions & 0 deletions packages/payments/platforms/ios/src/NSCPayment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,33 @@ public enum NSCPaymentsResponseFailure: Int32, RawRepresentable {
return 10
}
}

var stringValue: String {
switch self {
case .ProductUnavailable:
return "PRODUCT_UNAVAILABLE"
case .DeveloperUsage:
return "DEVELOPER_USAGE"
case .ProductAlreadyOwned:
return "PRODUCT_ALREADY_OWNED"
case .ProductNotOwned:
return "PRODUCT_NOT_OWNED"
case .UserCancelled:
return "USER_CANCELLED"
case .NetworkAvailability:
return "NETWORK_AVAILABILITY"
case .BillingAvailability:
return "BILLING_AVAILABILITY"
case .Unspecified:
return "UNSPECIFIED"
case .PurchaseNotAllowed:
return "PURCHASE_NOT_ALLOWED"
case .DeferredPayment:
return "DEFERRED_PAYMENT"
case .Error:
return "ERROR"
}
}
}

@objc(NSCPaymentsResponse)
Expand All @@ -512,6 +539,10 @@ public class NSCPaymentsResponse: NSObject {
self.message = message
self.resolution = resolution
}

public var raw: String {
return code.stringValue
}
}

@objc(NSCPurchaseOptions)
Expand Down
1 change: 1 addition & 0 deletions packages/payments/typings/android.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ declare module org {
public getCode(): number;
public getResolution(): string;
public getSubCode(): number;
public getRaw(): string;
}
export class Companion {
public static class: java.lang.Class<org.nativescript.plugins.payments.Payments.Companion>;
Expand Down
2 changes: 2 additions & 0 deletions packages/payments/typings/objc!NSCPayments.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ declare class NSCPaymentsResponse extends NSObject {

readonly code: NSCPaymentsResponseFailure;

readonly raw: string;

readonly message: string;

readonly resolution: string;
Expand Down