@devvit/payments 0.12.2-next-2025-10-29-22-34-10-21b07c31a.0 → 0.12.2-next-2025-10-30-14-40-48-f40144719.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/client/clientImportInServerCodePanic.d.ts +15 -0
- package/client/clientImportInServerCodePanic.d.ts.map +1 -0
- package/client/clientImportInServerCodePanic.js +15 -0
- package/client/index.d.ts +3 -0
- package/client/index.d.ts.map +1 -0
- package/client/index.js +1 -0
- package/client/purchase.d.ts +11 -0
- package/client/purchase.d.ts.map +1 -0
- package/client/purchase.js +28 -0
- package/package.json +11 -7
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hey! If you're seeing this, you're probably trying to run client code in the
|
|
3
|
+
* server context, or you have your client build environment set up incorrectly.
|
|
4
|
+
* To fix this:
|
|
5
|
+
* 1) Check that you're not importing client code in your server files. If you
|
|
6
|
+
* are, you should import from `@devvit/payments/server` instead of
|
|
7
|
+
* `@devvit/payments/client`.
|
|
8
|
+
* 2) If this is coming from client code, ensure that your server's tsconfig &
|
|
9
|
+
* build environment is set up correctly - specifically, make sure you set
|
|
10
|
+
* `compilerOptions.customConditions` to `["browser"]` in your `tsconfig.json`
|
|
11
|
+
* file. Also, verify that whatever bundler you're using (esbuild, vite, etc.)
|
|
12
|
+
* is bundling the server code for a web browser, and not a Node environment!
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=clientImportInServerCodePanic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientImportInServerCodePanic.d.ts","sourceRoot":"","sources":["../../src/client/clientImportInServerCodePanic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hey! If you're seeing this, you're probably trying to run client code in the
|
|
3
|
+
* server context, or you have your client build environment set up incorrectly.
|
|
4
|
+
* To fix this:
|
|
5
|
+
* 1) Check that you're not importing client code in your server files. If you
|
|
6
|
+
* are, you should import from `@devvit/payments/server` instead of
|
|
7
|
+
* `@devvit/payments/client`.
|
|
8
|
+
* 2) If this is coming from client code, ensure that your server's tsconfig &
|
|
9
|
+
* build environment is set up correctly - specifically, make sure you set
|
|
10
|
+
* `compilerOptions.customConditions` to `["browser"]` in your `tsconfig.json`
|
|
11
|
+
* file. Also, verify that whatever bundler you're using (esbuild, vite, etc.)
|
|
12
|
+
* is bundling the server code for a web browser, and not a Node environment!
|
|
13
|
+
*/
|
|
14
|
+
console.error("Can't import client code in the server!");
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAE,gBAAgB,EAAE,MAAM,oEAAoE,CAAC"}
|
package/client/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './purchase.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OrderResultEvent } from '@devvit/protos/json/devvit/ui/effect_types/v1alpha/create_order.js';
|
|
2
|
+
/**
|
|
3
|
+
* Initiates a purchase for one or more products.
|
|
4
|
+
*
|
|
5
|
+
* @param skuOrSkus - The SKU, or an array of SKUs, to purchase
|
|
6
|
+
* @param metadata - Optional, custom metadata attached to this purchase
|
|
7
|
+
*/
|
|
8
|
+
export declare function purchase(skuOrSkus: string | string[], metadata?: {
|
|
9
|
+
[key: string]: string;
|
|
10
|
+
}): Promise<OrderResultEvent>;
|
|
11
|
+
//# sourceMappingURL=purchase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"purchase.d.ts","sourceRoot":"","sources":["../../src/client/purchase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oEAAoE,CAAC;AAI3G;;;;;GAKG;AACH,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,EAC5B,QAAQ,CAAC,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GACnC,OAAO,CAAC,gBAAgB,CAAC,CAsB3B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { EffectType } from '@devvit/protos/json/devvit/ui/effects/v1alpha/effect.js';
|
|
2
|
+
import { emitEffect } from '@devvit/shared-types/client/emit-effect.js';
|
|
3
|
+
/**
|
|
4
|
+
* Initiates a purchase for one or more products.
|
|
5
|
+
*
|
|
6
|
+
* @param skuOrSkus - The SKU, or an array of SKUs, to purchase
|
|
7
|
+
* @param metadata - Optional, custom metadata attached to this purchase
|
|
8
|
+
*/
|
|
9
|
+
export async function purchase(skuOrSkus, metadata) {
|
|
10
|
+
const id = crypto.randomUUID();
|
|
11
|
+
const skus = typeof skuOrSkus === 'string' ? [skuOrSkus] : skuOrSkus;
|
|
12
|
+
const resp = await emitEffect({
|
|
13
|
+
createOrder: {
|
|
14
|
+
id,
|
|
15
|
+
skus,
|
|
16
|
+
metadata: metadata ?? {},
|
|
17
|
+
},
|
|
18
|
+
type: EffectType.EFFECT_CREATE_ORDER,
|
|
19
|
+
});
|
|
20
|
+
if (!resp) {
|
|
21
|
+
throw new Error(`Purchase didn't resolve correctly, got no response!`);
|
|
22
|
+
}
|
|
23
|
+
const result = resp.orderResult;
|
|
24
|
+
if (!result) {
|
|
25
|
+
throw new Error(`Purchase didn't resolve correctly, had no order result in the response!`);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/payments",
|
|
3
|
-
"version": "0.12.2-next-2025-10-
|
|
3
|
+
"version": "0.12.2-next-2025-10-30-14-40-48-f40144719.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
"type": "module",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": "./index.js",
|
|
12
|
+
"./client": {
|
|
13
|
+
"browser": "./client/index.js",
|
|
14
|
+
"default": "./client/clientImportInServerCodePanic.js"
|
|
15
|
+
},
|
|
12
16
|
"./helpers/*": {
|
|
13
17
|
"type": "./helpers/*.d.ts",
|
|
14
18
|
"import": "./helpers/*.js"
|
|
@@ -36,14 +40,14 @@
|
|
|
36
40
|
},
|
|
37
41
|
"types": "./dist/index.d.ts",
|
|
38
42
|
"dependencies": {
|
|
39
|
-
"@devvit/protos": "0.12.2-next-2025-10-
|
|
40
|
-
"@devvit/public-api": "0.12.2-next-2025-10-
|
|
41
|
-
"@devvit/shared-types": "0.12.2-next-2025-10-
|
|
43
|
+
"@devvit/protos": "0.12.2-next-2025-10-30-14-40-48-f40144719.0",
|
|
44
|
+
"@devvit/public-api": "0.12.2-next-2025-10-30-14-40-48-f40144719.0",
|
|
45
|
+
"@devvit/shared-types": "0.12.2-next-2025-10-30-14-40-48-f40144719.0"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
48
|
"@ampproject/filesize": "4.3.0",
|
|
45
|
-
"@devvit/repo-tools": "0.12.2-next-2025-10-
|
|
46
|
-
"@devvit/tsconfig": "0.12.2-next-2025-10-
|
|
49
|
+
"@devvit/repo-tools": "0.12.2-next-2025-10-30-14-40-48-f40144719.0",
|
|
50
|
+
"@devvit/tsconfig": "0.12.2-next-2025-10-30-14-40-48-f40144719.0",
|
|
47
51
|
"esbuild": "0.25.9",
|
|
48
52
|
"eslint": "9.11.1",
|
|
49
53
|
"typescript": "5.8.3",
|
|
@@ -56,5 +60,5 @@
|
|
|
56
60
|
}
|
|
57
61
|
},
|
|
58
62
|
"source": "./src/index.ts",
|
|
59
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "964ff5c474ae54b31a49d4ce51511cd63b826b58"
|
|
60
64
|
}
|