Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit e5d6824

Browse files
committed
refactor: error naming
1 parent fddc690 commit e5d6824

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

Sources/Models/OpenIapProduct.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public struct OpenIapProduct: Codable, Equatable {
3434
public let introductoryPriceAsAmountIOS: String?
3535
public let introductoryPricePaymentModeIOS: String? // PaymentMode as String
3636
public let introductoryPriceNumberOfPeriodsIOS: String?
37-
public let introductoryPriceSubscriptionPeriodIOS: String? // SubscriptionIosPeriod as String
37+
public let introductoryPriceSubscriptionPeriodIOS: String? // SubscriptionPeriodIOS as String
3838
public let subscriptionPeriodNumberIOS: String?
39-
public let subscriptionPeriodUnitIOS: String? // SubscriptionIosPeriod as String
40-
39+
public let subscriptionPeriodUnitIOS: String? // SubscriptionPeriodIOS as String
40+
4141
// Discount structure for ProductSubscriptionIOS
4242
public struct Discount: Codable, Equatable {
4343
/// Discount identifier

Sources/OpenIapError.swift

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -53,56 +53,57 @@ public extension OpenIapError {
5353
static let E_EMPTY_SKU_LIST = "E_EMPTY_SKU_LIST"
5454

5555
/// Dictionary of error keys to OpenIAP codes
56+
/// Keys use PascalCase to match TS ErrorCode enum
5657
static func errorCodes() -> [String: String] {
5758
return [
5859
// User Action Errors
59-
"userCancelled": Self.E_USER_CANCELLED,
60-
"userError": Self.E_USER_ERROR,
61-
"deferredPayment": Self.E_DEFERRED_PAYMENT,
62-
"interrupted": Self.E_INTERRUPTED,
60+
"UserCancelled": Self.E_USER_CANCELLED,
61+
"UserError": Self.E_USER_ERROR,
62+
"DeferredPayment": Self.E_DEFERRED_PAYMENT,
63+
"Interrupted": Self.E_INTERRUPTED,
6364

6465
// Product Errors
65-
"itemUnavailable": Self.E_ITEM_UNAVAILABLE,
66-
"skuNotFound": Self.E_SKU_NOT_FOUND,
67-
"skuOfferMismatch": Self.E_SKU_OFFER_MISMATCH,
68-
"queryProduct": Self.E_QUERY_PRODUCT,
69-
"alreadyOwned": Self.E_ALREADY_OWNED,
70-
"itemNotOwned": Self.E_ITEM_NOT_OWNED,
66+
"ItemUnavailable": Self.E_ITEM_UNAVAILABLE,
67+
"SkuNotFound": Self.E_SKU_NOT_FOUND,
68+
"SkuOfferMismatch": Self.E_SKU_OFFER_MISMATCH,
69+
"QueryProduct": Self.E_QUERY_PRODUCT,
70+
"AlreadyOwned": Self.E_ALREADY_OWNED,
71+
"ItemNotOwned": Self.E_ITEM_NOT_OWNED,
7172

7273
// Network & Service Errors
73-
"networkError": Self.E_NETWORK_ERROR,
74-
"serviceError": Self.E_SERVICE_ERROR,
75-
"remoteError": Self.E_REMOTE_ERROR,
76-
"initConnection": Self.E_INIT_CONNECTION,
77-
"serviceDisconnected": Self.E_SERVICE_DISCONNECTED,
78-
"connectionClosed": Self.E_CONNECTION_CLOSED,
79-
"iapNotAvailable": Self.E_IAP_NOT_AVAILABLE,
80-
"billingUnavailable": Self.E_BILLING_UNAVAILABLE,
81-
"featureNotSupported": Self.E_FEATURE_NOT_SUPPORTED,
82-
"syncError": Self.E_SYNC_ERROR,
74+
"NetworkError": Self.E_NETWORK_ERROR,
75+
"ServiceError": Self.E_SERVICE_ERROR,
76+
"RemoteError": Self.E_REMOTE_ERROR,
77+
"InitConnection": Self.E_INIT_CONNECTION,
78+
"ServiceDisconnected": Self.E_SERVICE_DISCONNECTED,
79+
"ConnectionClosed": Self.E_CONNECTION_CLOSED,
80+
"IapNotAvailable": Self.E_IAP_NOT_AVAILABLE,
81+
"BillingUnavailable": Self.E_BILLING_UNAVAILABLE,
82+
"FeatureNotSupported": Self.E_FEATURE_NOT_SUPPORTED,
83+
"SyncError": Self.E_SYNC_ERROR,
8384
// Lifecycle/Preparation Errors (extra parity)
84-
"notPrepared": Self.E_NOT_PREPARED,
85-
"notEnded": Self.E_NOT_ENDED,
86-
"developerError": Self.E_DEVELOPER_ERROR,
85+
"NotPrepared": Self.E_NOT_PREPARED,
86+
"NotEnded": Self.E_NOT_ENDED,
87+
"DeveloperError": Self.E_DEVELOPER_ERROR,
8788

8889
// Validation Errors
89-
"receiptFailed": Self.E_RECEIPT_FAILED,
90-
"receiptFinished": Self.E_RECEIPT_FINISHED,
91-
"receiptFinishedFailed": Self.E_RECEIPT_FINISHED_FAILED,
92-
"transactionValidationFailed": Self.E_TRANSACTION_VALIDATION_FAILED,
93-
"emptySkuList": Self.E_EMPTY_SKU_LIST,
90+
"ReceiptFailed": Self.E_RECEIPT_FAILED,
91+
"ReceiptFinished": Self.E_RECEIPT_FINISHED,
92+
"ReceiptFinishedFailed": Self.E_RECEIPT_FINISHED_FAILED,
93+
"TransactionValidationFailed": Self.E_TRANSACTION_VALIDATION_FAILED,
94+
"EmptySkuList": Self.E_EMPTY_SKU_LIST,
9495

9596
// Platform/Parsing Errors (extra parity)
96-
"billingResponseJsonParseError": Self.E_BILLING_RESPONSE_JSON_PARSE_ERROR,
97-
"activityUnavailable": Self.E_ACTIVITY_UNAVAILABLE,
97+
"BillingResponseJsonParseError": Self.E_BILLING_RESPONSE_JSON_PARSE_ERROR,
98+
"ActivityUnavailable": Self.E_ACTIVITY_UNAVAILABLE,
9899

99100
// State/Generic Errors (extra parity)
100-
"alreadyPrepared": Self.E_ALREADY_PREPARED,
101-
"pending": Self.E_PENDING,
102-
"purchaseError": Self.E_PURCHASE_ERROR,
101+
"AlreadyPrepared": Self.E_ALREADY_PREPARED,
102+
"Pending": Self.E_PENDING,
103+
"PurchaseError": Self.E_PURCHASE_ERROR,
103104

104105
// Generic Error
105-
"unknown": Self.E_UNKNOWN
106+
"Unknown": Self.E_UNKNOWN
106107
]
107108
}
108109
}
@@ -206,4 +207,3 @@ public extension OpenIapError {
206207
}
207208
}
208209
}
209-

0 commit comments

Comments
 (0)