Skip to content

Commit 2936343

Browse files
display payment by stripe
1 parent f7c8f02 commit 2936343

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

client/components/open/forms/OpenForm.vue

+17-4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,17 @@
119119
<div v-if="!currentFieldsPageBreak && !isLastPage">
120120
{{ $t('forms.wrong_form_structure') }}
121121
</div>
122+
<div
123+
v-if="paymentBlock"
124+
class="text-xs text-gray-500 mt-2"
125+
>
126+
<template v-if="isLastPage">
127+
Your credit card will be charged upon clicking the "Submit" button. Payments are securely processed through Stripe.
128+
</template>
129+
<template v-else>
130+
Your credit card will be charged upon clicking the "Next" button. Payments are securely processed through Stripe.
131+
</template>
132+
</div>
122133
</div>
123134
</form>
124135
</template>
@@ -302,6 +313,9 @@ export default {
302313
return {
303314
'--form-color': this.form.color
304315
}
316+
},
317+
paymentBlock() {
318+
return this.currentFields.find(field => field.type === 'payment')
305319
}
306320
},
307321
@@ -547,14 +561,13 @@ export default {
547561
async doPayment() {
548562
// If there is a payment block, process the payment
549563
const { state: stripeState, processPayment } = useStripeElements()
550-
const paymentBlock = this.currentFields.find(field => field.type === 'payment')
551-
if (paymentBlock && !stripeState.value.intentId && (paymentBlock.required || !stripeState.value.card._empty)) {
564+
if (this.paymentBlock && !stripeState.value.intentId && (this.paymentBlock.required || !stripeState.value.card._empty)) {
552565
try {
553566
// Process the payment
554-
const result = await processPayment(this.form.slug, paymentBlock.required)
567+
const result = await processPayment(this.form.slug, this.paymentBlock.required)
555568
console.log('result', result)
556569
if (result && result?.error) {
557-
this.dataForm.errors.set(paymentBlock.id, result.error.message)
570+
this.dataForm.errors.set(this.paymentBlock.id, result.error.message)
558571
useAlert().error(result.error.message)
559572
return false
560573
}

0 commit comments

Comments
 (0)