@virgodev/iap 1.0.3 → 1.0.5
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/components/StripeCheckout.vue +23 -7
- package/components/StripePopup.vue +1 -8
- package/package.json +1 -1
- package/stores/iap.ts +12 -0
|
@@ -85,18 +85,26 @@ import type { StripeCart } from "../stores/iap";
|
|
|
85
85
|
import Message from "primevue/message";
|
|
86
86
|
import Button from "primevue/button";
|
|
87
87
|
|
|
88
|
-
const props =
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
88
|
+
const props = withDefaults(
|
|
89
|
+
defineProps<{
|
|
90
|
+
cart: StripeCart;
|
|
91
|
+
returnUrl: string;
|
|
92
|
+
email: string;
|
|
93
|
+
vertical: boolean;
|
|
94
|
+
}>(),
|
|
95
|
+
{ vertical: false }
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const emits = defineEmits<{
|
|
99
|
+
start: [];
|
|
100
|
+
end: [string];
|
|
93
101
|
}>();
|
|
94
102
|
|
|
95
103
|
const iap = useIapStore();
|
|
96
104
|
|
|
97
105
|
const isLoading = ref<boolean>(false);
|
|
98
106
|
const messageText = ref("");
|
|
99
|
-
const sessionResponse = ref<any>();
|
|
107
|
+
const sessionResponse: any = ref<any>();
|
|
100
108
|
|
|
101
109
|
let checkout: StripeCheckout | null = null;
|
|
102
110
|
let loadActionsResult: StripeCheckoutLoadActionsResult | null = null;
|
|
@@ -178,7 +186,9 @@ function setLoading(loading: boolean) {
|
|
|
178
186
|
}
|
|
179
187
|
|
|
180
188
|
async function handleSubmit() {
|
|
189
|
+
console.log("Submitting payment");
|
|
181
190
|
setLoading(true);
|
|
191
|
+
emits("start");
|
|
182
192
|
|
|
183
193
|
if (loadActionsResult?.type === "success") {
|
|
184
194
|
const result = await loadActionsResult.actions.confirm({
|
|
@@ -187,14 +197,20 @@ async function handleSubmit() {
|
|
|
187
197
|
props.returnUrl + "?stripe_session_id=" + sessionResponse.value.id,
|
|
188
198
|
});
|
|
189
199
|
if (result.type === "error") {
|
|
190
|
-
|
|
200
|
+
const errorContent = `${result.error.code}: ${result.error.message}`;
|
|
201
|
+
emits("end", errorContent);
|
|
202
|
+
showPaymentMessage(errorContent);
|
|
191
203
|
} else {
|
|
192
204
|
// TODO: verify with server
|
|
193
205
|
// TODO: connect purchaseItem with a promise resolve function
|
|
206
|
+
emits("end", "");
|
|
194
207
|
}
|
|
208
|
+
} else {
|
|
209
|
+
emits("end", "");
|
|
195
210
|
}
|
|
196
211
|
|
|
197
212
|
setLoading(false);
|
|
213
|
+
console.log("done Submitting payment");
|
|
198
214
|
}
|
|
199
215
|
</script>
|
|
200
216
|
|
|
@@ -58,14 +58,7 @@ onMounted(() => {});
|
|
|
58
58
|
|
|
59
59
|
function closeDialog(v: boolean): void {
|
|
60
60
|
if (v === false) {
|
|
61
|
-
|
|
62
|
-
iap.stripe.callback(undefined);
|
|
63
|
-
}
|
|
64
|
-
iap.stripe.callback = undefined;
|
|
65
|
-
iap.stripe.result = undefined;
|
|
66
|
-
iap.stripe.cart = undefined;
|
|
67
|
-
iap.stripe.status = undefined;
|
|
68
|
-
iap.stripe.error = undefined;
|
|
61
|
+
iap.stripe.reset();
|
|
69
62
|
visible.value = false;
|
|
70
63
|
}
|
|
71
64
|
}
|
package/package.json
CHANGED
package/stores/iap.ts
CHANGED
|
@@ -286,6 +286,17 @@ export const useIapStore = defineStore("iap", () => {
|
|
|
286
286
|
});
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
+
function reset() {
|
|
290
|
+
if (stripeCallback.value) {
|
|
291
|
+
stripeCallback.value(undefined);
|
|
292
|
+
}
|
|
293
|
+
stripeCallback.value = undefined;
|
|
294
|
+
stripeResult.value = undefined;
|
|
295
|
+
stripeCart.value = undefined;
|
|
296
|
+
stripeStatus.value = undefined;
|
|
297
|
+
stripeError.value = undefined;
|
|
298
|
+
}
|
|
299
|
+
|
|
289
300
|
return {
|
|
290
301
|
products,
|
|
291
302
|
platform,
|
|
@@ -307,6 +318,7 @@ export const useIapStore = defineStore("iap", () => {
|
|
|
307
318
|
result: stripeResult,
|
|
308
319
|
callback: stripeCallback,
|
|
309
320
|
error: stripeError,
|
|
321
|
+
reset,
|
|
310
322
|
},
|
|
311
323
|
};
|
|
312
324
|
});
|