@virgodev/iap 1.0.3 → 1.0.4

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.
@@ -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 = defineProps<{
89
- cart: StripeCart;
90
- returnUrl: string;
91
- email: string;
92
- vertical: false;
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
- showPaymentMessage(`${result.error.code}: ${result.error.message}`);
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@virgodev/iap",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "./index.ts",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"