7171 </v-btn >
7272
7373 <!-- Payment section if not subscribed -->
74- <div v-else >
75- <ChatVisualizationPayment
76- :amount =" price "
77- :currency =" currency "
78- @onApprove =" onApprove "
79- @onCreateOrder =" onCreateOrder "
80- @onError =" onError "
81- />
74+ <div v-else class =" text-center" >
75+ <v-btn
76+ color =" success"
77+ size =" large"
78+ class =" mb-3"
79+ :loading =" isOneTimeLoading"
80+ @click =" payOneTimeStripe"
81+ >
82+ <v-icon class =" mr-1" >mdi-credit-card</v-icon >
83+ <span
84+ >{{ $t("chooseOneTime") }} ({{ price }} {{ currency }})</span
85+ >
86+ </v-btn >
8287 <v-alert density =" compact" type =" info" prominent >
8388 <span v-html =" $t('subscriptionHint')" ></span >
84- <v-btn to =" /subscribe" >
89+ <v-btn to =" /subscribe" class = " ml-2 " variant = " tonal " >
8590 <span v-html =" $t('openSubscriptionPage')" ></span >
8691 </v-btn >
8792 </v-alert >
208213import { saveAs } from " file-saver" ;
209214import { markRaw } from " vue" ;
210215import { GTAG_PAYMENT , GTAG_PDF , gtagEvent } from " ~/utils/gtagValues" ;
216+ import { fetchOneTimeCheckoutUrl } from " ~/utils/subscription" ;
211217import PDFWorker from " ~/assets/js/pdf.worker.js?worker" ;
212218import { loadImage , objectToDictionary } from " ~/utils/utils" ;
213219
@@ -224,6 +230,7 @@ export default {
224230 return {
225231 showDownloadPopup: false ,
226232 isLoading: false ,
233+ isOneTimeLoading: false ,
227234 GTAG_PAYMENT ,
228235 GTAG_PDF ,
229236 progress: 0 ,
@@ -243,14 +250,23 @@ export default {
243250 this .download (false );
244251 this .showDownloadPopup = false ;
245252 },
246- onCreateOrder () {
253+ async payOneTimeStripe () {
254+ if (this .isOneTimeLoading ) return ;
247255 gtagEvent (" created" , GTAG_PAYMENT , 0 );
256+ this .isOneTimeLoading = true ;
257+ try {
258+ const url = await fetchOneTimeCheckoutUrl ({
259+ successUrl: ` ${ window .location .origin } /?session_id={CHECKOUT_SESSION_ID}&payment_success=true` ,
260+ cancelUrl: window .location .href ,
261+ });
262+ if (! url) throw new Error (" No checkout URL returned" );
263+ window .location .assign (url);
264+ } catch (err) {
265+ console .error (" Error creating one-time Stripe checkout:" , err);
266+ alert (" Failed to start checkout. Please try again." );
267+ this .isOneTimeLoading = false ;
268+ }
248269 },
249- onApprove () {
250- gtagEvent (" approved" , GTAG_PAYMENT , 10 );
251- this .downloadFull ();
252- },
253- onError () {},
254270 async download (isSample = false ) {
255271 if (! import .meta.client) return;
256272
0 commit comments