我认为我搞砸了csrf_field(),但我确实推了X-CSRF-TOKEN ......之前我遇到了419错误但让自己陷入了麻烦......
错误 - POST / betaling 500 - 未捕获(承诺)响应{url:“/ betaling”,ok:false,状态:500,statusText:“内部服务器错误”,标题:标题
标题
<script>
var Cityofcompanies = {
csrfToken: "{{ csrf_token() }}",
stripeKey: "{{ config('services.stripe.key') }}"
};
路线
Route::post('betaling', 'PaymentController@store')->name('payment');
App.js
window.Vue = require('vue');
require('vue-resource');
Vue.http.interceptors.push((request, next) => {
request.headers.set('X-CSRF-TOKEN', Cityofcompanies.csrfToken);
next();
});
Vue.component('CheckoutForm',
require('./components/CheckoutForm.vue'));
CheckoutForm.vue
<template>
<form action="/betaling" method="POST">
<input type="hidden" name="stripeToken" v-model="stripeToken">
<input type="hidden" name="stripeEmail" v-model="stripeEmail">
<button type="submit" @click.prevent="buy">Abonneer</button>
</form>
</template>
<script>
export default {
data() {
return {
stripeEmail: '',
stripeToken: ''
};
},
created() {
this.stripe = StripeCheckout.configure({
key: Cityofcompanies.stripeKey,
image:"https://stripe.com/img/documentation/checkout/marketplace.png",
locale: "auto",
currency: "eur",
token: (token) => {
this.stripeToken = token.id;
this.stripeEmail = token.email;
this.$http.post('/betaling', this.$data);
//.then(response => alert('Bedankt voor het abonneren!'));
}
});
},
methods: {
buy() {
this.stripe.open({
name: "Abonneer voor 1 jaar",
description: "Professional Version",
amount: 5000,
});
}
}
}
</script>
Show.blade.php
<div id="checkout">
<checkout-form></checkout-form>
</div>
<script>
window.onload = function () {
const app = new Vue({
el: '#checkout'
});
}
</script>
<script src="https://checkout.stripe.com/checkout.js"></script>
答案 0 :(得分:0)
您需要查看/betaling
端点的日志,以查看此处可能出现的错误。