munim-billing 0.2.0 → 0.3.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/LICENSE +42 -201
- package/README.md +8 -27
- package/lib/cjs/index.js +2 -28
- package/lib/cjs/react-native.js +2 -118
- package/lib/cjs/web.js +2 -157
- package/lib/esm/chunks/57OHO4KT.js +2 -0
- package/lib/esm/client.d.ts +0 -1
- package/lib/esm/errors.d.ts +0 -1
- package/lib/esm/index.d.ts +0 -1
- package/lib/esm/index.js +2 -6
- package/lib/esm/react-native.d.ts +0 -1
- package/lib/esm/react-native.js +2 -114
- package/lib/esm/types.d.ts +0 -1
- package/lib/esm/version.d.ts +1 -2
- package/lib/esm/web.d.ts +0 -1
- package/lib/esm/web.js +2 -152
- package/lib/esm/webhooks.d.ts +0 -1
- package/package.json +5 -14
- package/lib/cjs/client.js +0 -233
- package/lib/cjs/client.js.map +0 -1
- package/lib/cjs/errors.js +0 -55
- package/lib/cjs/errors.js.map +0 -1
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/react-native.js.map +0 -1
- package/lib/cjs/types.js +0 -21
- package/lib/cjs/types.js.map +0 -1
- package/lib/cjs/version.js +0 -6
- package/lib/cjs/version.js.map +0 -1
- package/lib/cjs/web.js.map +0 -1
- package/lib/cjs/webhooks.js +0 -137
- package/lib/cjs/webhooks.js.map +0 -1
- package/lib/esm/client.d.ts.map +0 -1
- package/lib/esm/client.js +0 -226
- package/lib/esm/client.js.map +0 -1
- package/lib/esm/errors.d.ts.map +0 -1
- package/lib/esm/errors.js +0 -50
- package/lib/esm/errors.js.map +0 -1
- package/lib/esm/index.d.ts.map +0 -1
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/react-native.d.ts.map +0 -1
- package/lib/esm/react-native.js.map +0 -1
- package/lib/esm/types.d.ts.map +0 -1
- package/lib/esm/types.js +0 -18
- package/lib/esm/types.js.map +0 -1
- package/lib/esm/version.d.ts.map +0 -1
- package/lib/esm/version.js +0 -3
- package/lib/esm/version.js.map +0 -1
- package/lib/esm/web.d.ts.map +0 -1
- package/lib/esm/web.js.map +0 -1
- package/lib/esm/webhooks.d.ts.map +0 -1
- package/lib/esm/webhooks.js +0 -129
- package/lib/esm/webhooks.js.map +0 -1
- package/src/client.ts +0 -314
- package/src/errors.ts +0 -74
- package/src/index.ts +0 -26
- package/src/react-native.ts +0 -154
- package/src/types.ts +0 -366
- package/src/version.ts +0 -2
- package/src/web.ts +0 -182
- package/src/webhooks.ts +0 -169
package/LICENSE
CHANGED
|
@@ -1,201 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|
|
177
|
-
|
|
178
|
-
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
-
|
|
180
|
-
To apply the Apache License to your work, attach the following
|
|
181
|
-
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
-
replaced with your own identifying information. (Don't include
|
|
183
|
-
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
-
comment syntax for the file format. We also recommend that a
|
|
185
|
-
file or class name and description of purpose be included on the
|
|
186
|
-
same "printed page" as the copyright notice for easier
|
|
187
|
-
identification within third-party archives.
|
|
188
|
-
|
|
189
|
-
Copyright 2025 sheehanmunim
|
|
190
|
-
|
|
191
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
-
you may not use this file except in compliance with the License.
|
|
193
|
-
You may obtain a copy of the License at
|
|
194
|
-
|
|
195
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
-
|
|
197
|
-
Unless required by applicable law or agreed to in writing, software
|
|
198
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
-
See the License for the specific language governing permissions and
|
|
201
|
-
limitations under the License.
|
|
1
|
+
Munim Billing SDK License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Munim, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software (the "SDK") is licensed, not sold. Munim, Inc. ("Munim") grants
|
|
6
|
+
you a limited, non-exclusive, non-transferable, revocable license to install
|
|
7
|
+
and use the SDK, unmodified, solely to access and use the Munim Billing
|
|
8
|
+
service operated by Munim (including billing-api.munimtech.com and
|
|
9
|
+
billing-sandbox-api.munimtech.com), subject to the Munim Billing Seller Terms
|
|
10
|
+
at https://munimtech.com/billing/terms.
|
|
11
|
+
|
|
12
|
+
You may not, and may not permit anyone else to:
|
|
13
|
+
|
|
14
|
+
1. use the SDK, or any part of it, with any payment processor, billing
|
|
15
|
+
service, or backend other than the Munim Billing service;
|
|
16
|
+
2. copy, modify, adapt, translate, or create derivative works of the SDK,
|
|
17
|
+
except for copies made automatically by installing it as a dependency;
|
|
18
|
+
3. decompile, disassemble, reverse engineer, or attempt to derive the source
|
|
19
|
+
code, design, or protocols of the SDK or the Munim Billing service, except
|
|
20
|
+
to the extent applicable law expressly permits it despite this limitation;
|
|
21
|
+
4. copy or imitate the Munim Billing hosted checkout, its design, or its
|
|
22
|
+
integration with the SDK;
|
|
23
|
+
5. sell, sublicense, rent, lend, or distribute the SDK on its own, or
|
|
24
|
+
remove or alter any proprietary notices in it.
|
|
25
|
+
|
|
26
|
+
You may distribute the SDK only as an unmodified dependency of your own
|
|
27
|
+
application that uses the Munim Billing service.
|
|
28
|
+
|
|
29
|
+
All rights not expressly granted are reserved by Munim. This license ends
|
|
30
|
+
automatically if you breach it or stop using the Munim Billing service; you
|
|
31
|
+
must then stop using the SDK and delete it.
|
|
32
|
+
|
|
33
|
+
THE SDK IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
34
|
+
IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
35
|
+
PARTICULAR PURPOSE, AND NON-INFRINGEMENT. TO THE MAXIMUM EXTENT PERMITTED BY
|
|
36
|
+
LAW, MUNIM SHALL NOT BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
|
|
37
|
+
CONSEQUENTIAL, OR PUNITIVE DAMAGES, OR ANY LOSS OF PROFITS OR REVENUE,
|
|
38
|
+
ARISING OUT OF OR RELATED TO THE SDK.
|
|
39
|
+
|
|
40
|
+
Versions of this package published before 0.3.0 were withdrawn.
|
|
41
|
+
|
|
42
|
+
Questions: support@munimtech.com
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<!-- Banner Image -->
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
|
-
<a href="https://
|
|
4
|
+
<a href="https://munimtech.com/billing">
|
|
5
5
|
<h1 align="center">munim-billing</h1>
|
|
6
6
|
</a>
|
|
7
7
|
</p>
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
<a aria-label="Package version" href="https://www.npmjs.com/package/munim-billing" target="_blank">
|
|
11
11
|
<img alt="Package version" src="https://img.shields.io/npm/v/munim-billing.svg?style=flat-square&label=Version&labelColor=000000&color=0066CC" />
|
|
12
12
|
</a>
|
|
13
|
-
<a aria-label="
|
|
14
|
-
<img alt="License:
|
|
13
|
+
<a aria-label="License" href="https://www.npmjs.com/package/munim-billing?activeTab=code" target="_blank">
|
|
14
|
+
<img alt="License: Proprietary" src="https://img.shields.io/badge/License-Proprietary-000000.svg?style=flat-square" />
|
|
15
15
|
</a>
|
|
16
16
|
<a aria-label="package downloads" href="https://www.npmtrends.com/munim-billing" target="_blank">
|
|
17
17
|
<img alt="Downloads" src="https://img.shields.io/npm/dm/munim-billing.svg?style=flat-square&labelColor=gray&color=33CC12&label=Downloads" />
|
|
@@ -33,16 +33,13 @@
|
|
|
33
33
|
 • 
|
|
34
34
|
<a aria-label="dashboard" href="https://munimtech.com/billing/dashboard">Open the Dashboard</a>
|
|
35
35
|
 • 
|
|
36
|
-
<a aria-label="documentation" href="https://
|
|
36
|
+
<a aria-label="documentation" href="https://munimtech.com/billing">Read the Documentation</a>
|
|
37
37
|
 • 
|
|
38
|
-
<a aria-label="
|
|
38
|
+
<a aria-label="support" href="mailto:support@munimtech.com">Support</a>
|
|
39
39
|
</p>
|
|
40
40
|
|
|
41
41
|
<h6 align="center">Follow Munim Technologies</h6>
|
|
42
42
|
<p align="center">
|
|
43
|
-
<a aria-label="Follow Munim Technologies on GitHub" href="https://github.com/munimtechnologies" target="_blank">
|
|
44
|
-
<img alt="Munim Technologies on GitHub" src="https://img.shields.io/badge/GitHub-222222?style=for-the-badge&logo=github&logoColor=white" target="_blank" />
|
|
45
|
-
</a>
|
|
46
43
|
<a aria-label="Follow Munim Technologies on LinkedIn" href="https://linkedin.com/in/sheehanmunim" target="_blank">
|
|
47
44
|
<img alt="Munim Technologies on LinkedIn" src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" target="_blank" />
|
|
48
45
|
</a>
|
|
@@ -75,12 +72,11 @@ See your sales, customers, subscriptions, API keys, webhooks and payouts in the
|
|
|
75
72
|
- [🪝 Webhooks](#-webhooks)
|
|
76
73
|
- [📖 Usage Examples](#-usage-examples)
|
|
77
74
|
- [🔍 Troubleshooting](#-troubleshooting)
|
|
78
|
-
- [👏 Contributing](#-contributing)
|
|
79
75
|
- [📄 License](#-license)
|
|
80
76
|
|
|
81
77
|
## 📚 Documentation
|
|
82
78
|
|
|
83
|
-
<p>Learn how to sell with Munim Billing <a aria-label="documentation" href="https://
|
|
79
|
+
<p>Learn how to sell with Munim Billing <a aria-label="documentation" href="https://munimtech.com/billing">in our documentation!</a></p>
|
|
84
80
|
|
|
85
81
|
- [Getting Started](#-installation)
|
|
86
82
|
- [API Reference](#-api-reference)
|
|
@@ -529,23 +525,8 @@ for await (const txn of munim.transactions.list.all({ limit: 100 })) {
|
|
|
529
525
|
2. **It opens in the browser instead of a sheet**: install `expo-web-browser` (`npx expo install expo-web-browser`), or pass it as `webBrowser`.
|
|
530
526
|
3. **Don't trust the return URL alone**: it only says the customer came back. Grant access from the `transaction.completed` webhook, or check `munim.checkouts.retrieve(checkoutId)` on your server.
|
|
531
527
|
|
|
532
|
-
## 👏 Contributing
|
|
533
|
-
|
|
534
|
-
We welcome contributions! Open an issue or a pull request on [GitHub](https://github.com/munimtechnologies/munim-billing).
|
|
535
|
-
|
|
536
|
-
```bash
|
|
537
|
-
npm install
|
|
538
|
-
npm run typecheck
|
|
539
|
-
npm test # Vitest: client requests, pagination, webhooks, web overlay, React Native returns
|
|
540
|
-
npm run build # ESM (lib/esm) + CommonJS (lib/cjs)
|
|
541
|
-
```
|
|
542
|
-
|
|
543
528
|
## 📄 License
|
|
544
529
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
---
|
|
530
|
+
Copyright © 2026 Munim, Inc. All rights reserved.
|
|
548
531
|
|
|
549
|
-
|
|
550
|
-
<img alt="Enjoying Munim Technologies? Star the repo on GitHub" src="./.github/resources/star-repo.svg" width="50%">
|
|
551
|
-
</a>
|
|
532
|
+
The SDK is licensed for use only with the Munim Billing service, under the Munim Billing SDK License in [LICENSE](LICENSE) and the [Munim Billing Seller Terms](https://munimtech.com/billing/terms). Copying, modifying, reverse engineering, or using it with another payment provider is not permitted.
|
package/lib/cjs/index.js
CHANGED
|
@@ -1,28 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(
|
|
3
|
-
exports.VERSION = exports.EVENT_TYPES = exports.DEFAULT_TOLERANCE_SECONDS = exports.EVENT_ID_HEADER = exports.SIGNATURE_HEADER = exports.webhooks = exports.timingSafeEqual = exports.parseSignatureHeader = exports.computeSignature = exports.signWebhookPayload = exports.verifyWebhook = exports.errorFromResponse = exports.MunimBillingError = exports.TEST_BASE_URL = exports.LIVE_BASE_URL = exports.paginate = exports.modeForKey = exports.baseUrlForKey = exports.MunimBilling = void 0;
|
|
4
|
-
var client_js_1 = require("./client.js");
|
|
5
|
-
Object.defineProperty(exports, "MunimBilling", { enumerable: true, get: function () { return client_js_1.MunimBilling; } });
|
|
6
|
-
Object.defineProperty(exports, "baseUrlForKey", { enumerable: true, get: function () { return client_js_1.baseUrlForKey; } });
|
|
7
|
-
Object.defineProperty(exports, "modeForKey", { enumerable: true, get: function () { return client_js_1.modeForKey; } });
|
|
8
|
-
Object.defineProperty(exports, "paginate", { enumerable: true, get: function () { return client_js_1.paginate; } });
|
|
9
|
-
Object.defineProperty(exports, "LIVE_BASE_URL", { enumerable: true, get: function () { return client_js_1.LIVE_BASE_URL; } });
|
|
10
|
-
Object.defineProperty(exports, "TEST_BASE_URL", { enumerable: true, get: function () { return client_js_1.TEST_BASE_URL; } });
|
|
11
|
-
var errors_js_1 = require("./errors.js");
|
|
12
|
-
Object.defineProperty(exports, "MunimBillingError", { enumerable: true, get: function () { return errors_js_1.MunimBillingError; } });
|
|
13
|
-
Object.defineProperty(exports, "errorFromResponse", { enumerable: true, get: function () { return errors_js_1.errorFromResponse; } });
|
|
14
|
-
var webhooks_js_1 = require("./webhooks.js");
|
|
15
|
-
Object.defineProperty(exports, "verifyWebhook", { enumerable: true, get: function () { return webhooks_js_1.verifyWebhook; } });
|
|
16
|
-
Object.defineProperty(exports, "signWebhookPayload", { enumerable: true, get: function () { return webhooks_js_1.signWebhookPayload; } });
|
|
17
|
-
Object.defineProperty(exports, "computeSignature", { enumerable: true, get: function () { return webhooks_js_1.computeSignature; } });
|
|
18
|
-
Object.defineProperty(exports, "parseSignatureHeader", { enumerable: true, get: function () { return webhooks_js_1.parseSignatureHeader; } });
|
|
19
|
-
Object.defineProperty(exports, "timingSafeEqual", { enumerable: true, get: function () { return webhooks_js_1.timingSafeEqual; } });
|
|
20
|
-
Object.defineProperty(exports, "webhooks", { enumerable: true, get: function () { return webhooks_js_1.webhooks; } });
|
|
21
|
-
Object.defineProperty(exports, "SIGNATURE_HEADER", { enumerable: true, get: function () { return webhooks_js_1.SIGNATURE_HEADER; } });
|
|
22
|
-
Object.defineProperty(exports, "EVENT_ID_HEADER", { enumerable: true, get: function () { return webhooks_js_1.EVENT_ID_HEADER; } });
|
|
23
|
-
Object.defineProperty(exports, "DEFAULT_TOLERANCE_SECONDS", { enumerable: true, get: function () { return webhooks_js_1.DEFAULT_TOLERANCE_SECONDS; } });
|
|
24
|
-
var types_js_1 = require("./types.js");
|
|
25
|
-
Object.defineProperty(exports, "EVENT_TYPES", { enumerable: true, get: function () { return types_js_1.EVENT_TYPES; } });
|
|
26
|
-
var version_js_1 = require("./version.js");
|
|
27
|
-
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_js_1.VERSION; } });
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
/*! munim-billing © Munim, Inc. All rights reserved. Use is subject to the Munim Billing SDK License (LICENSE). */
|
|
2
|
+
"use strict";var j=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var et=Object.getOwnPropertyNames;var rt=Object.prototype.hasOwnProperty;var Q=e=>{throw TypeError(e)};var nt=(e,t)=>{for(var r in t)j(e,r,{get:t[r],enumerable:!0})},it=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of et(t))!rt.call(e,o)&&o!==r&&j(e,o,{get:()=>t[o],enumerable:!(n=tt(t,o))||n.enumerable});return e};var st=e=>it(j({},"__esModule",{value:!0}),e);var $=(e,t,r)=>t.has(e)||Q("Cannot "+r);var _=(e,t,r)=>($(e,t,"read from private field"),r?r.call(e):t.get(e)),P=(e,t,r)=>t.has(e)?Q("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),L=(e,t,r,n)=>($(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r),s=(e,t,r)=>($(e,t,"access private method"),r);var pt={};nt(pt,{DEFAULT_TOLERANCE_SECONDS:()=>q,EVENT_ID_HEADER:()=>N,EVENT_TYPES:()=>X,LIVE_BASE_URL:()=>D,MunimBilling:()=>w,MunimBillingError:()=>a,SIGNATURE_HEADER:()=>x,TEST_BASE_URL:()=>V,VERSION:()=>R,baseUrlForKey:()=>H,computeSignature:()=>S,errorFromResponse:()=>A,modeForKey:()=>B,paginate:()=>G,parseSignatureHeader:()=>O,signWebhookPayload:()=>I,timingSafeEqual:()=>F,verifyWebhook:()=>W,webhooks:()=>E});module.exports=st(pt);var a=class extends Error{constructor(t,r){super(t),this.name="MunimBillingError",this.type=r.type,this.status=r.status??null,this.param=r.param??null,r.cause!==void 0&&(this.cause=r.cause)}},ot=new Set(["invalid_request","authentication","not_found","conflict","processor","internal"]);function at(e){return e===401||e===403?"authentication":e===404?"not_found":e===409?"conflict":e===402||e===502?"processor":e>=500?"internal":"invalid_request"}function A(e,t){let r=t&&typeof t=="object"&&"error"in t?t.error:void 0,n=r?.type&&ot.has(r.type)?r.type:at(e);return new a(r?.message||`Munim Billing request failed with status ${e}`,{type:n,status:e,param:r?.param??null})}var R="0.3.0";var x="Munim-Signature",N="Munim-Event-Id",q=300,Y=new TextEncoder;function K(){let e=globalThis.crypto?.subtle;if(!e)throw new a("Web Crypto (crypto.subtle) is not available in this runtime. Use Node 20+ or another runtime with WebCrypto.",{type:"internal"});return e}function ut(e){return Array.from(new Uint8Array(e),t=>t.toString(16).padStart(2,"0")).join("")}function z(e){return typeof e=="string"?e:new TextDecoder().decode(e)}async function S(e,t,r){let n=await K().importKey("raw",Y.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"]),o=await K().sign("HMAC",n,Y.encode(`${r}.${z(t)}`));return ut(o)}async function I(e,t,r=Math.floor(Date.now()/1e3)){let n=Math.floor(r);return`t=${n},v1=${await S(e,t,n)}`}function O(e){let t=null,r=[];for(let n of e.split(",")){let o=n.indexOf("=");if(o<0)continue;let d=n.slice(0,o).trim(),l=n.slice(o+1).trim();d==="t"&&/^\d+$/.test(l)?t=Number(l):d==="v1"&&l&&r.push(l.toLowerCase())}return{timestamp:t,signatures:r}}function F(e,t){if(e.length!==t.length)return!1;let r=0;for(let n=0;n<e.length;n++)r|=e.charCodeAt(n)^t.charCodeAt(n);return r===0}function v(e){throw new a(e,{type:"signature_verification",status:400})}async function W(e,t,r,n={}){r||v("No webhook secret was given."),t||v(`Missing ${x} header.`);let{timestamp:o,signatures:d}=O(t);(o===null||d.length===0)&&v(`Malformed ${x} header.`);let l=await S(r,e,o);d.some(m=>F(m,l))||v("Webhook signature does not match. Check the secret and that the body is the raw, unparsed request body.");let g=n.toleranceSeconds??q;if(g>0){let m=Math.floor((n.now??Date.now())/1e3);Math.abs(m-o)>g&&v("Webhook timestamp is outside the tolerance.")}try{return JSON.parse(z(e))}catch(m){throw new a("Webhook body is not valid JSON.",{type:"signature_verification",status:400,cause:m})}}var E={verify:W,sign:I,computeSignature:S,parseHeader:O,SIGNATURE_HEADER:x,EVENT_ID_HEADER:N};var D="https://billing-api.munimtech.com",V="https://billing-sandbox-api.munimtech.com";function B(e){return e.startsWith("mb_test_")?"test":e.startsWith("mb_live_")?"live":null}function H(e){let t=B(e);if(t==="test")return V;if(t==="live")return D;throw new a("Munim Billing secret keys start with mb_test_sk_ or mb_live_sk_. Find yours at https://munimtech.com/billing/dashboard.",{type:"authentication"})}async function*G(e,t={}){let r=t.cursor;for(;;){let n=await e({...t,cursor:r});for(let o of n.data)yield o;if(!n.has_more||!n.next_cursor)return;r=n.next_cursor}}function y(e){let t=(r=>e(r??{}));return t.all=r=>G(e,r??{}),t}function ct(){let e=globalThis;return typeof e.window<"u"&&typeof e.document<"u"||e.navigator?.product==="ReactNative"}function c(e){if(!e)throw new a("An id is required.",{type:"invalid_request",param:"id"});return encodeURIComponent(e)}var T,k,b,i,u,p,w=class{constructor(t,r={}){P(this,i);this.webhooks=E;P(this,T);P(this,k);P(this,b);this.products={create:t=>s(this,i,p).call(this,"/v1/products",t),list:y(t=>s(this,i,u).call(this,"/v1/products",t)),retrieve:t=>s(this,i,u).call(this,`/v1/products/${c(t)}`),update:(t,r)=>s(this,i,p).call(this,`/v1/products/${c(t)}`,r)};this.prices={create:t=>s(this,i,p).call(this,"/v1/prices",t),list:y(t=>s(this,i,u).call(this,"/v1/prices",t)),retrieve:t=>s(this,i,u).call(this,`/v1/prices/${c(t)}`),update:(t,r)=>s(this,i,p).call(this,`/v1/prices/${c(t)}`,r)};this.checkouts={create:t=>s(this,i,p).call(this,"/v1/checkouts",t),retrieve:t=>s(this,i,u).call(this,`/v1/checkouts/${c(t)}`)};this.customers={list:y(t=>s(this,i,u).call(this,"/v1/customers",t)),retrieve:t=>s(this,i,u).call(this,`/v1/customers/${c(t)}`)};this.transactions={list:y(t=>s(this,i,u).call(this,"/v1/transactions",t)),retrieve:t=>s(this,i,u).call(this,`/v1/transactions/${c(t)}`),refund:(t,r={})=>s(this,i,p).call(this,`/v1/transactions/${c(t)}/refund`,r)};this.subscriptions={list:y(t=>s(this,i,u).call(this,"/v1/subscriptions",t)),retrieve:t=>s(this,i,u).call(this,`/v1/subscriptions/${c(t)}`),cancel:(t,r={})=>s(this,i,p).call(this,`/v1/subscriptions/${c(t)}/cancel`,r),manageUrl:t=>s(this,i,p).call(this,`/v1/subscriptions/${c(t)}/manage_url`)};this.balance={retrieve:()=>s(this,i,u).call(this,"/v1/balance")};this.payouts={list:y(t=>s(this,i,u).call(this,"/v1/payouts",t))};this.subscribers={retrieve:t=>s(this,i,u).call(this,`/v1/subscribers/${c(t)}`)};this.receipts={apple:t=>s(this,i,p).call(this,"/v1/receipts/apple",t),google:t=>s(this,i,p).call(this,"/v1/receipts/google",t)};this.storeSubscriptions={list:y(t=>s(this,i,u).call(this,"/v1/store_subscriptions",t))};this.entitlements={list:()=>s(this,i,u).call(this,"/v1/entitlements")};if(!t||typeof t!="string")throw new a("A Munim Billing secret key is required.",{type:"authentication"});if(!r.dangerouslyAllowBrowser&&ct())throw new a("MunimBilling uses your secret key and must run on your server. In a browser or app, create the checkout on your server and open its url with munim-billing/web or munim-billing/react-native.",{type:"invalid_request"});L(this,T,t),this.mode=B(t),this.baseUrl=(r.baseUrl??H(t)).replace(/\/+$/,"");let n=r.fetch??globalThis.fetch;if(!n)throw new a("No fetch is available. Pass one with options.fetch.",{type:"internal"});L(this,k,n),L(this,b,r.timeoutMs??3e4)}async request(t,r,n={}){let o=`${this.baseUrl}${r}`;if(n.query){let C=new URLSearchParams;for(let[Z,U]of Object.entries(n.query))U!=null&&C.append(Z,String(U));let M=C.toString();M&&(o+=`?${M}`)}let d={Authorization:`Bearer ${_(this,T)}`,Accept:"application/json","Munim-Billing-Client":`munim-billing-js/${R}`},l;t==="POST"&&(d["Content-Type"]="application/json",l=JSON.stringify(n.body??{}));let g=typeof AbortController<"u"?new AbortController:void 0,m=g?setTimeout(()=>g.abort(),_(this,b)):void 0,h;try{h=await _(this,k).call(this,o,{method:t,headers:d,body:l,signal:g?.signal})}catch(C){let M=g?.signal.aborted;throw new a(M?`Munim Billing request timed out after ${_(this,b)} ms.`:"Could not reach Munim Billing.",{type:"connection",cause:C})}finally{m&&clearTimeout(m)}let J=await h.text(),f;if(J)try{f=JSON.parse(J)}catch{f=void 0}if(!h.ok)throw A(h.status,f);if(f===void 0)throw new a("Munim Billing returned a response that is not JSON.",{type:"internal",status:h.status});return f}};T=new WeakMap,k=new WeakMap,b=new WeakMap,i=new WeakSet,u=function(t,r){return this.request("GET",t,{query:r})},p=function(t,r){return this.request("POST",t,{body:r})},w.webhooks=E;var X=["checkout.completed","transaction.completed","transaction.refunded","transaction.disputed","subscription.created","subscription.updated","subscription.canceled","payout.paid","payout.failed"];
|
package/lib/cjs/react-native.js
CHANGED
|
@@ -1,118 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* munim-billing/react-native: open a Munim checkout from a React Native or
|
|
4
|
-
* Expo app.
|
|
5
|
-
*
|
|
6
|
-
* The checkout opens in an in-app sheet (ASWebAuthenticationSession on iOS,
|
|
7
|
-
* a Custom Tab on Android) through `expo-web-browser`, the same kind of
|
|
8
|
-
* sheet munim-venmo uses. The sheet closes when the checkout redirects to
|
|
9
|
-
* your app's scheme, so create the checkout **on your server** with
|
|
10
|
-
* `success_url` and `cancel_url` set to that scheme:
|
|
11
|
-
*
|
|
12
|
-
* success_url: 'myapp://billing/done'
|
|
13
|
-
* cancel_url: 'myapp://billing/canceled'
|
|
14
|
-
*
|
|
15
|
-
* Never ship your secret key in an app.
|
|
16
|
-
*/
|
|
17
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.parseCheckoutReturnUrl = parseCheckoutReturnUrl;
|
|
19
|
-
exports.openCheckout = openCheckout;
|
|
20
|
-
function loadWebBrowser() {
|
|
21
|
-
try {
|
|
22
|
-
// Optional peer dependency, looked up only when it's needed.
|
|
23
|
-
const mod = (typeof require === 'function' ? require('expo-web-browser') : undefined);
|
|
24
|
-
return mod && typeof mod.openAuthSessionAsync === 'function' ? mod : null;
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function loadLinking() {
|
|
31
|
-
try {
|
|
32
|
-
const mod = (typeof require === 'function' ? require('react-native') : undefined);
|
|
33
|
-
return mod?.Linking ?? null;
|
|
34
|
-
}
|
|
35
|
-
catch {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
/** Reads a URL's query (and fragment) without `URL.searchParams`, which React Native doesn't implement. */
|
|
40
|
-
function queryParams(url) {
|
|
41
|
-
const params = new Map();
|
|
42
|
-
const start = url.indexOf('?');
|
|
43
|
-
const hash = url.indexOf('#');
|
|
44
|
-
const parts = [];
|
|
45
|
-
if (start >= 0)
|
|
46
|
-
parts.push(url.slice(start + 1, hash > start ? hash : undefined));
|
|
47
|
-
if (hash >= 0)
|
|
48
|
-
parts.push(url.slice(hash + 1));
|
|
49
|
-
for (const part of parts) {
|
|
50
|
-
for (const pair of part.split('&')) {
|
|
51
|
-
if (!pair)
|
|
52
|
-
continue;
|
|
53
|
-
const eq = pair.indexOf('=');
|
|
54
|
-
const rawKey = eq >= 0 ? pair.slice(0, eq) : pair;
|
|
55
|
-
const rawValue = eq >= 0 ? pair.slice(eq + 1) : '';
|
|
56
|
-
try {
|
|
57
|
-
const key = decodeURIComponent(rawKey.replace(/\+/g, ' ')).toLowerCase();
|
|
58
|
-
if (!params.has(key))
|
|
59
|
-
params.set(key, decodeURIComponent(rawValue.replace(/\+/g, ' ')));
|
|
60
|
-
}
|
|
61
|
-
catch {
|
|
62
|
-
// A malformed escape: skip that pair.
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return params;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Reads the URL the checkout returned to. `checkout_id` means it was paid;
|
|
70
|
-
* `canceled=true` (or no `checkout_id`) means it wasn't.
|
|
71
|
-
*/
|
|
72
|
-
function parseCheckoutReturnUrl(url) {
|
|
73
|
-
const params = queryParams(url);
|
|
74
|
-
const checkoutId = params.get('checkout_id') || undefined;
|
|
75
|
-
const canceled = params.get('canceled') ?? params.get('cancelled');
|
|
76
|
-
if (canceled === 'true' || canceled === '1' || !checkoutId) {
|
|
77
|
-
return checkoutId ? { status: 'canceled', checkoutId } : { status: 'canceled' };
|
|
78
|
-
}
|
|
79
|
-
return { status: 'completed', checkoutId };
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Opens a checkout `url` (from `munim.checkouts.create` on your server) in an
|
|
83
|
-
* in-app sheet and resolves when the customer comes back.
|
|
84
|
-
*
|
|
85
|
-
* - `completed`: the checkout redirected to your `success_url`. Confirm on
|
|
86
|
-
* your server (the `checkout.completed` webhook, or
|
|
87
|
-
* `munim.checkouts.retrieve(checkoutId)`) before granting anything.
|
|
88
|
-
* - `canceled`: the customer closed the sheet or hit cancel.
|
|
89
|
-
* - `opened`: `expo-web-browser` isn't installed, so the checkout opened in
|
|
90
|
-
* the browser; the result arrives later as a deep link to your app.
|
|
91
|
-
*/
|
|
92
|
-
async function openCheckout(url, options) {
|
|
93
|
-
if (!url)
|
|
94
|
-
throw new Error('munim-billing: openCheckout needs the checkout url.');
|
|
95
|
-
if (!options?.returnUrl || !/^[a-z][a-z0-9+.-]*:/i.test(options.returnUrl)) {
|
|
96
|
-
throw new Error("munim-billing: openCheckout needs a returnUrl like 'myapp://billing'.");
|
|
97
|
-
}
|
|
98
|
-
const browser = options.webBrowser ?? loadWebBrowser();
|
|
99
|
-
if (browser) {
|
|
100
|
-
const result = await browser.openAuthSessionAsync(url, options.returnUrl, {
|
|
101
|
-
preferEphemeralSession: options.preferEphemeralSession ?? false,
|
|
102
|
-
});
|
|
103
|
-
if (result.type === 'success' && result.url) {
|
|
104
|
-
const parsed = parseCheckoutReturnUrl(result.url);
|
|
105
|
-
return parsed.status === 'completed'
|
|
106
|
-
? { status: 'completed', checkoutId: parsed.checkoutId, url: result.url }
|
|
107
|
-
: { status: 'canceled', checkoutId: parsed.checkoutId, url: result.url };
|
|
108
|
-
}
|
|
109
|
-
return { status: 'canceled' };
|
|
110
|
-
}
|
|
111
|
-
const linking = loadLinking();
|
|
112
|
-
if (!linking) {
|
|
113
|
-
throw new Error('munim-billing: install expo-web-browser (or run inside React Native) to open a checkout.');
|
|
114
|
-
}
|
|
115
|
-
await linking.openURL(url);
|
|
116
|
-
return { status: 'opened' };
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=react-native.js.map
|
|
1
|
+
/*! munim-billing © Munim, Inc. All rights reserved. Use is subject to the Munim Billing SDK License (LICENSE). */
|
|
2
|
+
"use strict";var i=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var g=(e,n)=>{for(var t in n)i(e,t,{get:n[t],enumerable:!0})},w=(e,n,t,s)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of f(n))!k.call(e,r)&&r!==t&&i(e,r,{get:()=>n[r],enumerable:!(s=h(n,r))||s.enumerable});return e};var m=e=>w(i({},"__esModule",{value:!0}),e);var R={};g(R,{openCheckout:()=>L,parseCheckoutReturnUrl:()=>a});module.exports=m(R);function y(){try{let e=typeof require=="function"?require("expo-web-browser"):void 0;return e&&typeof e.openAuthSessionAsync=="function"?e:null}catch{return null}}function b(){try{return(typeof require=="function"?require("react-native"):void 0)?.Linking??null}catch{return null}}function C(e){let n=new Map,t=e.indexOf("?"),s=e.indexOf("#"),r=[];t>=0&&r.push(e.slice(t+1,s>t?s:void 0)),s>=0&&r.push(e.slice(s+1));for(let o of r)for(let c of o.split("&")){if(!c)continue;let u=c.indexOf("="),p=u>=0?c.slice(0,u):c,d=u>=0?c.slice(u+1):"";try{let l=decodeURIComponent(p.replace(/\+/g," ")).toLowerCase();n.has(l)||n.set(l,decodeURIComponent(d.replace(/\+/g," ")))}catch{}}return n}function a(e){let n=C(e),t=n.get("checkout_id")||void 0,s=n.get("canceled")??n.get("cancelled");return s==="true"||s==="1"||!t?t?{status:"canceled",checkoutId:t}:{status:"canceled"}:{status:"completed",checkoutId:t}}async function L(e,n){if(!e)throw new Error("munim-billing: openCheckout needs the checkout url.");if(!n?.returnUrl||!/^[a-z][a-z0-9+.-]*:/i.test(n.returnUrl))throw new Error("munim-billing: openCheckout needs a returnUrl like 'myapp://billing'.");let t=n.webBrowser??y();if(t){let r=await t.openAuthSessionAsync(e,n.returnUrl,{preferEphemeralSession:n.preferEphemeralSession??!1});if(r.type==="success"&&r.url){let o=a(r.url);return o.status==="completed"?{status:"completed",checkoutId:o.checkoutId,url:r.url}:{status:"canceled",checkoutId:o.checkoutId,url:r.url}}return{status:"canceled"}}let s=b();if(!s)throw new Error("munim-billing: install expo-web-browser (or run inside React Native) to open a checkout.");return await s.openURL(e),{status:"opened"}}
|