@wix/himalaya-cli 0.1263.0 → 0.1265.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts +2 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-contract.d.ts +104 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments-wire.d.ts +44 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/wix-payments.d.ts +47 -0
- package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/iap.mjs +283 -10
- package/dist/cli.mjs +0 -1
- package/guides/sdk-reference.json +135 -0
- package/package.json +2 -2
package/dist/authoring-runtime/node_modules/@wix/himalaya/dist/_types/core/sdk/iap/src/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export * from "./catalog-pricing-contract.js";
|
|
|
7
7
|
export * from "./catalog-pricing.js";
|
|
8
8
|
export * from "./catalog-price-fields.js";
|
|
9
9
|
export * from "./catalog-adapters/online-programs.js";
|
|
10
|
+
export * from "./wix-payments-contract.js";
|
|
11
|
+
export * from "./wix-payments.js";
|
|
10
12
|
/** The three store product categories. */
|
|
11
13
|
export type ProductType = "subscription" | "nonConsumable" | "consumable";
|
|
12
14
|
export interface Product {
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { SessionSnapshot } from "./delivery-contract.js";
|
|
2
|
+
/** This Himalaya app's registration in the purchases service. Produced once by trusted
|
|
3
|
+
* provisioning, never by a worker; no production source exists yet. */
|
|
4
|
+
export interface PurchasesAppBinding {
|
|
5
|
+
/** The purchases service's app UUID (RegisterApp's `app.id`), which Payments calls `appId`. */
|
|
6
|
+
purchasesAppId: string;
|
|
7
|
+
himalayaAppId: string;
|
|
8
|
+
bundleId: string;
|
|
9
|
+
/** Wix metaSiteId the app was registered on. */
|
|
10
|
+
siteId: string;
|
|
11
|
+
}
|
|
12
|
+
export interface AppBindingSource {
|
|
13
|
+
/** Null when the app was never registered. */
|
|
14
|
+
current(): Promise<PurchasesAppBinding | null>;
|
|
15
|
+
}
|
|
16
|
+
/** The running app's own identity; a binding for anything else is refused. */
|
|
17
|
+
export interface IapAppHost {
|
|
18
|
+
appId: string;
|
|
19
|
+
bundleId: string;
|
|
20
|
+
siteId: string;
|
|
21
|
+
}
|
|
22
|
+
/** Where the Payments service is reachable through the Wix gateway. */
|
|
23
|
+
export interface WixIapRoute {
|
|
24
|
+
/** The gateway path that maps to the service's `/v1`, without a trailing slash. No public route
|
|
25
|
+
* was in the generated gateway metadata on 2026-10-08, so there is deliberately no default. */
|
|
26
|
+
prefix: string;
|
|
27
|
+
}
|
|
28
|
+
/** The host's Wix REST bridge (`himalaya.wixApi`). Resolves the parsed body of a 2xx and
|
|
29
|
+
* rejects with `HTTP <status> [<code>]: <message>` otherwise. Credentials are attached
|
|
30
|
+
* natively, never in TypeScript. */
|
|
31
|
+
export interface WixTransport {
|
|
32
|
+
call(method: "GET" | "POST", path: string, body?: unknown, headers?: Record<string, string>): Promise<unknown>;
|
|
33
|
+
}
|
|
34
|
+
/** Optional, from a trusted host only: the Wix member id signed in for a captured session. Used to
|
|
35
|
+
* refuse an answer about someone else, never sent: the server derives the member itself. */
|
|
36
|
+
export interface MemberIdentitySource {
|
|
37
|
+
memberId(session: SessionSnapshot): Promise<string | null>;
|
|
38
|
+
}
|
|
39
|
+
export type WixIapPaymentStatus = "pending" | "approving" | "approved" | "canceling" | "canceled" | "refunding" | "refunded";
|
|
40
|
+
/** One Wix Payments transaction being paid with a store purchase. `approving` means the server
|
|
41
|
+
* has claimed the purchase and is still reporting it: not paid, and no access. */
|
|
42
|
+
export interface WixIapPayment {
|
|
43
|
+
paymentId: string;
|
|
44
|
+
appId: string;
|
|
45
|
+
memberId: string;
|
|
46
|
+
wixTransactionId: string;
|
|
47
|
+
/** The store product the payment sells; absent until the server resolves one. */
|
|
48
|
+
appProductId?: string;
|
|
49
|
+
status: WixIapPaymentStatus;
|
|
50
|
+
cancelReason?: "expired" | "rejected";
|
|
51
|
+
/** The purchases service's record UUID, not Apple's transaction id. */
|
|
52
|
+
purchaseTransactionId?: string;
|
|
53
|
+
expiresDate?: string;
|
|
54
|
+
approvedDate?: string;
|
|
55
|
+
canceledDate?: string;
|
|
56
|
+
refundedDate?: string;
|
|
57
|
+
}
|
|
58
|
+
export type WixIapOperation = "startPayment" | "completePayment" | "getCustomerId" | "getPayment";
|
|
59
|
+
export type StartPaymentErrorCode = "NOT_PENDING" | "WRONG_PAYMENT_METHOD" | "NOT_ORDER_BUYER" | "UNSUPPORTED_ORDER" | "PRODUCT_NOT_AVAILABLE" | "ALREADY_OWNED";
|
|
60
|
+
export type CompletePaymentErrorCode = "INVALID_PURCHASE" | "OWNED_BY_ANOTHER_CUSTOMER" | "PURCHASE_REVOKED" | "NOT_PURCHASED" | "ZERO_PRICE" | "NO_MATCHING_PAYMENT" | "APP_NOT_CONFIGURED";
|
|
61
|
+
export type GetCustomerIdErrorCode = "APP_NOT_CONFIGURED";
|
|
62
|
+
export type GetPaymentErrorCode = "NOT_FOUND";
|
|
63
|
+
/** Why a call gave no usable answer, other than a named application error.
|
|
64
|
+
* `unavailable` and `sessionChanged` say nothing about whether the request took effect.
|
|
65
|
+
* `unrecognized` is an HTTP refusal this client cannot name: never treat it as terminal.
|
|
66
|
+
* `invalidArgument`, `environmentUnsupported`, `notProvisioned` and `authRequired` from a
|
|
67
|
+
* local check are decided before anything is sent. */
|
|
68
|
+
export type WixIapFailureKind = "notEnabled" | "notProvisioned" | "authRequired" | "notPermitted" | "invalidArgument" | "environmentUnsupported" | "sessionChanged" | "unavailable" | "unrecognized" | "invalidResponse";
|
|
69
|
+
/** A failure carries the operation, a kind, the service's own code when it named one, and the
|
|
70
|
+
* HTTP status when there was one. Never the server's message, the proof or a credential. */
|
|
71
|
+
export type WixIapFailure<Code extends string> = {
|
|
72
|
+
status: "failed";
|
|
73
|
+
operation: WixIapOperation;
|
|
74
|
+
kind: "application";
|
|
75
|
+
code: Code;
|
|
76
|
+
httpStatus: number;
|
|
77
|
+
} | {
|
|
78
|
+
status: "failed";
|
|
79
|
+
operation: WixIapOperation;
|
|
80
|
+
kind: WixIapFailureKind;
|
|
81
|
+
httpStatus?: number;
|
|
82
|
+
};
|
|
83
|
+
/** `customerId` goes to StoreKit as `appAccountToken` (the customer id is the token, D59). Keep it
|
|
84
|
+
* out of screen state. */
|
|
85
|
+
export type StartPaymentResult = {
|
|
86
|
+
status: "started";
|
|
87
|
+
payment: WixIapPayment;
|
|
88
|
+
storeProductId: string;
|
|
89
|
+
customerId: string;
|
|
90
|
+
} | WixIapFailure<StartPaymentErrorCode>;
|
|
91
|
+
/** `matched`: the server verified the proof and matched it to `payment`, which may not be the one
|
|
92
|
+
* this device started. Its status may still be `approving`. */
|
|
93
|
+
export type CompletePaymentResult = {
|
|
94
|
+
status: "matched";
|
|
95
|
+
payment: WixIapPayment;
|
|
96
|
+
} | WixIapFailure<CompletePaymentErrorCode>;
|
|
97
|
+
export type CustomerIdResult = {
|
|
98
|
+
status: "found";
|
|
99
|
+
customerId: string;
|
|
100
|
+
} | WixIapFailure<GetCustomerIdErrorCode>;
|
|
101
|
+
export type GetPaymentResult = {
|
|
102
|
+
status: "found";
|
|
103
|
+
payment: WixIapPayment;
|
|
104
|
+
} | WixIapFailure<GetPaymentErrorCode>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { PurchasesAppBinding, WixIapFailure, WixIapFailureKind, WixIapOperation, WixIapPayment } from "./wix-payments-contract.js";
|
|
2
|
+
export interface WixIapCall {
|
|
3
|
+
method: "GET" | "POST";
|
|
4
|
+
path: string;
|
|
5
|
+
body?: Record<string, unknown>;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export interface CallScope {
|
|
9
|
+
binding: PurchasesAppBinding;
|
|
10
|
+
prefix: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function startPaymentCall(scope: CallScope, wixTransactionId: string): WixIapCall;
|
|
13
|
+
/** The JWS goes byte-for-byte: the server derives the member, and the proof names the product. */
|
|
14
|
+
export declare function completePaymentCall(scope: CallScope, signedTransaction: string): WixIapCall;
|
|
15
|
+
export declare function customerIdCall(scope: CallScope): WixIapCall;
|
|
16
|
+
export declare function paymentCall(scope: CallScope, paymentId: string): WixIapCall;
|
|
17
|
+
/** A gateway path such as `/_api/<service>/v1`: absolute, no trailing slash, query or scheme. */
|
|
18
|
+
export declare function isRoutePrefix(prefix: string): boolean;
|
|
19
|
+
export interface PaymentExpectation {
|
|
20
|
+
appId: string;
|
|
21
|
+
/** Checked only when a trusted host supplied it. */
|
|
22
|
+
memberId: string | null;
|
|
23
|
+
paymentId?: string;
|
|
24
|
+
wixTransactionId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface StartedPayment {
|
|
27
|
+
payment: WixIapPayment;
|
|
28
|
+
storeProductId: string;
|
|
29
|
+
customerId: string;
|
|
30
|
+
}
|
|
31
|
+
export declare function decodeStarted(raw: unknown, expected: PaymentExpectation): StartedPayment | null;
|
|
32
|
+
/** CompletePayment's and GetPayment's answer: `{payment}`. */
|
|
33
|
+
export declare function decodePaymentAnswer(raw: unknown, expected: PaymentExpectation): WixIapPayment | null;
|
|
34
|
+
/** D59: the customer's id is the StoreKit `appAccountToken`; no other field may stand in for it. */
|
|
35
|
+
export declare function decodeCustomerId(raw: unknown): string | null;
|
|
36
|
+
/** Maps a bridge rejection to a failure. The message itself is never kept: the bridge copies up
|
|
37
|
+
* to 300 characters of the response, which can echo the request. */
|
|
38
|
+
export declare function classifyFailure<Code extends string>(error: unknown, operation: WixIapOperation, codes: readonly Code[]): WixIapFailure<Code>;
|
|
39
|
+
export declare function failure(operation: WixIapOperation, kind: WixIapFailureKind): {
|
|
40
|
+
status: "failed";
|
|
41
|
+
operation: WixIapOperation;
|
|
42
|
+
kind: WixIapFailureKind;
|
|
43
|
+
};
|
|
44
|
+
export declare function isUUID(value: unknown): value is string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AppleTransaction } from "./index.js";
|
|
2
|
+
import type { SessionProvider } from "./delivery-contract.js";
|
|
3
|
+
import type { AppBindingSource, CompletePaymentResult, CustomerIdResult, GetPaymentResult, IapAppHost, MemberIdentitySource, StartPaymentResult, WixIapRoute, WixTransport } from "./wix-payments-contract.js";
|
|
4
|
+
export interface WixIapClientDependencies {
|
|
5
|
+
/** The trusted host session; each call is bound to the generation current when it starts. */
|
|
6
|
+
session: SessionProvider;
|
|
7
|
+
binding: AppBindingSource;
|
|
8
|
+
host: IapAppHost;
|
|
9
|
+
route: WixIapRoute;
|
|
10
|
+
/** Defaults to the host's Wix REST bridge (`himalaya.wixApi`, capability `wix_api`). */
|
|
11
|
+
transport?: WixTransport;
|
|
12
|
+
/** Optional cross-check that every Payment answered is the signed-in member's own. */
|
|
13
|
+
identity?: MemberIdentitySource;
|
|
14
|
+
}
|
|
15
|
+
export interface WixIapClient {
|
|
16
|
+
/** StartPayment for a pending `appleIAP` Wix Payments transaction the member placed. Returns the
|
|
17
|
+
* store product to sell and the customer id to pass to StoreKit as `appAccountToken`. */
|
|
18
|
+
startPayment(input: {
|
|
19
|
+
wixTransactionId: string;
|
|
20
|
+
}): Promise<StartPaymentResult>;
|
|
21
|
+
/** CompletePayment with held Apple proof, sent unchanged. Success can still be `approving`. */
|
|
22
|
+
completePayment(transaction: AppleTransaction): Promise<CompletePaymentResult>;
|
|
23
|
+
/** GetCustomerId: the member's customer id, for recovering held purchases. Creates the customer
|
|
24
|
+
* when there is none. */
|
|
25
|
+
getCustomerId(): Promise<CustomerIdResult>;
|
|
26
|
+
/** GetPayment: one of the member's own Payments. */
|
|
27
|
+
getPayment(input: {
|
|
28
|
+
paymentId: string;
|
|
29
|
+
}): Promise<GetPaymentResult>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a client for Wix's in-app-purchase payments service (`mobile-apps-wix-iap`), which pays
|
|
33
|
+
* a Wix order with a store purchase the member makes in the app.
|
|
34
|
+
*
|
|
35
|
+
* NOT ENABLED and not production-ready. No app wires it, and no call reaches the service: it has
|
|
36
|
+
* no public gateway route yet, so `route` must be supplied and there is no default. It calls
|
|
37
|
+
* StartPayment (`POST …/payments/start`), CompletePayment (`POST …/payments/complete`),
|
|
38
|
+
* GetCustomerId (`GET …/customer-id`) and GetPayment (`GET …/payments/{id}`) through the
|
|
39
|
+
* `wix_api` bridge. A matched or approved Payment is not durable access and never finishes the
|
|
40
|
+
* store transaction.
|
|
41
|
+
*
|
|
42
|
+
* Production use is blocked on pending prerequisites: a public route and member authorization on
|
|
43
|
+
* the service, the service's own app identity and permissions, a trusted provisioning flow for the
|
|
44
|
+
* app binding, and a native bridge that binds each request to the session generation across
|
|
45
|
+
* authorization, send and retry. Its checks here protect only this client's own flow.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createWixIapClient(deps: WixIapClientDependencies): WixIapClient;
|
|
@@ -836,6 +836,278 @@ function onlineProgramItem(program, commerceDisplayPrice) {
|
|
|
836
836
|
return { reference: { kind: ONLINE_PROGRAM, id }, ...commerceDisplayPrice ? { commerceDisplayPrice } : {} };
|
|
837
837
|
}
|
|
838
838
|
|
|
839
|
+
// ../../core/sdk/iap/src/wix-payments-wire.ts
|
|
840
|
+
function startPaymentCall(scope, wixTransactionId) {
|
|
841
|
+
return post(scope, "/payments/start", { appId: scope.binding.purchasesAppId, wixTransactionId });
|
|
842
|
+
}
|
|
843
|
+
function completePaymentCall(scope, signedTransaction) {
|
|
844
|
+
return post(scope, "/payments/complete", { appId: scope.binding.purchasesAppId, apple: { signedTransaction } });
|
|
845
|
+
}
|
|
846
|
+
function customerIdCall(scope) {
|
|
847
|
+
return get(scope, `/customer-id?appId=${encodeURIComponent(scope.binding.purchasesAppId)}`);
|
|
848
|
+
}
|
|
849
|
+
function paymentCall(scope, paymentId) {
|
|
850
|
+
return get(scope, `/payments/${encodeURIComponent(paymentId)}`);
|
|
851
|
+
}
|
|
852
|
+
function isRoutePrefix(prefix) {
|
|
853
|
+
return /^\/[A-Za-z0-9._~\-/]*[A-Za-z0-9._~-]$/.test(prefix);
|
|
854
|
+
}
|
|
855
|
+
function decodeStarted(raw, expected) {
|
|
856
|
+
if (!isObject3(raw) || !isStoreProductId(raw.storeProductId) || !isUUID(raw.customerId)) return null;
|
|
857
|
+
const payment = decodePayment(raw.payment, expected);
|
|
858
|
+
return payment && { payment, storeProductId: raw.storeProductId, customerId: raw.customerId };
|
|
859
|
+
}
|
|
860
|
+
function decodePaymentAnswer(raw, expected) {
|
|
861
|
+
return isObject3(raw) ? decodePayment(raw.payment, expected) : null;
|
|
862
|
+
}
|
|
863
|
+
function decodeCustomerId(raw) {
|
|
864
|
+
return isObject3(raw) && isUUID(raw.customerId) ? raw.customerId : null;
|
|
865
|
+
}
|
|
866
|
+
function decodePayment(raw, expected) {
|
|
867
|
+
if (!isObject3(raw) || !hasPaymentIds(raw) || !echoes(raw, expected) || !hasValidOptionals(raw)) return null;
|
|
868
|
+
const status = ownValue(STATUSES, raw.status);
|
|
869
|
+
return status ? toPayment(raw, status) : null;
|
|
870
|
+
}
|
|
871
|
+
function hasPaymentIds(raw) {
|
|
872
|
+
return isUUID(raw.id) && isUUID(raw.appId) && isUUID(raw.memberId) && isUUID(raw.wixTransactionId);
|
|
873
|
+
}
|
|
874
|
+
function echoes(raw, expected) {
|
|
875
|
+
return sameUUID(raw.appId, expected.appId) && (expected.memberId === null || sameUUID(raw.memberId, expected.memberId)) && (expected.paymentId === void 0 || sameUUID(raw.id, expected.paymentId)) && (expected.wixTransactionId === void 0 || sameUUID(raw.wixTransactionId, expected.wixTransactionId));
|
|
876
|
+
}
|
|
877
|
+
function hasValidOptionals(raw) {
|
|
878
|
+
return (raw.appProductId === void 0 || isStoreProductId(raw.appProductId)) && (raw.purchaseTransactionId === void 0 || isUUID(raw.purchaseTransactionId)) && TIMESTAMPS.every((field) => raw[field] === void 0 || isTimestamp(raw[field]));
|
|
879
|
+
}
|
|
880
|
+
function toPayment(raw, status) {
|
|
881
|
+
const optional = {
|
|
882
|
+
appProductId: raw.appProductId,
|
|
883
|
+
cancelReason: ownValue(CANCEL_REASONS, raw.cancelReason),
|
|
884
|
+
purchaseTransactionId: raw.purchaseTransactionId,
|
|
885
|
+
expiresDate: raw.expiresDate,
|
|
886
|
+
approvedDate: raw.approvedDate,
|
|
887
|
+
canceledDate: raw.canceledDate,
|
|
888
|
+
refundedDate: raw.refundedDate
|
|
889
|
+
};
|
|
890
|
+
const ids = { paymentId: raw.id, appId: raw.appId, memberId: raw.memberId, wixTransactionId: raw.wixTransactionId };
|
|
891
|
+
return { ...ids, status, ...withoutUndefined(optional) };
|
|
892
|
+
}
|
|
893
|
+
function classifyFailure(error, operation, codes) {
|
|
894
|
+
const message = messageOf(error);
|
|
895
|
+
if (BRIDGE_REFUSAL.test(message)) return failure(operation, "notEnabled");
|
|
896
|
+
if (PRINCIPAL_CHANGED.test(message)) return failure(operation, "sessionChanged");
|
|
897
|
+
const http = /^HTTP (\d{3})(?: \[([^\]]+)\])?:/.exec(message);
|
|
898
|
+
if (!http) return failure(operation, "unavailable");
|
|
899
|
+
return classifyHttp({ operation, codes, httpStatus: Number(http[1]), code: http[2] ?? "" });
|
|
900
|
+
}
|
|
901
|
+
function failure(operation, kind) {
|
|
902
|
+
return { status: "failed", operation, kind };
|
|
903
|
+
}
|
|
904
|
+
function classifyHttp(refusal) {
|
|
905
|
+
const { operation, codes, httpStatus, code } = refusal;
|
|
906
|
+
if (code === "PRINCIPAL_CHANGED") return failure(operation, "sessionChanged");
|
|
907
|
+
if (isOneOf(codes, code)) return { status: "failed", operation, kind: "application", code, httpStatus };
|
|
908
|
+
return { status: "failed", operation, kind: kindForStatus(httpStatus, code), httpStatus };
|
|
909
|
+
}
|
|
910
|
+
function kindForStatus(httpStatus, code) {
|
|
911
|
+
if (code === "UNAVAILABLE" || httpStatus === 408 || httpStatus === 429 || httpStatus >= 500) return "unavailable";
|
|
912
|
+
if (httpStatus === 401 || code === "UNAUTHENTICATED") return "authRequired";
|
|
913
|
+
if (httpStatus === 403 || code === "PERMISSION_DENIED") return "notPermitted";
|
|
914
|
+
return "unrecognized";
|
|
915
|
+
}
|
|
916
|
+
function post(scope, route, body) {
|
|
917
|
+
return { method: "POST", path: `${scope.prefix}${route}`, body, headers: siteHeaders(scope.binding) };
|
|
918
|
+
}
|
|
919
|
+
function get(scope, route) {
|
|
920
|
+
return { method: "GET", path: `${scope.prefix}${route}`, headers: siteHeaders(scope.binding) };
|
|
921
|
+
}
|
|
922
|
+
function siteHeaders(binding) {
|
|
923
|
+
return { "wix-site-id": binding.siteId };
|
|
924
|
+
}
|
|
925
|
+
function messageOf(error) {
|
|
926
|
+
const message = error?.message;
|
|
927
|
+
return typeof message === "string" ? message : "";
|
|
928
|
+
}
|
|
929
|
+
function withoutUndefined(value) {
|
|
930
|
+
const kept = {};
|
|
931
|
+
for (const key of Object.keys(value)) {
|
|
932
|
+
if (value[key] !== void 0) kept[key] = value[key];
|
|
933
|
+
}
|
|
934
|
+
return kept;
|
|
935
|
+
}
|
|
936
|
+
function isOneOf(codes, code) {
|
|
937
|
+
return codes.includes(code);
|
|
938
|
+
}
|
|
939
|
+
function ownValue(table, key) {
|
|
940
|
+
return typeof key === "string" && Object.prototype.hasOwnProperty.call(table, key) ? table[key] : void 0;
|
|
941
|
+
}
|
|
942
|
+
function isObject3(value) {
|
|
943
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
944
|
+
}
|
|
945
|
+
function isUUID(value) {
|
|
946
|
+
return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value);
|
|
947
|
+
}
|
|
948
|
+
function sameUUID(value, expected) {
|
|
949
|
+
return isUUID(value) && value.toLowerCase() === expected.toLowerCase();
|
|
950
|
+
}
|
|
951
|
+
function isStoreProductId(value) {
|
|
952
|
+
return typeof value === "string" && value.length > 0 && value.length <= 255;
|
|
953
|
+
}
|
|
954
|
+
function isTimestamp(value) {
|
|
955
|
+
return typeof value === "string" && !Number.isNaN(Date.parse(value));
|
|
956
|
+
}
|
|
957
|
+
var STATUSES = {
|
|
958
|
+
PENDING: "pending",
|
|
959
|
+
APPROVING: "approving",
|
|
960
|
+
APPROVED: "approved",
|
|
961
|
+
CANCELING: "canceling",
|
|
962
|
+
CANCELED: "canceled",
|
|
963
|
+
REFUNDING: "refunding",
|
|
964
|
+
REFUNDED: "refunded"
|
|
965
|
+
};
|
|
966
|
+
var CANCEL_REASONS = { EXPIRED: "expired", REJECTED: "rejected" };
|
|
967
|
+
var TIMESTAMPS = ["createdDate", "updatedDate", "expiresDate", "approvedDate", "canceledDate", "refundedDate"];
|
|
968
|
+
var BRIDGE_REFUSAL = /^(wixApi not enabled|capability wix_api not allowed)\b|^NotInstalled\(\)$/;
|
|
969
|
+
var PRINCIPAL_CHANGED = /^PRINCIPAL_CHANGED\b/;
|
|
970
|
+
|
|
971
|
+
// ../../core/sdk/iap/src/wix-payments.ts
|
|
972
|
+
function createWixIapClient(deps) {
|
|
973
|
+
function startPayment(input) {
|
|
974
|
+
if (!isUUID(input.wixTransactionId)) return Promise.resolve(failure("startPayment", "invalidArgument"));
|
|
975
|
+
return run({
|
|
976
|
+
operation: "startPayment",
|
|
977
|
+
codes: START_PAYMENT_CODES,
|
|
978
|
+
request: (scope) => startPaymentCall(scope, input.wixTransactionId),
|
|
979
|
+
decode: (raw, scope) => {
|
|
980
|
+
const started = decodeStarted(raw, { ...expectationOf(scope), wixTransactionId: input.wixTransactionId });
|
|
981
|
+
return started && { status: "started", ...started };
|
|
982
|
+
}
|
|
983
|
+
});
|
|
984
|
+
}
|
|
985
|
+
function completePayment(transaction) {
|
|
986
|
+
const refusal = refuseProof(transaction);
|
|
987
|
+
if (refusal) return Promise.resolve(refusal);
|
|
988
|
+
return run({
|
|
989
|
+
operation: "completePayment",
|
|
990
|
+
codes: COMPLETE_PAYMENT_CODES,
|
|
991
|
+
request: (scope) => completePaymentCall(scope, transaction.signedTransaction),
|
|
992
|
+
decode: (raw, scope) => {
|
|
993
|
+
const payment = decodePaymentAnswer(raw, expectationOf(scope));
|
|
994
|
+
return payment && { status: "matched", payment };
|
|
995
|
+
}
|
|
996
|
+
});
|
|
997
|
+
}
|
|
998
|
+
function getCustomerId() {
|
|
999
|
+
return run({
|
|
1000
|
+
operation: "getCustomerId",
|
|
1001
|
+
codes: GET_CUSTOMER_ID_CODES,
|
|
1002
|
+
request: customerIdCall,
|
|
1003
|
+
decode: (raw) => {
|
|
1004
|
+
const customerId = decodeCustomerId(raw);
|
|
1005
|
+
return customerId ? { status: "found", customerId } : null;
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
function getPayment(input) {
|
|
1010
|
+
if (!isUUID(input.paymentId)) return Promise.resolve(failure("getPayment", "invalidArgument"));
|
|
1011
|
+
return run({
|
|
1012
|
+
operation: "getPayment",
|
|
1013
|
+
codes: GET_PAYMENT_CODES,
|
|
1014
|
+
request: (scope) => paymentCall(scope, input.paymentId),
|
|
1015
|
+
decode: (raw, scope) => {
|
|
1016
|
+
const payment = decodePaymentAnswer(raw, { ...expectationOf(scope), paymentId: input.paymentId });
|
|
1017
|
+
return payment && { status: "found", payment };
|
|
1018
|
+
}
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
async function run(spec) {
|
|
1022
|
+
const scope = await resolveScope(deps.session.current(), spec.operation);
|
|
1023
|
+
if ("failure" in scope) return scope.failure;
|
|
1024
|
+
const sent = await send(scope, spec);
|
|
1025
|
+
if ("failure" in sent) return sent.failure;
|
|
1026
|
+
return spec.decode(sent.answer, scope) ?? failure(spec.operation, "invalidResponse");
|
|
1027
|
+
}
|
|
1028
|
+
async function resolveScope(session, operation) {
|
|
1029
|
+
if (session.kind !== "member") return refused(operation, "authRequired");
|
|
1030
|
+
if (!isRoutePrefix(deps.route.prefix)) return refused(operation, "notProvisioned");
|
|
1031
|
+
const binding = await read(() => deps.binding.current(), operation);
|
|
1032
|
+
if ("failure" in binding) return binding;
|
|
1033
|
+
if (!binding.value || !isBindingFor(binding.value, deps.host)) return refused(operation, "notProvisioned");
|
|
1034
|
+
const member = await expectedMember(session, operation);
|
|
1035
|
+
if ("failure" in member) return member;
|
|
1036
|
+
return { session, binding: binding.value, prefix: deps.route.prefix, memberId: member.memberId };
|
|
1037
|
+
}
|
|
1038
|
+
async function expectedMember(session, operation) {
|
|
1039
|
+
const identity = deps.identity;
|
|
1040
|
+
if (!identity) return { memberId: null };
|
|
1041
|
+
const memberId = await read(() => identity.memberId(session), operation);
|
|
1042
|
+
if ("failure" in memberId) return memberId;
|
|
1043
|
+
return memberId.value ? { memberId: memberId.value } : refused(operation, "authRequired");
|
|
1044
|
+
}
|
|
1045
|
+
async function send(scope, spec) {
|
|
1046
|
+
const transport = deps.transport ?? bridgeTransport();
|
|
1047
|
+
if (!transport) return refused(spec.operation, "notEnabled");
|
|
1048
|
+
if (!isCurrent(scope.session)) return refused(spec.operation, "sessionChanged");
|
|
1049
|
+
const outcome = await attempt(transport, spec.request(scope), spec);
|
|
1050
|
+
return isCurrent(scope.session) ? outcome : refused(spec.operation, "sessionChanged");
|
|
1051
|
+
}
|
|
1052
|
+
function isCurrent(session) {
|
|
1053
|
+
return deps.session.current().generation === session.generation;
|
|
1054
|
+
}
|
|
1055
|
+
return { startPayment, completePayment, getCustomerId, getPayment };
|
|
1056
|
+
}
|
|
1057
|
+
async function attempt(transport, call, spec) {
|
|
1058
|
+
try {
|
|
1059
|
+
return { answer: await transport.call(call.method, call.path, call.body, call.headers) };
|
|
1060
|
+
} catch (error) {
|
|
1061
|
+
return { failure: classifyFailure(error, spec.operation, spec.codes) };
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
async function read(call, operation) {
|
|
1065
|
+
try {
|
|
1066
|
+
return { value: await call() };
|
|
1067
|
+
} catch (error) {
|
|
1068
|
+
return { failure: classifyFailure(error, operation, []) };
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
function refused(operation, kind) {
|
|
1072
|
+
return { failure: failure(operation, kind) };
|
|
1073
|
+
}
|
|
1074
|
+
function expectationOf(scope) {
|
|
1075
|
+
return { appId: scope.binding.purchasesAppId, memberId: scope.memberId };
|
|
1076
|
+
}
|
|
1077
|
+
function refuseProof(transaction) {
|
|
1078
|
+
if (transaction.environment !== "production" && transaction.environment !== "sandbox") return failure("completePayment", "environmentUnsupported");
|
|
1079
|
+
const signed = transaction.signedTransaction;
|
|
1080
|
+
return typeof signed === "string" && signed.length > 0 && signed.length <= MAX_SIGNED_TRANSACTION ? null : failure("completePayment", "invalidArgument");
|
|
1081
|
+
}
|
|
1082
|
+
function isBindingFor(binding, host) {
|
|
1083
|
+
return binding.himalayaAppId === host.appId && binding.bundleId === host.bundleId && binding.siteId === host.siteId;
|
|
1084
|
+
}
|
|
1085
|
+
function bridgeTransport() {
|
|
1086
|
+
const himalaya = globalThis.himalaya;
|
|
1087
|
+
const bridge = himalaya ? himalaya.wixApi : void 0;
|
|
1088
|
+
return typeof bridge?.call === "function" ? bridge : void 0;
|
|
1089
|
+
}
|
|
1090
|
+
var MAX_SIGNED_TRANSACTION = 2e4;
|
|
1091
|
+
var START_PAYMENT_CODES = [
|
|
1092
|
+
"NOT_PENDING",
|
|
1093
|
+
"WRONG_PAYMENT_METHOD",
|
|
1094
|
+
"NOT_ORDER_BUYER",
|
|
1095
|
+
"UNSUPPORTED_ORDER",
|
|
1096
|
+
"PRODUCT_NOT_AVAILABLE",
|
|
1097
|
+
"ALREADY_OWNED"
|
|
1098
|
+
];
|
|
1099
|
+
var COMPLETE_PAYMENT_CODES = [
|
|
1100
|
+
"INVALID_PURCHASE",
|
|
1101
|
+
"OWNED_BY_ANOTHER_CUSTOMER",
|
|
1102
|
+
"PURCHASE_REVOKED",
|
|
1103
|
+
"NOT_PURCHASED",
|
|
1104
|
+
"ZERO_PRICE",
|
|
1105
|
+
"NO_MATCHING_PAYMENT",
|
|
1106
|
+
"APP_NOT_CONFIGURED"
|
|
1107
|
+
];
|
|
1108
|
+
var GET_CUSTOMER_ID_CODES = ["APP_NOT_CONFIGURED"];
|
|
1109
|
+
var GET_PAYMENT_CODES = ["NOT_FOUND"];
|
|
1110
|
+
|
|
839
1111
|
// ../../core/sdk/iap/src/index.ts
|
|
840
1112
|
async function getPaywallConfig() {
|
|
841
1113
|
const r = await dispatch("capability.iap.getPaywallConfig");
|
|
@@ -883,7 +1155,7 @@ function normalizeStatus(s) {
|
|
|
883
1155
|
}
|
|
884
1156
|
var version = 2;
|
|
885
1157
|
async function purchaseForVerification(input) {
|
|
886
|
-
if (!nonempty2(input?.productId) || !
|
|
1158
|
+
if (!nonempty2(input?.productId) || !isUUID2(input?.appAccountToken)) return failure2("invalidArgument");
|
|
887
1159
|
const result = await managedDispatch(() => dispatch("capability.iap.purchaseForVerification", input));
|
|
888
1160
|
if (result?.status === "purchased" && isAppleTransaction(result.transaction)) {
|
|
889
1161
|
return { status: "purchased", transaction: decodeTransaction(result.transaction) };
|
|
@@ -899,31 +1171,31 @@ async function getUnfinishedTransactions() {
|
|
|
899
1171
|
return decodeFailure(result);
|
|
900
1172
|
}
|
|
901
1173
|
async function finishTransaction(input) {
|
|
902
|
-
if (!nonempty2(input?.transactionId)) return
|
|
1174
|
+
if (!nonempty2(input?.transactionId)) return failure2("invalidArgument");
|
|
903
1175
|
const result = await managedDispatch(() => dispatch("capability.iap.finishTransaction", input));
|
|
904
1176
|
if (result?.status === "finished" || result?.status === "notFound") return { status: result.status };
|
|
905
1177
|
return decodeFailure(result);
|
|
906
1178
|
}
|
|
907
1179
|
var appleManagedStore = { purchaseForVerification, getUnfinishedTransactions, finishTransaction };
|
|
908
1180
|
var transactionErrors = /* @__PURE__ */ new Set(["unsupported", "unavailable", "invalidArgument", "invalidResponse", "notEnabled", "unsupportedProductType", "unknownProduct", "verificationFailed", "persistenceFailed", "ownershipConflict", "storeError", "busy"]);
|
|
909
|
-
var
|
|
1181
|
+
var failure2 = (code) => ({ status: "failed", code });
|
|
910
1182
|
var nonempty2 = (value) => typeof value === "string" && value.trim().length > 0;
|
|
911
|
-
var
|
|
912
|
-
var
|
|
1183
|
+
var isUUID2 = (value) => typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value) && value.length === 36;
|
|
1184
|
+
var isObject4 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
913
1185
|
async function managedDispatch(invoke) {
|
|
914
1186
|
try {
|
|
915
1187
|
const value = await invoke();
|
|
916
|
-
return
|
|
1188
|
+
return isObject4(value) ? value : null;
|
|
917
1189
|
} catch {
|
|
918
|
-
return
|
|
1190
|
+
return failure2("unavailable");
|
|
919
1191
|
}
|
|
920
1192
|
}
|
|
921
1193
|
function decodeFailure(value) {
|
|
922
|
-
return value?.status === "failed" && transactionErrors.has(value.code) ?
|
|
1194
|
+
return value?.status === "failed" && transactionErrors.has(value.code) ? failure2(value.code) : failure2("invalidResponse");
|
|
923
1195
|
}
|
|
924
1196
|
function isAppleTransaction(value) {
|
|
925
|
-
if (!
|
|
926
|
-
return value.store === "apple" && typeof value.signedTransaction === "string" && /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.signedTransaction) && nonempty2(value.transactionId) && nonempty2(value.originalTransactionId) && nonempty2(value.productId) && (value.appAccountToken === null ||
|
|
1197
|
+
if (!isObject4(value)) return false;
|
|
1198
|
+
return value.store === "apple" && typeof value.signedTransaction === "string" && /^[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+$/.test(value.signedTransaction) && nonempty2(value.transactionId) && nonempty2(value.originalTransactionId) && nonempty2(value.productId) && (value.appAccountToken === null || isUUID2(value.appAccountToken)) && ["production", "sandbox", "xcode", "unknown"].includes(value.environment);
|
|
927
1199
|
}
|
|
928
1200
|
function decodeTransaction(value) {
|
|
929
1201
|
const { store, signedTransaction, transactionId, originalTransactionId, productId, appAccountToken, environment } = value;
|
|
@@ -938,6 +1210,7 @@ export {
|
|
|
938
1210
|
createIapCatalogPricing,
|
|
939
1211
|
createPricingController,
|
|
940
1212
|
createPurchaseCoordinator,
|
|
1213
|
+
createWixIapClient,
|
|
941
1214
|
entitlements,
|
|
942
1215
|
finishTransaction,
|
|
943
1216
|
getPaywallConfig,
|
package/dist/cli.mjs
CHANGED
|
@@ -6893,7 +6893,6 @@ function buttonVariant(style) {
|
|
|
6893
6893
|
var SYSTEM_FONT_FAMILY, TONAL_ELEVATION_ALPHA, BUTTON_MIN_HIT_TARGET, nonNegative, nonEmpty, own, COLOR_TOKEN_PROPS, TYPOGRAPHY_TOKEN_PROPS, BUTTON_VARIANTS;
|
|
6894
6894
|
var init_tokens = __esm({
|
|
6895
6895
|
"../../core/ts/src/tokens.ts"() {
|
|
6896
|
-
"use strict";
|
|
6897
6896
|
SYSTEM_FONT_FAMILY = "$system";
|
|
6898
6897
|
TONAL_ELEVATION_ALPHA = [0, 0.05, 0.08, 0.11, 0.12, 0.14];
|
|
6899
6898
|
BUTTON_MIN_HIT_TARGET = 44;
|
|
@@ -1879,6 +1879,141 @@
|
|
|
1879
1879
|
"jsdoc": "/** An Online Programs program as a shared IAP catalog item. A program without a Wix ID cannot be\n * mapped (a title fallback is not an identity), so it has no item and its screen shows no price. */",
|
|
1880
1880
|
"decl": "export function onlineProgramItem(program: { id?: string | null }, commerceDisplayPrice?: string): IapCatalogItem | undefined;"
|
|
1881
1881
|
},
|
|
1882
|
+
{
|
|
1883
|
+
"name": "PurchasesAppBinding",
|
|
1884
|
+
"kind": "interface",
|
|
1885
|
+
"jsdoc": "/** This Himalaya app's registration in the purchases service. Produced once by trusted\n * provisioning, never by a worker; no production source exists yet. */",
|
|
1886
|
+
"decl": "export interface PurchasesAppBinding {\n /** The purchases service's app UUID (RegisterApp's `app.id`), which Payments calls `appId`. */\n purchasesAppId: string;\n himalayaAppId: string;\n bundleId: string;\n /** Wix metaSiteId the app was registered on. */\n siteId: string;\n}"
|
|
1887
|
+
},
|
|
1888
|
+
{
|
|
1889
|
+
"name": "AppBindingSource",
|
|
1890
|
+
"kind": "interface",
|
|
1891
|
+
"jsdoc": "",
|
|
1892
|
+
"decl": "export interface AppBindingSource {\n /** Null when the app was never registered. */\n current(): Promise<PurchasesAppBinding | null>;\n}"
|
|
1893
|
+
},
|
|
1894
|
+
{
|
|
1895
|
+
"name": "IapAppHost",
|
|
1896
|
+
"kind": "interface",
|
|
1897
|
+
"jsdoc": "/** The running app's own identity; a binding for anything else is refused. */",
|
|
1898
|
+
"decl": "export interface IapAppHost {\n appId: string;\n bundleId: string;\n siteId: string;\n}"
|
|
1899
|
+
},
|
|
1900
|
+
{
|
|
1901
|
+
"name": "WixIapRoute",
|
|
1902
|
+
"kind": "interface",
|
|
1903
|
+
"jsdoc": "/** Where the Payments service is reachable through the Wix gateway. */",
|
|
1904
|
+
"decl": "export interface WixIapRoute {\n /** The gateway path that maps to the service's `/v1`, without a trailing slash. No public route\n * was in the generated gateway metadata on 2026-10-08, so there is deliberately no default. */\n prefix: string;\n}"
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
"name": "WixTransport",
|
|
1908
|
+
"kind": "interface",
|
|
1909
|
+
"jsdoc": "/** The host's Wix REST bridge (`himalaya.wixApi`). Resolves the parsed body of a 2xx and\n * rejects with `HTTP <status> [<code>]: <message>` otherwise. Credentials are attached\n * natively, never in TypeScript. */",
|
|
1910
|
+
"decl": "export interface WixTransport {\n call(method: \"GET\" | \"POST\", path: string, body?: unknown, headers?: Record<string, string>): Promise<unknown>;\n}"
|
|
1911
|
+
},
|
|
1912
|
+
{
|
|
1913
|
+
"name": "MemberIdentitySource",
|
|
1914
|
+
"kind": "interface",
|
|
1915
|
+
"jsdoc": "/** Optional, from a trusted host only: the Wix member id signed in for a captured session. Used to\n * refuse an answer about someone else, never sent: the server derives the member itself. */",
|
|
1916
|
+
"decl": "export interface MemberIdentitySource {\n memberId(session: SessionSnapshot): Promise<string | null>;\n}"
|
|
1917
|
+
},
|
|
1918
|
+
{
|
|
1919
|
+
"name": "WixIapPaymentStatus",
|
|
1920
|
+
"kind": "type",
|
|
1921
|
+
"jsdoc": "",
|
|
1922
|
+
"decl": "export type WixIapPaymentStatus = \"pending\" | \"approving\" | \"approved\" | \"canceling\" | \"canceled\" | \"refunding\" | \"refunded\";"
|
|
1923
|
+
},
|
|
1924
|
+
{
|
|
1925
|
+
"name": "WixIapPayment",
|
|
1926
|
+
"kind": "interface",
|
|
1927
|
+
"jsdoc": "/** One Wix Payments transaction being paid with a store purchase. `approving` means the server\n * has claimed the purchase and is still reporting it: not paid, and no access. */",
|
|
1928
|
+
"decl": "export interface WixIapPayment {\n paymentId: string;\n appId: string;\n memberId: string;\n wixTransactionId: string;\n /** The store product the payment sells; absent until the server resolves one. */\n appProductId?: string;\n status: WixIapPaymentStatus;\n cancelReason?: \"expired\" | \"rejected\";\n /** The purchases service's record UUID, not Apple's transaction id. */\n purchaseTransactionId?: string;\n expiresDate?: string;\n approvedDate?: string;\n canceledDate?: string;\n refundedDate?: string;\n}"
|
|
1929
|
+
},
|
|
1930
|
+
{
|
|
1931
|
+
"name": "WixIapOperation",
|
|
1932
|
+
"kind": "type",
|
|
1933
|
+
"jsdoc": "",
|
|
1934
|
+
"decl": "export type WixIapOperation = \"startPayment\" | \"completePayment\" | \"getCustomerId\" | \"getPayment\";"
|
|
1935
|
+
},
|
|
1936
|
+
{
|
|
1937
|
+
"name": "StartPaymentErrorCode",
|
|
1938
|
+
"kind": "type",
|
|
1939
|
+
"jsdoc": "",
|
|
1940
|
+
"decl": "export type StartPaymentErrorCode = \"NOT_PENDING\" | \"WRONG_PAYMENT_METHOD\" | \"NOT_ORDER_BUYER\" | \"UNSUPPORTED_ORDER\"\n | \"PRODUCT_NOT_AVAILABLE\" | \"ALREADY_OWNED\";"
|
|
1941
|
+
},
|
|
1942
|
+
{
|
|
1943
|
+
"name": "CompletePaymentErrorCode",
|
|
1944
|
+
"kind": "type",
|
|
1945
|
+
"jsdoc": "",
|
|
1946
|
+
"decl": "export type CompletePaymentErrorCode = \"INVALID_PURCHASE\" | \"OWNED_BY_ANOTHER_CUSTOMER\" | \"PURCHASE_REVOKED\"\n | \"NOT_PURCHASED\" | \"ZERO_PRICE\" | \"NO_MATCHING_PAYMENT\" | \"APP_NOT_CONFIGURED\";"
|
|
1947
|
+
},
|
|
1948
|
+
{
|
|
1949
|
+
"name": "GetCustomerIdErrorCode",
|
|
1950
|
+
"kind": "type",
|
|
1951
|
+
"jsdoc": "",
|
|
1952
|
+
"decl": "export type GetCustomerIdErrorCode = \"APP_NOT_CONFIGURED\";"
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
"name": "GetPaymentErrorCode",
|
|
1956
|
+
"kind": "type",
|
|
1957
|
+
"jsdoc": "",
|
|
1958
|
+
"decl": "export type GetPaymentErrorCode = \"NOT_FOUND\";"
|
|
1959
|
+
},
|
|
1960
|
+
{
|
|
1961
|
+
"name": "WixIapFailureKind",
|
|
1962
|
+
"kind": "type",
|
|
1963
|
+
"jsdoc": "/** Why a call gave no usable answer, other than a named application error.\n * `unavailable` and `sessionChanged` say nothing about whether the request took effect.\n * `unrecognized` is an HTTP refusal this client cannot name: never treat it as terminal.\n * `invalidArgument`, `environmentUnsupported`, `notProvisioned` and `authRequired` from a\n * local check are decided before anything is sent. */",
|
|
1964
|
+
"decl": "export type WixIapFailureKind = \"notEnabled\" | \"notProvisioned\" | \"authRequired\" | \"notPermitted\" | \"invalidArgument\"\n | \"environmentUnsupported\" | \"sessionChanged\" | \"unavailable\" | \"unrecognized\" | \"invalidResponse\";"
|
|
1965
|
+
},
|
|
1966
|
+
{
|
|
1967
|
+
"name": "WixIapFailure",
|
|
1968
|
+
"kind": "type",
|
|
1969
|
+
"jsdoc": "/** A failure carries the operation, a kind, the service's own code when it named one, and the\n * HTTP status when there was one. Never the server's message, the proof or a credential. */",
|
|
1970
|
+
"decl": "export type WixIapFailure<Code extends string> =\n | { status: \"failed\"; operation: WixIapOperation; kind: \"application\"; code: Code; httpStatus: number }\n | { status: \"failed\"; operation: WixIapOperation; kind: WixIapFailureKind; httpStatus?: number };"
|
|
1971
|
+
},
|
|
1972
|
+
{
|
|
1973
|
+
"name": "StartPaymentResult",
|
|
1974
|
+
"kind": "type",
|
|
1975
|
+
"jsdoc": "/** `customerId` goes to StoreKit as `appAccountToken` (the customer id is the token, D59). Keep it\n * out of screen state. */",
|
|
1976
|
+
"decl": "export type StartPaymentResult =\n | { status: \"started\"; payment: WixIapPayment; storeProductId: string; customerId: string }\n | WixIapFailure<StartPaymentErrorCode>;"
|
|
1977
|
+
},
|
|
1978
|
+
{
|
|
1979
|
+
"name": "CompletePaymentResult",
|
|
1980
|
+
"kind": "type",
|
|
1981
|
+
"jsdoc": "/** `matched`: the server verified the proof and matched it to `payment`, which may not be the one\n * this device started. Its status may still be `approving`. */",
|
|
1982
|
+
"decl": "export type CompletePaymentResult = { status: \"matched\"; payment: WixIapPayment } | WixIapFailure<CompletePaymentErrorCode>;"
|
|
1983
|
+
},
|
|
1984
|
+
{
|
|
1985
|
+
"name": "CustomerIdResult",
|
|
1986
|
+
"kind": "type",
|
|
1987
|
+
"jsdoc": "",
|
|
1988
|
+
"decl": "export type CustomerIdResult = { status: \"found\"; customerId: string } | WixIapFailure<GetCustomerIdErrorCode>;"
|
|
1989
|
+
},
|
|
1990
|
+
{
|
|
1991
|
+
"name": "GetPaymentResult",
|
|
1992
|
+
"kind": "type",
|
|
1993
|
+
"jsdoc": "",
|
|
1994
|
+
"decl": "export type GetPaymentResult = { status: \"found\"; payment: WixIapPayment } | WixIapFailure<GetPaymentErrorCode>;"
|
|
1995
|
+
},
|
|
1996
|
+
{
|
|
1997
|
+
"name": "WixIapClientDependencies",
|
|
1998
|
+
"kind": "interface",
|
|
1999
|
+
"jsdoc": "",
|
|
2000
|
+
"decl": "export interface WixIapClientDependencies {\n /** The trusted host session; each call is bound to the generation current when it starts. */\n session: SessionProvider;\n binding: AppBindingSource;\n host: IapAppHost;\n route: WixIapRoute;\n /** Defaults to the host's Wix REST bridge (`himalaya.wixApi`, capability `wix_api`). */\n transport?: WixTransport;\n /** Optional cross-check that every Payment answered is the signed-in member's own. */\n identity?: MemberIdentitySource;\n}",
|
|
2001
|
+
"verified": false
|
|
2002
|
+
},
|
|
2003
|
+
{
|
|
2004
|
+
"name": "WixIapClient",
|
|
2005
|
+
"kind": "interface",
|
|
2006
|
+
"jsdoc": "",
|
|
2007
|
+
"decl": "export interface WixIapClient {\n /** StartPayment for a pending `appleIAP` Wix Payments transaction the member placed. Returns the\n * store product to sell and the customer id to pass to StoreKit as `appAccountToken`. */\n startPayment(input: { wixTransactionId: string }): Promise<StartPaymentResult>;\n /** CompletePayment with held Apple proof, sent unchanged. Success can still be `approving`. */\n completePayment(transaction: AppleTransaction): Promise<CompletePaymentResult>;\n /** GetCustomerId: the member's customer id, for recovering held purchases. Creates the customer\n * when there is none. */\n getCustomerId(): Promise<CustomerIdResult>;\n /** GetPayment: one of the member's own Payments. */\n getPayment(input: { paymentId: string }): Promise<GetPaymentResult>;\n}",
|
|
2008
|
+
"verified": false
|
|
2009
|
+
},
|
|
2010
|
+
{
|
|
2011
|
+
"name": "createWixIapClient",
|
|
2012
|
+
"kind": "function",
|
|
2013
|
+
"jsdoc": "/**\n * Creates a client for Wix's in-app-purchase payments service (`mobile-apps-wix-iap`), which pays\n * a Wix order with a store purchase the member makes in the app.\n *\n * NOT ENABLED and not production-ready. No app wires it, and no call reaches the service: it has\n * no public gateway route yet, so `route` must be supplied and there is no default. It calls\n * StartPayment (`POST …/payments/start`), CompletePayment (`POST …/payments/complete`),\n * GetCustomerId (`GET …/customer-id`) and GetPayment (`GET …/payments/{id}`) through the\n * `wix_api` bridge. A matched or approved Payment is not durable access and never finishes the\n * store transaction.\n *\n * Production use is blocked on pending prerequisites: a public route and member authorization on\n * the service, the service's own app identity and permissions, a trusted provisioning flow for the\n * app binding, and a native bridge that binds each request to the session generation across\n * authorization, send and retry. Its checks here protect only this client's own flow.\n */",
|
|
2014
|
+
"decl": "export function createWixIapClient(deps: WixIapClientDependencies): WixIapClient;",
|
|
2015
|
+
"verified": false
|
|
2016
|
+
},
|
|
1882
2017
|
{
|
|
1883
2018
|
"name": "ProductType",
|
|
1884
2019
|
"kind": "type",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/himalaya-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1265.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "himi — the Himalaya authoring CLI. Build a Tier-5 content package on your own machine, push it to the production serve as a draft, preview it on web + Himi Player, and read worker logs back — the remote dev loop. Wraps @himalaya/serve-cli for transport.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"artifactId": "himalaya-cli"
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
|
-
"falconPackageHash": "
|
|
70
|
+
"falconPackageHash": "6529df3a98d5e1b19af7c9ec4915aad9ef742dd0e92f3bef6cbbe67b"
|
|
71
71
|
}
|