cppay-sdk 0.0.2-beta.3 → 0.0.2-beta.30
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/cppay-CCxKnEWz.js +218 -0
- package/dist/cppay-D2T3pCwj.cjs +1 -0
- package/dist/cppay-sdk.css +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +99 -17
- package/dist/index.js +1 -99
- package/dist/inject-style-Boo8CMsU.cjs +1 -0
- package/dist/inject-style-CWza6SKp.js +7 -0
- package/dist/react.cjs +1 -0
- package/dist/react.d.ts +84 -0
- package/dist/react.js +567 -0
- package/dist/vue.cjs +1 -0
- package/dist/vue.d.ts +88 -0
- package/dist/vue.js +467 -0
- package/package.json +75 -7
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
const CHAIN_ICONS = {
|
|
2
|
+
Ethereum: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
3
|
+
BSC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
4
|
+
"bsc-testnet": "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
5
|
+
Tron: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
|
|
6
|
+
Polygon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
|
|
7
|
+
Solana: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png"
|
|
8
|
+
}, TOKEN_ICONS = {
|
|
9
|
+
USDT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
|
|
10
|
+
USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
|
|
11
|
+
ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
12
|
+
BNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
13
|
+
tBNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
14
|
+
TRX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
|
|
15
|
+
SOL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png"
|
|
16
|
+
};
|
|
17
|
+
var BASE_URL = "http://192.168.0.162:8000", request = async (e, t, r) => {
|
|
18
|
+
let i = Object.assign({ timeout: 15e3 }, r), a = new AbortController(), o = setTimeout(() => a.abort(), i.timeout);
|
|
19
|
+
try {
|
|
20
|
+
let r = await fetch(new URL(e, BASE_URL), {
|
|
21
|
+
signal: a.signal,
|
|
22
|
+
...t
|
|
23
|
+
});
|
|
24
|
+
clearTimeout(o);
|
|
25
|
+
let i = r.headers.get("Content-Type") ?? "";
|
|
26
|
+
if (i.includes("json")) return await r.json();
|
|
27
|
+
try {
|
|
28
|
+
return await r.json();
|
|
29
|
+
} catch {
|
|
30
|
+
throw Error(`URL: ${e}, Unsupport Content Type: ${i}`);
|
|
31
|
+
}
|
|
32
|
+
} catch (t) {
|
|
33
|
+
throw clearTimeout(o), t instanceof DOMException && t.name === "AbortError" ? Error(`URL: ${e}, Request timeout after ${i.timeout}ms`) : t;
|
|
34
|
+
}
|
|
35
|
+
}, SUCCESS_CODE = 0, cppayRequest = async (e, t) => {
|
|
36
|
+
let n = new URLSearchParams(t.params), a = await request(`${t.url}${n.size ? `?${n.toString()}` : ""}`, {
|
|
37
|
+
method: t.method ?? "get",
|
|
38
|
+
headers: {
|
|
39
|
+
Authorization: e,
|
|
40
|
+
...t.headers
|
|
41
|
+
},
|
|
42
|
+
body: t.data ? JSON.stringify(t.data) : void 0
|
|
43
|
+
});
|
|
44
|
+
if (a.code !== SUCCESS_CODE) throw Error(`Request ${t.url} Failed. ${a.message}`);
|
|
45
|
+
return a.data;
|
|
46
|
+
}, CppayApi = class {
|
|
47
|
+
authorization;
|
|
48
|
+
constructor(e, t) {
|
|
49
|
+
this.authorization = e ? `ApiKey ${e}` : `OTT ${t}`;
|
|
50
|
+
}
|
|
51
|
+
async getSupportedChains() {
|
|
52
|
+
return (await cppayRequest(this.authorization, { url: "/api/payment/token" })).map((e) => ({
|
|
53
|
+
chain: e.chain,
|
|
54
|
+
chainId: e.chain_id,
|
|
55
|
+
tokenSymbol: e.token_symbol,
|
|
56
|
+
tokenDecimals: e.token_decimals,
|
|
57
|
+
tokenAddress: e.token_address,
|
|
58
|
+
tokenPrice: e.token_price
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
async createOnetimePayment(e, t, n, r) {
|
|
62
|
+
let i = {
|
|
63
|
+
chain: e,
|
|
64
|
+
token: t,
|
|
65
|
+
order_no: n,
|
|
66
|
+
amount: r
|
|
67
|
+
}, o = await cppayRequest(this.authorization, {
|
|
68
|
+
url: "/api/payment/create",
|
|
69
|
+
method: "post",
|
|
70
|
+
data: i
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
paymentId: o.payment_id,
|
|
74
|
+
paymentAmount: o.pay_amount,
|
|
75
|
+
receiveAddress: o.receive_address,
|
|
76
|
+
expireAt: o.expire_at
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
async createSubscriptionPayment(e, t, n, r, i) {
|
|
80
|
+
let o = {
|
|
81
|
+
chain: e,
|
|
82
|
+
token: t,
|
|
83
|
+
order_no: n,
|
|
84
|
+
amount_usd: r,
|
|
85
|
+
renewal_days: i
|
|
86
|
+
}, s = await cppayRequest(this.authorization, {
|
|
87
|
+
url: "/api/subscription/create",
|
|
88
|
+
method: "post",
|
|
89
|
+
data: o
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
subscriptionId: s.subscription_id,
|
|
93
|
+
approveAmount: s.approved_amount,
|
|
94
|
+
spenderAddress: s.contract_address,
|
|
95
|
+
expireAt: s.expire_at
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
async createX402Payment() {
|
|
99
|
+
throw Error("Unsupported payment mode");
|
|
100
|
+
}
|
|
101
|
+
async checkOnetimePaymentStatus(e) {
|
|
102
|
+
let t = { payment_id: e }, n = await cppayRequest(this.authorization, {
|
|
103
|
+
url: "/api/payment/query",
|
|
104
|
+
params: t
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
orderId: n.order_no,
|
|
108
|
+
paymentId: n.payment_id,
|
|
109
|
+
chain: n.chain,
|
|
110
|
+
token: n.token,
|
|
111
|
+
baseAmount: n.base_amount,
|
|
112
|
+
payAmount: n.pay_amount,
|
|
113
|
+
receiveAddress: n.receive_address,
|
|
114
|
+
expireAt: n.expire_at,
|
|
115
|
+
status: n.status
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async checkSubcriptionPaymentStatus(e) {
|
|
119
|
+
let t = { subscription_id: e }, n = await cppayRequest(this.authorization, {
|
|
120
|
+
url: "/api/subscription/query",
|
|
121
|
+
params: t
|
|
122
|
+
});
|
|
123
|
+
return {
|
|
124
|
+
orderId: n.order_no,
|
|
125
|
+
subscriptionId: n.subscription_id,
|
|
126
|
+
chain: n.chain,
|
|
127
|
+
token: n.token,
|
|
128
|
+
approvedAddress: n.approved_contract_address,
|
|
129
|
+
txHash: n.approved_tx_hash,
|
|
130
|
+
approveAmount: n.approved_amount,
|
|
131
|
+
amountOfUsd: n.amount_usd,
|
|
132
|
+
expireAt: n.expire_at,
|
|
133
|
+
status: n.subscription_status
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
async getSubcriptionPayments(e) {
|
|
137
|
+
let t = { subscription_id: e }, n = await cppayRequest(this.authorization, {
|
|
138
|
+
url: "/api/subscription/payments",
|
|
139
|
+
params: t
|
|
140
|
+
});
|
|
141
|
+
return {
|
|
142
|
+
total: n.total,
|
|
143
|
+
payments: (n.payments ?? []).map((e) => ({
|
|
144
|
+
orderId: e.order_no,
|
|
145
|
+
subscriptionId: e.subscription_id,
|
|
146
|
+
chain: e.chain,
|
|
147
|
+
token: e.token,
|
|
148
|
+
txHash: e.tx_hash,
|
|
149
|
+
payAmount: e.pay_amount,
|
|
150
|
+
receiveAddress: e.receive_address,
|
|
151
|
+
status: e.status,
|
|
152
|
+
errorMessage: e.error_message
|
|
153
|
+
}))
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async checkX402PaymentStatus() {
|
|
157
|
+
throw Error("Unsupported payment mode");
|
|
158
|
+
}
|
|
159
|
+
}, cppay_default = class {
|
|
160
|
+
api;
|
|
161
|
+
constructor(e) {
|
|
162
|
+
this.api = new CppayApi(e);
|
|
163
|
+
}
|
|
164
|
+
async getSupportedChains() {
|
|
165
|
+
let n = (await this.api.getSupportedChains()).reduce((n, r) => {
|
|
166
|
+
let i = n[r.chain] ?? {
|
|
167
|
+
chain: r.chain,
|
|
168
|
+
chainId: r.chainId,
|
|
169
|
+
tokens: [],
|
|
170
|
+
icon: CHAIN_ICONS[r.chain]
|
|
171
|
+
};
|
|
172
|
+
return i.tokens.push({
|
|
173
|
+
symbol: r.tokenSymbol,
|
|
174
|
+
decimals: r.tokenDecimals,
|
|
175
|
+
address: r.tokenAddress,
|
|
176
|
+
icon: TOKEN_ICONS[r.tokenSymbol],
|
|
177
|
+
price: r.tokenPrice
|
|
178
|
+
}), n[r.chain] = i, n;
|
|
179
|
+
}, {});
|
|
180
|
+
return Object.values(n);
|
|
181
|
+
}
|
|
182
|
+
async createPayment(e, t) {
|
|
183
|
+
switch (e) {
|
|
184
|
+
case "one-time": return this.createOnetimePayment(t);
|
|
185
|
+
case "subscription": return this.createSubscriptionPayment(t);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
async checkPaymentStatus(e, t) {
|
|
189
|
+
switch (e) {
|
|
190
|
+
case "one-time": return this.checkOnetimePaymentStatus(t);
|
|
191
|
+
case "subscription": return this.checkSubscriptionPaymentStatus(t);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async createOnetimePayment(e) {
|
|
195
|
+
let t = await this.api.createOnetimePayment(e.paymentChain, e.paymentToken, e.orderId, e.amount);
|
|
196
|
+
return {
|
|
197
|
+
...e,
|
|
198
|
+
...t
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async createSubscriptionPayment(e) {
|
|
202
|
+
let t = await this.api.createSubscriptionPayment(e.paymentChain, e.paymentToken, e.orderId, e.amountOfUsd, e.intervalDays);
|
|
203
|
+
return {
|
|
204
|
+
...e,
|
|
205
|
+
...t
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
async checkOnetimePaymentStatus(e) {
|
|
209
|
+
return { ...await this.api.checkOnetimePaymentStatus(e.paymentId) };
|
|
210
|
+
}
|
|
211
|
+
async checkSubscriptionPaymentStatus(e) {
|
|
212
|
+
return { ...await this.api.checkSubcriptionPaymentStatus(e.subscriptionId) };
|
|
213
|
+
}
|
|
214
|
+
async getSubcriptionPayments(e) {
|
|
215
|
+
return { ...await this.api.getSubcriptionPayments(e.subscriptionId) };
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
export { CHAIN_ICONS as n, TOKEN_ICONS as r, cppay_default as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={Ethereum:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png`,BSC:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png`,"bsc-testnet":`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png`,Tron:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png`,Polygon:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png`,Solana:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png`},t={USDT:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png`,USDC:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png`,ETH:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png`,BNB:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png`,tBNB:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png`,TRX:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png`,SOL:`https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png`};var n=`http://192.168.0.162:8000`,r=async(e,t,r)=>{let i=Object.assign({timeout:15e3},r),a=new AbortController,o=setTimeout(()=>a.abort(),i.timeout);try{let r=await fetch(new URL(e,n),{signal:a.signal,...t});clearTimeout(o);let i=r.headers.get(`Content-Type`)??``;if(i.includes(`json`))return await r.json();try{return await r.json()}catch{throw Error(`URL: ${e}, Unsupport Content Type: ${i}`)}}catch(t){throw clearTimeout(o),t instanceof DOMException&&t.name===`AbortError`?Error(`URL: ${e}, Request timeout after ${i.timeout}ms`):t}},i=0,a=async(e,t)=>{let n=new URLSearchParams(t.params),a=await r(`${t.url}${n.size?`?${n.toString()}`:``}`,{method:t.method??`get`,headers:{Authorization:e,...t.headers},body:t.data?JSON.stringify(t.data):void 0});if(a.code!==i)throw Error(`Request ${t.url} Failed. ${a.message}`);return a.data},o=class{authorization;constructor(e,t){this.authorization=e?`ApiKey ${e}`:`OTT ${t}`}async getSupportedChains(){return(await a(this.authorization,{url:`/api/payment/token`})).map(e=>({chain:e.chain,chainId:e.chain_id,tokenSymbol:e.token_symbol,tokenDecimals:e.token_decimals,tokenAddress:e.token_address,tokenPrice:e.token_price}))}async createOnetimePayment(e,t,n,r){let i={chain:e,token:t,order_no:n,amount:r},o=await a(this.authorization,{url:`/api/payment/create`,method:`post`,data:i});return{paymentId:o.payment_id,paymentAmount:o.pay_amount,receiveAddress:o.receive_address,expireAt:o.expire_at}}async createSubscriptionPayment(e,t,n,r,i){let o={chain:e,token:t,order_no:n,amount_usd:r,renewal_days:i},s=await a(this.authorization,{url:`/api/subscription/create`,method:`post`,data:o});return{subscriptionId:s.subscription_id,approveAmount:s.approved_amount,spenderAddress:s.contract_address,expireAt:s.expire_at}}async createX402Payment(){throw Error(`Unsupported payment mode`)}async checkOnetimePaymentStatus(e){let t={payment_id:e},n=await a(this.authorization,{url:`/api/payment/query`,params:t});return{orderId:n.order_no,paymentId:n.payment_id,chain:n.chain,token:n.token,baseAmount:n.base_amount,payAmount:n.pay_amount,receiveAddress:n.receive_address,expireAt:n.expire_at,status:n.status}}async checkSubcriptionPaymentStatus(e){let t={subscription_id:e},n=await a(this.authorization,{url:`/api/subscription/query`,params:t});return{orderId:n.order_no,subscriptionId:n.subscription_id,chain:n.chain,token:n.token,approvedAddress:n.approved_contract_address,txHash:n.approved_tx_hash,approveAmount:n.approved_amount,amountOfUsd:n.amount_usd,expireAt:n.expire_at,status:n.subscription_status}}async getSubcriptionPayments(e){let t={subscription_id:e},n=await a(this.authorization,{url:`/api/subscription/payments`,params:t});return{total:n.total,payments:(n.payments??[]).map(e=>({orderId:e.order_no,subscriptionId:e.subscription_id,chain:e.chain,token:e.token,txHash:e.tx_hash,payAmount:e.pay_amount,receiveAddress:e.receive_address,status:e.status,errorMessage:e.error_message}))}}async checkX402PaymentStatus(){throw Error(`Unsupported payment mode`)}},s=class{api;constructor(e){this.api=new o(e)}async getSupportedChains(){let n=(await this.api.getSupportedChains()).reduce((n,r)=>{let i=n[r.chain]??{chain:r.chain,chainId:r.chainId,tokens:[],icon:e[r.chain]};return i.tokens.push({symbol:r.tokenSymbol,decimals:r.tokenDecimals,address:r.tokenAddress,icon:t[r.tokenSymbol],price:r.tokenPrice}),n[r.chain]=i,n},{});return Object.values(n)}async createPayment(e,t){switch(e){case`one-time`:return this.createOnetimePayment(t);case`subscription`:return this.createSubscriptionPayment(t)}}async checkPaymentStatus(e,t){switch(e){case`one-time`:return this.checkOnetimePaymentStatus(t);case`subscription`:return this.checkSubscriptionPaymentStatus(t)}}async createOnetimePayment(e){let t=await this.api.createOnetimePayment(e.paymentChain,e.paymentToken,e.orderId,e.amount);return{...e,...t}}async createSubscriptionPayment(e){let t=await this.api.createSubscriptionPayment(e.paymentChain,e.paymentToken,e.orderId,e.amountOfUsd,e.intervalDays);return{...e,...t}}async checkOnetimePaymentStatus(e){return{...await this.api.checkOnetimePaymentStatus(e.paymentId)}}async checkSubscriptionPaymentStatus(e){return{...await this.api.checkSubcriptionPaymentStatus(e.subscriptionId)}}async getSubcriptionPayments(e){return{...await this.api.getSubcriptionPayments(e.subscriptionId)}}},c=s;Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
._cppay-fade-enter-active[data-v-9361860d],._cppay-fade-leave-active[data-v-9361860d]{transition:opacity .3s}._cppay-fade-enter-from[data-v-9361860d],._cppay-fade-leave-to[data-v-9361860d]{opacity:0}._cppay-fade-enter-active ._cppay-dialog[data-v-9361860d]{animation:.3s _cppay-slideUp}
|
|
2
|
+
/*$vite$:1*/
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=
|
|
1
|
+
const e=require(`./cppay-D2T3pCwj.cjs`);exports.CHAIN_ICONS=e.n,exports.Cppay=e.t,exports.TOKEN_ICONS=e.r;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,47 @@
|
|
|
1
1
|
export declare type Address = `0x${string}`;
|
|
2
2
|
|
|
3
|
-
export declare
|
|
4
|
-
|
|
5
|
-
export declare const CHAIN_ICONS: Record<Chain, string>;
|
|
3
|
+
export declare const CHAIN_ICONS: Record<string, string>;
|
|
6
4
|
|
|
7
5
|
export declare interface ChainInfo {
|
|
8
6
|
icon?: string;
|
|
9
|
-
chain:
|
|
7
|
+
chain: string;
|
|
8
|
+
chainId: number;
|
|
10
9
|
tokens: TokenInfo[];
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
export declare class Cppay {
|
|
14
|
-
private
|
|
13
|
+
private api;
|
|
15
14
|
constructor(apikey: string);
|
|
16
15
|
getSupportedChains(): Promise<ChainInfo[]>;
|
|
17
|
-
createPayment(params:
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
createPayment(plain: "one-time", params: Parameters<Cppay["createOnetimePayment"]>[0]): Promise<OnetimePaymentInfo>;
|
|
17
|
+
createPayment(plain: "subscription", params: Parameters<Cppay["createSubscriptionPayment"]>[0]): Promise<SubscriptionPaymentInfo>;
|
|
18
|
+
checkPaymentStatus(plain: "one-time", params: Parameters<Cppay["checkOnetimePaymentStatus"]>[0]): Promise<OnetimePaymentOrderStatus>;
|
|
19
|
+
checkPaymentStatus(plain: "subscription", params: Parameters<Cppay["checkSubscriptionPaymentStatus"]>[0]): Promise<SubscriptionPaymentOrderStatus>;
|
|
20
|
+
createOnetimePayment(params: {
|
|
21
|
+
paymentChain: string;
|
|
22
|
+
paymentToken: string;
|
|
20
23
|
orderId: string;
|
|
21
24
|
amount: Numberic;
|
|
22
|
-
}): Promise<
|
|
23
|
-
|
|
25
|
+
}): Promise<OnetimePaymentInfo>;
|
|
26
|
+
createSubscriptionPayment(params: {
|
|
27
|
+
paymentChain: string;
|
|
28
|
+
paymentToken: string;
|
|
29
|
+
orderId: string;
|
|
30
|
+
amountOfUsd: Numberic;
|
|
31
|
+
intervalDays: number;
|
|
32
|
+
}): Promise<SubscriptionPaymentInfo>;
|
|
33
|
+
checkOnetimePaymentStatus(params: {
|
|
34
|
+
paymentId: string;
|
|
35
|
+
}): Promise<OnetimePaymentOrderStatus>;
|
|
36
|
+
checkSubscriptionPaymentStatus(params: {
|
|
37
|
+
subscriptionId: string;
|
|
38
|
+
}): Promise<SubscriptionPaymentOrderStatus>;
|
|
39
|
+
getSubcriptionPayments(params: {
|
|
40
|
+
subscriptionId: string;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
total: number;
|
|
43
|
+
payments: SubscriptionPayment[];
|
|
44
|
+
}>;
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
export declare interface CppayResponse<R> {
|
|
@@ -31,24 +52,85 @@ export declare interface CppayResponse<R> {
|
|
|
31
52
|
|
|
32
53
|
export declare type Numberic = `${number}.${number}` | `${number}`;
|
|
33
54
|
|
|
34
|
-
export declare interface
|
|
55
|
+
export declare interface OnetimePaymentInfo {
|
|
35
56
|
orderId: string;
|
|
36
57
|
paymentId: string;
|
|
37
58
|
paymentAmount: Numberic;
|
|
38
|
-
paymentChain:
|
|
39
|
-
paymentToken:
|
|
59
|
+
paymentChain: string;
|
|
60
|
+
paymentToken: string;
|
|
61
|
+
receiveAddress: Address;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export declare interface OnetimePaymentOrderStatus {
|
|
65
|
+
orderId: string;
|
|
66
|
+
paymentId: string;
|
|
67
|
+
chain: string;
|
|
68
|
+
token: string;
|
|
69
|
+
baseAmount: Numberic;
|
|
70
|
+
payAmount: Numberic;
|
|
71
|
+
receiveAddress: Address;
|
|
72
|
+
expireAt: number;
|
|
73
|
+
status: PaymentStatus;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export declare type PaymentPlain = "one-time" | "subscription" | "x402";
|
|
77
|
+
|
|
78
|
+
export declare type PaymentStatus = "pending" | "paid" | "expired" | "failed";
|
|
79
|
+
|
|
80
|
+
export declare interface SubscriptionPayment {
|
|
81
|
+
orderId: string;
|
|
82
|
+
subscriptionId: string;
|
|
83
|
+
chain: string;
|
|
84
|
+
token: string;
|
|
85
|
+
payAmount: Numberic;
|
|
86
|
+
txHash: string;
|
|
87
|
+
receiveAddress: Address;
|
|
88
|
+
status: PaymentStatus;
|
|
89
|
+
errorMessage: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export declare interface SubscriptionPaymentInfo {
|
|
93
|
+
subscriptionId: string;
|
|
94
|
+
approveAmount: Numberic;
|
|
95
|
+
spenderAddress: Address;
|
|
96
|
+
expireAt: number;
|
|
97
|
+
paymentChain: string;
|
|
98
|
+
paymentToken: string;
|
|
99
|
+
orderId: string;
|
|
100
|
+
amountOfUsd: Numberic;
|
|
101
|
+
intervalDays: number;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export declare interface SubscriptionPaymentOrderStatus {
|
|
105
|
+
orderId: string;
|
|
106
|
+
subscriptionId: string;
|
|
107
|
+
chain: string;
|
|
108
|
+
token: string;
|
|
109
|
+
approvedAddress: string;
|
|
110
|
+
txHash: string;
|
|
111
|
+
approveAmount: string;
|
|
112
|
+
amountOfUsd: string;
|
|
113
|
+
expireAt: number;
|
|
114
|
+
status: SubscriptionPaymentStatus;
|
|
40
115
|
}
|
|
41
116
|
|
|
42
|
-
export declare type
|
|
117
|
+
export declare type SubscriptionPaymentStatus = "pending" | "approved" | "expired" | "failed";
|
|
43
118
|
|
|
44
|
-
export declare const TOKEN_ICONS: Record<
|
|
119
|
+
export declare const TOKEN_ICONS: Record<string, string>;
|
|
45
120
|
|
|
46
121
|
export declare interface TokenInfo {
|
|
47
122
|
icon?: string;
|
|
48
|
-
symbol:
|
|
123
|
+
symbol: string;
|
|
124
|
+
price: Numberic;
|
|
49
125
|
decimals: number;
|
|
50
126
|
address: Address | "";
|
|
51
|
-
receiveAddresses: Address[];
|
|
52
127
|
}
|
|
53
128
|
|
|
54
129
|
export { }
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
declare module "@vue/runtime-core" {
|
|
133
|
+
interface ComponentCustomProperties {
|
|
134
|
+
$showPayment: typeof showPayment;
|
|
135
|
+
}
|
|
136
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,100 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Ethereum: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
3
|
-
BSC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
4
|
-
Tron: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
|
|
5
|
-
Polygon: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/polygon/info/logo.png",
|
|
6
|
-
Solana: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png"
|
|
7
|
-
}, TOKEN_ICONS = {
|
|
8
|
-
USDT: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xdAC17F958D2ee523a2206206994597C13D831ec7/logo.png",
|
|
9
|
-
USDC: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/assets/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48/logo.png",
|
|
10
|
-
ETH: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/ethereum/info/logo.png",
|
|
11
|
-
BNB: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/binance/info/logo.png",
|
|
12
|
-
TRX: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/tron/info/logo.png",
|
|
13
|
-
SOL: "https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png"
|
|
14
|
-
};
|
|
15
|
-
var BASE_URL = "http://192.168.0.162:8000", request = async (e, n, i) => {
|
|
16
|
-
let a = Object.assign({ timeout: 15e3 }, i), o = new AbortController(), s = setTimeout(() => o.abort(), a.timeout);
|
|
17
|
-
try {
|
|
18
|
-
let i = await fetch(new URL(e, BASE_URL), {
|
|
19
|
-
signal: o.signal,
|
|
20
|
-
...n
|
|
21
|
-
});
|
|
22
|
-
clearTimeout(s);
|
|
23
|
-
let a = i.headers.get("Content-Type") ?? "";
|
|
24
|
-
if (a.includes("json")) return await i.json();
|
|
25
|
-
try {
|
|
26
|
-
return await i.json();
|
|
27
|
-
} catch {
|
|
28
|
-
throw Error(`URL: ${e}, Unsupport Content Type: ${a}`);
|
|
29
|
-
}
|
|
30
|
-
} catch (n) {
|
|
31
|
-
throw clearTimeout(s), n instanceof DOMException && n.name === "AbortError" ? Error(`URL: ${e}, Request timeout after ${a.timeout}ms`) : n;
|
|
32
|
-
}
|
|
33
|
-
}, SUCCESS_CODE = 0;
|
|
34
|
-
const cppayRequest = async (e, n) => {
|
|
35
|
-
let r = await request(n.url, {
|
|
36
|
-
method: n.method ?? "get",
|
|
37
|
-
headers: {
|
|
38
|
-
Authorization: e,
|
|
39
|
-
...n.headers
|
|
40
|
-
},
|
|
41
|
-
body: JSON.stringify(n.data)
|
|
42
|
-
});
|
|
43
|
-
if (r.code !== SUCCESS_CODE) throw Error(`Request ${n.url} Failed. ${r.message}`);
|
|
44
|
-
return r.data;
|
|
45
|
-
}, sleep = (e = 1e3) => new Promise((n) => setTimeout(n, e));
|
|
46
|
-
var cppay_default = class {
|
|
47
|
-
apikey;
|
|
48
|
-
constructor(e) {
|
|
49
|
-
this.apikey = e;
|
|
50
|
-
}
|
|
51
|
-
async getSupportedChains() {
|
|
52
|
-
let r = (await cppayRequest(this.apikey, { url: "/api/payment/token" })).reduce((r, i) => {
|
|
53
|
-
let a = r[i.chain] ?? {
|
|
54
|
-
chain: i.chain,
|
|
55
|
-
tokens: [],
|
|
56
|
-
icon: CHAIN_ICONS[i.chain]
|
|
57
|
-
};
|
|
58
|
-
return a.tokens.push({
|
|
59
|
-
symbol: i.token_symbol,
|
|
60
|
-
decimals: i.token_decimals,
|
|
61
|
-
address: i.token_address,
|
|
62
|
-
receiveAddresses: i.receive_addresses,
|
|
63
|
-
icon: TOKEN_ICONS[i.token_symbol]
|
|
64
|
-
}), r[i.chain] = a, r;
|
|
65
|
-
}, {});
|
|
66
|
-
return Object.values(r);
|
|
67
|
-
}
|
|
68
|
-
async createPayment(e) {
|
|
69
|
-
let n = {
|
|
70
|
-
chain: e.paymentChain,
|
|
71
|
-
token: e.paymentToken,
|
|
72
|
-
order_no: e.orderId,
|
|
73
|
-
amount: e.amount
|
|
74
|
-
}, r = await cppayRequest(this.apikey, {
|
|
75
|
-
url: "/api/payment/create",
|
|
76
|
-
method: "post",
|
|
77
|
-
data: n
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
orderId: e.orderId,
|
|
81
|
-
paymentId: r.payment_id,
|
|
82
|
-
paymentAmount: r.pay_amount,
|
|
83
|
-
paymentChain: e.paymentChain,
|
|
84
|
-
paymentToken: e.paymentToken
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
async checkPaymentStatus(e, n = 1e3) {
|
|
88
|
-
let r = 15;
|
|
89
|
-
for (; r--;) {
|
|
90
|
-
let r = { payment_id: e };
|
|
91
|
-
if ((await cppayRequest(this.apikey, {
|
|
92
|
-
url: "/api/payment/query",
|
|
93
|
-
data: r
|
|
94
|
-
})).status === "success") return;
|
|
95
|
-
await sleep(n);
|
|
96
|
-
}
|
|
97
|
-
throw Error(`Check Payment Status Timeout, PaymentId: ${e}`);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
1
|
+
import { n as CHAIN_ICONS, r as TOKEN_ICONS, t as cppay_default } from "./cppay-CCxKnEWz.js";
|
|
100
2
|
export { CHAIN_ICONS, cppay_default as Cppay, TOKEN_ICONS };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),c=`._cppay-overlay{z-index:999;background-color:#00000080;justify-content:center;align-items:center;padding:1rem;display:flex;position:fixed;inset:0}._cppay-dialog{background-color:#fff;border-radius:1.5rem;flex-direction:column;width:100%;max-width:28rem;max-height:90vh;display:flex;overflow:hidden;box-shadow:0 20px 25px -5px #0000001a,0 10px 10px -5px #0000000a}._cppay-header{border-bottom:1px solid #e5e7eb;justify-content:space-between;align-items:center;padding:1rem 1.25rem;display:flex}._cppay-title{color:#111827;margin:0;font-size:1.25rem;font-weight:600}._cppay-close-btn{color:#9ca3af;cursor:pointer;background:0 0;border:none;padding:.25rem;transition:color .2s}._cppay-close-btn:hover:not(:disabled){color:#4b5563}._cppay-close-btn:disabled{opacity:.5;cursor:not-allowed}._cppay-close-btn svg{width:1.5rem;height:1.5rem}._cppay-content{flex:1;padding:1.25rem;overflow-y:auto}._cppay-section{margin-bottom:1rem}._cppay-section:last-child{margin-bottom:0}._cppay-label{color:#374151;margin-bottom:.5rem;font-size:.875rem;font-weight:500;display:block}._cppay-grid{grid-template-columns:repeat(2,1fr);gap:.75rem;display:grid}._cppay-select-btn{cursor:pointer;background:#fff;border:2px solid #e5e7eb;border-radius:.75rem;align-items:center;gap:.5rem;padding:.75rem;font-family:inherit;font-size:.875rem;transition:all .2s;display:flex}._cppay-select-btn:hover{border-color:#d1d5db}._cppay-select-btn._cppay-selected{background-color:#eff6ff;border-color:#2563eb}._cppay-select-btn img{border-radius:9999px;width:1.5rem;height:1.5rem}._cppay-select-btn span{font-weight:500}._cppay-price-box{background-color:#f9fafb;border-radius:1rem;padding:1rem}._cppay-price-row{justify-content:space-between;align-items:center;display:flex}._cppay-price-label{color:#4b5563;font-size:.875rem}._cppay-price-amount{text-align:right}._cppay-price-main{color:#111827;margin:0;font-size:1.25rem;font-weight:700}._cppay-price-sub{color:#6b7280;margin-top:.25rem;font-size:.875rem}._cppay-btn{cursor:pointer;border:none;border-radius:.75rem;width:100%;padding:.75rem;font-family:inherit;font-size:1rem;font-weight:500;transition:all .2s}._cppay-btn-primary{color:#fff;background-color:#2563eb}._cppay-btn-primary:hover:not(:disabled){background-color:#1d4ed8}._cppay-btn-primary:disabled{opacity:.5;cursor:not-allowed}._cppay-btn-secondary{color:#374151;background-color:#fff;border:1px solid #d1d5db}._cppay-btn-secondary:hover:not(:disabled){background-color:#f9fafb}._cppay-btn-secondary:disabled{opacity:.5;cursor:not-allowed}._cppay-btn-text{color:#6b7280;text-align:center;background:0 0;border:none;padding:.5rem;font-size:.875rem}._cppay-btn-text:hover:not(:disabled){color:#2563eb;background:0 0}._cppay-btn-text:disabled{opacity:.5;cursor:not-allowed}._cppay-error-tooltip-wrapper{position:relative}._cppay-error-tooltip{color:#991b1b;cursor:help;background-color:#fef2f2;border:1px solid #fecaca;border-radius:.375rem;align-items:center;gap:.5rem;margin-bottom:.5rem;padding:.5rem .75rem;font-size:.8125rem;line-height:1.25;transition:all .2s;display:flex}._cppay-error-tooltip:hover{background-color:#fee2e2;border-color:#fca5a5}._cppay-error-tooltip svg{flex-shrink:0;width:1rem;height:1rem}._cppay-error-tooltip span{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}._cppay-error-tooltip-full{color:#fff;z-index:10;word-wrap:break-word;white-space:normal;background-color:#7f1d1d;border-radius:.5rem;margin-bottom:.25rem;padding:.625rem .875rem;font-size:.8125rem;line-height:1.4;animation:.2s ease-out _cppay-tooltipFadeIn;position:absolute;bottom:100%;left:0;right:0;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}._cppay-error-tooltip-full:after{content:"";border:.375rem solid #0000;border-top-color:#7f1d1d;position:absolute;top:100%;left:1rem}@keyframes _cppay-tooltipFadeIn{0%{opacity:0;transform:translateY(.25rem)}to{opacity:1;transform:translateY(0)}}._cppay-btn-container{align-items:center;gap:.5rem;display:flex}._cppay-qr-container{justify-content:center;margin-bottom:1rem;display:flex}._cppay-qr-code{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);border-radius:1rem;padding:.75rem;box-shadow:0 4px 12px #667eea26}._cppay-qr-placeholder{background-color:#f3f4f6;border-radius:.75rem;justify-content:center;align-items:center;width:10rem;height:10rem;display:flex}._cppay-qr-placeholder span{color:#9ca3af;font-size:.875rem}._cppay-info-box{background-color:#f9fafb;border-radius:.75rem;margin-bottom:.625rem;padding:.875rem}._cppay-info-box:last-child{margin-bottom:0}._cppay-info-label{color:#4b5563;margin-bottom:.25rem;font-size:.875rem}._cppay-info-value{color:#111827;font-size:1.25rem;font-weight:700}._cppay-address-row{align-items:center;gap:.5rem;display:flex}._cppay-address-row code{text-overflow:ellipsis;white-space:nowrap;color:#111827;background:0 0;flex:1;font-family:monospace;font-size:.75rem;overflow:hidden}._cppay-copy-btn{color:#2563eb;cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:.25rem;transition:color .2s;display:flex}._cppay-copy-btn:hover{color:#1d4ed8}._cppay-copy-btn svg{width:1.25rem;height:1.25rem}@keyframes _cppay-fadeIn{0%{opacity:0}to{opacity:1}}@keyframes _cppay-slideUp{0%{opacity:0;transform:translateY(1.25rem)}to{opacity:1;transform:translateY(0)}}._cppay-overlay{animation:.3s _cppay-fadeIn}._cppay-dialog{animation:.3s _cppay-slideUp}@media (max-width:640px){._cppay-dialog{margin:.5rem}._cppay-header,._cppay-content{padding:1rem}}`;function l(e){if(typeof document>`u`||document.getElementById(`_cppay-payment-dialog-style`))return;let t=document.createElement(`style`);t.id=`_cppay-payment-dialog-style`,t.textContent=e,document.head.appendChild(t)}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return l}});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var payment_dialog_default = "._cppay-overlay{z-index:999;background-color:#00000080;justify-content:center;align-items:center;padding:1rem;display:flex;position:fixed;inset:0}._cppay-dialog{background-color:#fff;border-radius:1.5rem;flex-direction:column;width:100%;max-width:28rem;max-height:90vh;display:flex;overflow:hidden;box-shadow:0 20px 25px -5px #0000001a,0 10px 10px -5px #0000000a}._cppay-header{border-bottom:1px solid #e5e7eb;justify-content:space-between;align-items:center;padding:1rem 1.25rem;display:flex}._cppay-title{color:#111827;margin:0;font-size:1.25rem;font-weight:600}._cppay-close-btn{color:#9ca3af;cursor:pointer;background:0 0;border:none;padding:.25rem;transition:color .2s}._cppay-close-btn:hover:not(:disabled){color:#4b5563}._cppay-close-btn:disabled{opacity:.5;cursor:not-allowed}._cppay-close-btn svg{width:1.5rem;height:1.5rem}._cppay-content{flex:1;padding:1.25rem;overflow-y:auto}._cppay-section{margin-bottom:1rem}._cppay-section:last-child{margin-bottom:0}._cppay-label{color:#374151;margin-bottom:.5rem;font-size:.875rem;font-weight:500;display:block}._cppay-grid{grid-template-columns:repeat(2,1fr);gap:.75rem;display:grid}._cppay-select-btn{cursor:pointer;background:#fff;border:2px solid #e5e7eb;border-radius:.75rem;align-items:center;gap:.5rem;padding:.75rem;font-family:inherit;font-size:.875rem;transition:all .2s;display:flex}._cppay-select-btn:hover{border-color:#d1d5db}._cppay-select-btn._cppay-selected{background-color:#eff6ff;border-color:#2563eb}._cppay-select-btn img{border-radius:9999px;width:1.5rem;height:1.5rem}._cppay-select-btn span{font-weight:500}._cppay-price-box{background-color:#f9fafb;border-radius:1rem;padding:1rem}._cppay-price-row{justify-content:space-between;align-items:center;display:flex}._cppay-price-label{color:#4b5563;font-size:.875rem}._cppay-price-amount{text-align:right}._cppay-price-main{color:#111827;margin:0;font-size:1.25rem;font-weight:700}._cppay-price-sub{color:#6b7280;margin-top:.25rem;font-size:.875rem}._cppay-btn{cursor:pointer;border:none;border-radius:.75rem;width:100%;padding:.75rem;font-family:inherit;font-size:1rem;font-weight:500;transition:all .2s}._cppay-btn-primary{color:#fff;background-color:#2563eb}._cppay-btn-primary:hover:not(:disabled){background-color:#1d4ed8}._cppay-btn-primary:disabled{opacity:.5;cursor:not-allowed}._cppay-btn-secondary{color:#374151;background-color:#fff;border:1px solid #d1d5db}._cppay-btn-secondary:hover:not(:disabled){background-color:#f9fafb}._cppay-btn-secondary:disabled{opacity:.5;cursor:not-allowed}._cppay-btn-text{color:#6b7280;text-align:center;background:0 0;border:none;padding:.5rem;font-size:.875rem}._cppay-btn-text:hover:not(:disabled){color:#2563eb;background:0 0}._cppay-btn-text:disabled{opacity:.5;cursor:not-allowed}._cppay-error-tooltip-wrapper{position:relative}._cppay-error-tooltip{color:#991b1b;cursor:help;background-color:#fef2f2;border:1px solid #fecaca;border-radius:.375rem;align-items:center;gap:.5rem;margin-bottom:.5rem;padding:.5rem .75rem;font-size:.8125rem;line-height:1.25;transition:all .2s;display:flex}._cppay-error-tooltip:hover{background-color:#fee2e2;border-color:#fca5a5}._cppay-error-tooltip svg{flex-shrink:0;width:1rem;height:1rem}._cppay-error-tooltip span{text-overflow:ellipsis;white-space:nowrap;flex:1;min-width:0;overflow:hidden}._cppay-error-tooltip-full{color:#fff;z-index:10;word-wrap:break-word;white-space:normal;background-color:#7f1d1d;border-radius:.5rem;margin-bottom:.25rem;padding:.625rem .875rem;font-size:.8125rem;line-height:1.4;animation:.2s ease-out _cppay-tooltipFadeIn;position:absolute;bottom:100%;left:0;right:0;box-shadow:0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}._cppay-error-tooltip-full:after{content:\"\";border:.375rem solid #0000;border-top-color:#7f1d1d;position:absolute;top:100%;left:1rem}@keyframes _cppay-tooltipFadeIn{0%{opacity:0;transform:translateY(.25rem)}to{opacity:1;transform:translateY(0)}}._cppay-btn-container{align-items:center;gap:.5rem;display:flex}._cppay-qr-container{justify-content:center;margin-bottom:1rem;display:flex}._cppay-qr-code{background:linear-gradient(135deg,#667eea 0%,#764ba2 100%);border-radius:1rem;padding:.75rem;box-shadow:0 4px 12px #667eea26}._cppay-qr-placeholder{background-color:#f3f4f6;border-radius:.75rem;justify-content:center;align-items:center;width:10rem;height:10rem;display:flex}._cppay-qr-placeholder span{color:#9ca3af;font-size:.875rem}._cppay-info-box{background-color:#f9fafb;border-radius:.75rem;margin-bottom:.625rem;padding:.875rem}._cppay-info-box:last-child{margin-bottom:0}._cppay-info-label{color:#4b5563;margin-bottom:.25rem;font-size:.875rem}._cppay-info-value{color:#111827;font-size:1.25rem;font-weight:700}._cppay-address-row{align-items:center;gap:.5rem;display:flex}._cppay-address-row code{text-overflow:ellipsis;white-space:nowrap;color:#111827;background:0 0;flex:1;font-family:monospace;font-size:.75rem;overflow:hidden}._cppay-copy-btn{color:#2563eb;cursor:pointer;background:0 0;border:none;justify-content:center;align-items:center;padding:.25rem;transition:color .2s;display:flex}._cppay-copy-btn:hover{color:#1d4ed8}._cppay-copy-btn svg{width:1.25rem;height:1.25rem}@keyframes _cppay-fadeIn{0%{opacity:0}to{opacity:1}}@keyframes _cppay-slideUp{0%{opacity:0;transform:translateY(1.25rem)}to{opacity:1;transform:translateY(0)}}._cppay-overlay{animation:.3s _cppay-fadeIn}._cppay-dialog{animation:.3s _cppay-slideUp}@media (max-width:640px){._cppay-dialog{margin:.5rem}._cppay-header,._cppay-content{padding:1rem}}";
|
|
2
|
+
function injectStyle(e) {
|
|
3
|
+
if (typeof document > "u" || document.getElementById("_cppay-payment-dialog-style")) return;
|
|
4
|
+
let t = document.createElement("style");
|
|
5
|
+
t.id = "_cppay-payment-dialog-style", t.textContent = e, document.head.appendChild(t);
|
|
6
|
+
}
|
|
7
|
+
export { payment_dialog_default as n, injectStyle as t };
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./inject-style-Boo8CMsU.cjs`),t=require(`./cppay-D2T3pCwj.cjs`);let n=require(`qrcode`);n=e.r(n);let r=require(`rxjs`),i=require(`rxjs/operators`),a=require(`viem`),o=require(`viem/chains`),s=require(`@reown/appkit`),c=require(`@reown/appkit-adapter-ethers`),l=require(`react`);l=e.r(l);let u=require(`react/jsx-runtime`);var d=({open:e,onClose:d,apikey:f,plain:p,orderId:m,amount:h,intervalDays:ee,onExpired:te,onSuccess:g,onFailed:ne,onError:_})=>{let v=(0,l.useMemo)(()=>new t.t(f),[f]),[y,b]=(0,l.useState)(`select`),[x,S]=(0,l.useState)(!1),[C,w]=(0,l.useState)(!1),[T,E]=(0,l.useState)(),[D,O]=(0,l.useState)(!1),[k,re]=(0,l.useState)([]),[A,j]=(0,l.useState)(),[M,N]=(0,l.useState)(),[P,ie]=(0,l.useState)(),[F,I]=(0,l.useState)(),[L,R]=(0,l.useState)(!1),[z,B]=(0,l.useState)(),V=(0,l.useRef)(null),H=(0,l.useRef)(null);(0,l.useEffect)(()=>{typeof window<`u`&&!V.current&&(V.current=(0,s.createAppKit)({debug:!1,enableNetworkSwitch:!1,adapters:[new c.EthersAdapter],projectId:`8d2e1854d3f1782e45aa15fbd8938894`,allowUnsupportedChain:!0,networks:[o.mainnet,o.bsc,o.polygon,o.arbitrum,o.optimism,o.base],metadata:{name:`Cppay`,description:`Cppay Payment Gateway`,url:window.location.origin,icons:[`https://cppay.com/icon.png`]},features:{analytics:!1}}),I(V.current.getAddress()),B(V.current.getProvider(`eip155`)),V.current.subscribeAccount(e=>{e.isConnected?I(e.address):(I(void 0),B(void 0))}),V.current.subscribeProviders(e=>{let t=e?.eip155;B(t)}))},[]);let U=async()=>{try{R(!0),E(void 0),V.current&&await V.current.open()}catch(e){console.error(`钱包连接失败:`,e),E(e instanceof Error?e.message:`钱包连接失败`),_?.(e)}finally{R(!1)}},W=(0,l.useMemo)(()=>k.find(e=>e.chain===A),[k,A]),G=(0,l.useMemo)(()=>W?.tokens||[],[W]),K=(0,l.useMemo)(()=>G.find(e=>e.symbol===M),[G,M]),q=e=>[`USDT`,`USDC`,`BUSD`,`DAI`,`TUSD`,`USDD`,`FDUSD`].includes(e.toUpperCase())?2:6,J=(e,t)=>{let n=parseFloat(e);return isNaN(n)?`0`:n.toFixed(t).replace(/\.?0+$/,``)},Y=(0,l.useMemo)(()=>{if(!M||!K)return`0`;let e=parseFloat(K.price);if(isNaN(e)||e===0)return`0`;let t=q(M);return J((parseFloat(h)/e).toFixed(t),t)},[h,M,K]),ae=async()=>{try{S(!0),E(void 0);let e=await v.getSupportedChains();re(e),e.length>0&&j(e[0].chain)}catch(e){E(e instanceof Error?e.message:`加载支付网络失败`),_?.(e)}finally{S(!1)}},X=async e=>{if(z)try{await z.request({method:`wallet_switchEthereumChain`,params:[{chainId:`0x${e.toString(16)}`}]})}catch(e){throw e.code===4902?Error(`请在钱包中添加该网络`):e}},oe=async()=>{if(!(!F||!z||!Z.current||!K||!W))try{S(!0);let e=Z.current;await X(W.chainId);let t=(0,a.createWalletClient)({account:F,transport:(0,a.custom)(z)});if(K.address){let n=await t.writeContract({address:K.address,abi:[{name:`transfer`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`to`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`transfer`,args:[e.receiveAddress,(0,a.parseUnits)(e.paymentAmount,K.decimals)],chain:null});console.log(`转账交易哈希:`,n)}else{let n=await t.sendTransaction({to:e.receiveAddress,value:(0,a.parseUnits)(e.paymentAmount,K.decimals),chain:null});console.log(`转账交易哈希:`,n)}S(!1),w(!0),Q(e.paymentId)}catch(e){console.error(`钱包支付失败:`,e),E(e instanceof Error?e.message:`钱包支付失败`),_?.(e),S(!1)}},se=async()=>{if(!(!F||!z||!Z.current||!K||!W))try{S(!0);let e=Z.current;await X(W.chainId);let t=(0,a.createWalletClient)({account:F,transport:(0,a.custom)(z)});if(!K.address)throw Error(`订阅支付不支持原生代币`);let n=await t.writeContract({address:K.address,abi:[{name:`approve`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`spender`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`approve`,args:[e.spenderAddress,(0,a.parseUnits)(e.approveAmount,K.decimals)],chain:null});console.log(`授权交易哈希:`,n),S(!1),w(!0),Q(e.subscriptionId)}catch(e){console.error(`钱包授权失败:`,e),E(e instanceof Error?e.message:`钱包授权失败`),_?.(e),S(!1)}},ce=async()=>{if(!F){let e=`请先连接钱包`;E(e),_?.(Error(e));return}p===`one-time`?await oe():p===`subscription`&&await se()},Z=(0,l.useRef)(null),le=async()=>{if(!(!A||!M))try{S(!0),E(void 0);let e=``;p===`one-time`?(Z.current=await v.createOnetimePayment({paymentChain:A,paymentToken:M,orderId:m,amount:Y}),e=`${A.toLowerCase()}:${Z.current.receiveAddress}?amount=${Z.current.paymentAmount}`):p===`subscription`&&(Z.current=await v.createSubscriptionPayment({paymentChain:A,paymentToken:M,orderId:m,amountOfUsd:Y,intervalDays:ee||30}),e=`${A.toLowerCase()}:${Z.current.spenderAddress}?amount=${Z.current.approveAmount}`),b(`payment`),ie(await n.toDataURL(e,{width:200,margin:2,errorCorrectionLevel:`H`}))}catch(e){E(e instanceof Error?e.message:`创建支付失败`),_?.(e)}finally{S(!1)}},ue=async()=>{if(Z.current)try{w(!0),E(void 0),p===`one-time`?Q(Z.current.paymentId):p===`subscription`&&Q(Z.current.subscriptionId)}catch(e){console.error(`支付状态检查错误:`,e),E(e instanceof Error?e.message:`检查支付状态失败`),_?.(e),w(!1)}},Q=e=>{let t=()=>(0,r.defer)(()=>p===`subscription`?v.checkSubscriptionPaymentStatus({subscriptionId:e}):v.checkOnetimePaymentStatus({paymentId:e})).pipe((0,i.timeout)(15e3),(0,i.retry)({count:3,delay:2e3}));H.current?.unsubscribe(),H.current=t().pipe((0,i.expand)(e=>e.status===`pending`?(0,r.timer)(2e3).pipe((0,i.switchMap)(()=>t())):r.EMPTY),(0,i.tap)(e=>{e.status===`expired`&&(w(!1),te?.(e)),e.status===`paid`&&(w(!1),b(`success`),g?.(e)),e.status===`failed`&&(w(!1),ne?.(e)),e.status===`approved`&&(w(!1),b(`success`),g?.(e))})).subscribe({error:e=>{console.error(`支付状态检查错误:`,e),E(e instanceof Error?e.message:`检查支付状态失败`),w(!1),_?.(e)}})},de=async()=>{if(!Z.current)return;let e=p===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress;e&&await navigator.clipboard.writeText(e)},$=()=>{x||C||(d(),setTimeout(()=>{b(`select`),E(void 0),Z.current=null},300))};return(0,l.useEffect)(()=>{e&&k.length===0&&ae()},[e]),(0,l.useEffect)(()=>{G.length>0&&N(G[0].symbol)},[G]),(0,l.useEffect)(()=>()=>{H.current?.unsubscribe()},[]),e?(0,u.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&!x&&!C&&$(),children:(0,u.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,u.jsxs)(`div`,{className:`_cppay-header`,children:[(0,u.jsx)(`h2`,{className:`_cppay-title`,children:y===`select`?`选择支付方式`:`完成支付`}),(0,u.jsx)(`button`,{onClick:$,disabled:x||C,className:`_cppay-close-btn`,children:(0,u.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,u.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,u.jsx)(`div`,{className:`_cppay-content`,children:y===`success`?(0,u.jsxs)(`div`,{style:{textAlign:`center`,padding:`2rem 0`},children:[(0,u.jsx)(`div`,{style:{fontSize:`64px`,marginBottom:`1rem`},children:`✅`}),(0,u.jsx)(`h3`,{style:{fontSize:`1.5rem`,fontWeight:600,color:`#10b981`,margin:`0 0 0.5rem 0`},children:p===`subscription`?`授权成功!`:`支付成功!`}),(0,u.jsx)(`p`,{style:{color:`#6b7280`,margin:0},children:p===`subscription`?`订阅已激活`:`交易已完成`})]}):y===`select`?(0,u.jsxs)(`div`,{children:[(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:`支付网络`}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:k.map(e=>(0,u.jsxs)(`button`,{onClick:()=>j(e.chain),className:`_cppay-select-btn ${A===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,u.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[(0,u.jsx)(`label`,{className:`_cppay-label`,children:`支付代币`}),(0,u.jsx)(`div`,{className:`_cppay-grid`,children:G.map(e=>(0,u.jsxs)(`button`,{onClick:()=>N(e.symbol),className:`_cppay-select-btn ${M===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,u.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,u.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`div`,{className:`_cppay-price-box`,children:(0,u.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,u.jsx)(`span`,{className:`_cppay-price-label`,children:`支付金额`}),(0,u.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,u.jsxs)(`div`,{className:`_cppay-price-main`,children:[Y??`-`,` `,M??``]}),(0,u.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,h]})]})]})})}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[T&&(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip-wrapper`,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),children:[(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip`,children:[(0,u.jsx)(`svg`,{viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z`,clipRule:`evenodd`})}),(0,u.jsx)(`span`,{children:T})]}),D&&(0,u.jsx)(`div`,{className:`_cppay-error-tooltip-full`,children:T})]}),(0,u.jsx)(`button`,{onClick:le,disabled:!A||!M||x,className:`_cppay-btn _cppay-btn-primary`,children:x?`处理中...`:`继续支付`})]})]}):(0,u.jsxs)(`div`,{children:[(0,u.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,u.jsx)(`div`,{className:`_cppay-qr-code`,children:P&&(0,u.jsx)(`img`,{src:P,alt:`Payment QR Code`,style:{width:`160px`,height:`160px`,display:`block`}})})}),(0,u.jsxs)(`div`,{className:`_cppay-section`,children:[M&&(0,u.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,children:p===`subscription`?`授权金额`:`支付金额`}),(0,u.jsx)(`div`,{className:`_cppay-info-value`,children:p===`subscription`?`${J(Z.current.approveAmount,q(M))} ${M}`:`${J(Z.current.paymentAmount,q(M))} ${M}`})]}),(0,u.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,children:p===`subscription`?`授权合约地址`:`支付地址`}),(0,u.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,u.jsx)(`code`,{children:p===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress}),(0,u.jsx)(`button`,{onClick:de,className:`_cppay-copy-btn`,title:`复制地址`,children:(0,u.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,u.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]}),p===`subscription`&&(0,u.jsxs)(`div`,{className:`_cppay-info-box`,style:{background:`#fff3cd`,borderColor:`#ffc107`},children:[(0,u.jsx)(`div`,{className:`_cppay-info-label`,style:{color:`#856404`},children:`📌 订阅说明`}),(0,u.jsx)(`div`,{className:`_cppay-info-value`,style:{fontSize:`12px`,color:`#856404`},children:`订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。`})]})]}),T&&(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip-wrapper`,onMouseEnter:()=>O(!0),onMouseLeave:()=>O(!1),children:[(0,u.jsxs)(`div`,{className:`_cppay-error-tooltip`,children:[(0,u.jsx)(`svg`,{viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,u.jsx)(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z`,clipRule:`evenodd`})}),(0,u.jsx)(`span`,{children:T})]}),D&&(0,u.jsx)(`div`,{className:`_cppay-error-tooltip-full`,children:T})]}),!C&&(0,u.jsx)(`div`,{className:`_cppay-section`,children:F?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)(`div`,{className:`_cppay-btn-container`,children:[(0,u.jsx)(`button`,{onClick:ce,disabled:x,className:`_cppay-btn _cppay-btn-primary`,children:x?p===`subscription`?`授权中...`:`支付中...`:p===`subscription`?`💳 钱包授权`:`💳 钱包支付`}),(0,u.jsx)(`button`,{onClick:U,disabled:x,className:`_cppay-btn _cppay-btn-primary`,children:`💰钱包状态`})]}),(0,u.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`8px`,fontSize:`12px`,color:`#666`},children:[`已连接: `,F.slice(0,6),`...`,F.slice(-4)]})]}):(0,u.jsx)(`button`,{onClick:U,disabled:L,className:`_cppay-btn _cppay-btn-secondary`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5rem`,padding:`0.75rem 1rem`,width:`100%`},children:(0,u.jsx)(`span`,{children:L?`连接中...`:`💳 连接钱包`})})}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:ue,disabled:C,className:`_cppay-btn _cppay-btn-primary`,children:C?`检查中...`:`我已完成支付`})}),(0,u.jsx)(`div`,{className:`_cppay-section`,children:(0,u.jsx)(`button`,{onClick:()=>b(`select`),disabled:x||C,className:`_cppay-btn _cppay-btn-text`,children:`更改支付方式`})})]})})]})}):null},f=l.default.memo(d),p=(0,l.createContext)(null);const m=({apikey:e,children:t})=>{let[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)(null),o=(0,l.useCallback)(e=>{a(e),r(!0)},[]),s=(0,l.useCallback)(()=>{r(!1)},[]),c=(0,l.useCallback)(e=>{i?.onSuccess?.(e),r(!1)},[i]),d=(0,l.useCallback)(e=>{i?.onError?.(e)},[i]);return(0,u.jsxs)(p.Provider,{value:{showPayment:o},children:[t,i&&(0,u.jsx)(f,{open:n,onClose:s,apikey:e,plain:i.plain,orderId:i.orderId,amount:i.amount,intervalDays:i.intervalDays,onSuccess:c,onError:d})]})},h=()=>{let e=(0,l.useContext)(p);if(!e)throw Error(`useCppayPayment must be used within CppayProvider`);return e};e.t(e.n),exports.CppayProvider=m,exports.PaymentDialog=f,exports.useCppayPayment=h;
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare type Address = `0x${string}`;
|
|
5
|
+
|
|
6
|
+
declare interface CppayContextValue {
|
|
7
|
+
showPayment: (options: PaymentOptions_2) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export declare const CppayProvider: default_2.FC<CppayProviderProps>;
|
|
11
|
+
|
|
12
|
+
declare interface CppayProviderProps {
|
|
13
|
+
apikey: string;
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare type Numberic = `${number}.${number}` | `${number}`;
|
|
18
|
+
|
|
19
|
+
declare interface OnetimePaymentOrderStatus {
|
|
20
|
+
orderId: string;
|
|
21
|
+
paymentId: string;
|
|
22
|
+
chain: string;
|
|
23
|
+
token: string;
|
|
24
|
+
baseAmount: Numberic;
|
|
25
|
+
payAmount: Numberic;
|
|
26
|
+
receiveAddress: Address;
|
|
27
|
+
expireAt: number;
|
|
28
|
+
status: PaymentStatus;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export declare const PaymentDialog: default_2.NamedExoticComponent<PaymentDialogProps>;
|
|
32
|
+
|
|
33
|
+
declare interface PaymentDialogProps {
|
|
34
|
+
open: boolean;
|
|
35
|
+
onClose: () => void;
|
|
36
|
+
apikey: string;
|
|
37
|
+
plain: PaymentPlain;
|
|
38
|
+
orderId: string;
|
|
39
|
+
amount: string;
|
|
40
|
+
intervalDays?: number;
|
|
41
|
+
onSuccess?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
42
|
+
onExpired?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
43
|
+
onFailed?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
declare interface PaymentOptions_2 {
|
|
48
|
+
plain: PaymentPlain;
|
|
49
|
+
orderId: string;
|
|
50
|
+
amount: string;
|
|
51
|
+
intervalDays?: number;
|
|
52
|
+
onSuccess?: (order: SubscriptionPaymentOrderStatus | OnetimePaymentOrderStatus) => void;
|
|
53
|
+
onError?: (error: Error) => void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
declare type PaymentPlain = "one-time" | "subscription" | "x402";
|
|
57
|
+
|
|
58
|
+
declare type PaymentStatus = "pending" | "paid" | "expired" | "failed";
|
|
59
|
+
|
|
60
|
+
declare interface SubscriptionPaymentOrderStatus {
|
|
61
|
+
orderId: string;
|
|
62
|
+
subscriptionId: string;
|
|
63
|
+
chain: string;
|
|
64
|
+
token: string;
|
|
65
|
+
approvedAddress: string;
|
|
66
|
+
txHash: string;
|
|
67
|
+
approveAmount: string;
|
|
68
|
+
amountOfUsd: string;
|
|
69
|
+
expireAt: number;
|
|
70
|
+
status: SubscriptionPaymentStatus;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare type SubscriptionPaymentStatus = "pending" | "approved" | "expired" | "failed";
|
|
74
|
+
|
|
75
|
+
export declare const useCppayPayment: () => CppayContextValue;
|
|
76
|
+
|
|
77
|
+
export { }
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
declare module "@vue/runtime-core" {
|
|
81
|
+
interface ComponentCustomProperties {
|
|
82
|
+
$showPayment: typeof showPayment;
|
|
83
|
+
}
|
|
84
|
+
}
|