Я абсолютно ничего не могу найти, чтобы помочь мне интегрировать полосу с Laravel 5.2. Это было сложным, чтобы узнать эту структуру из-за многих Устаревшие между версиями :(Single Charge With StripeJS с использованием Laravel 5.2
Во всяком случае, вот что я работаю с
JS-файла для захвата входа
$(function() {
var $form = $('#payment-form');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from being submitted:
return false;
});
});
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
var CSRF_TOKEN = $('meta[name="csrf-token"]').attr('content');
if (response.error) { // Problem!
// Show the errors on the form:
$form.find('.payment-errors').text(response.error.message);
$form.find('.submit').prop('disabled', false); // Re-enable submission
} else { // Token was created!
// Get the token ID:
var token = response.id;
console.log(token);
// Insert the token ID into the form so it gets submitted to the server:
$form.append($('<input type="hidden" name="stripeToken">').val(token));
// Submit the form:
$form.get(0).submit();
}
};
когда форма делается я маршрут пользователь {{ route('success') }}
через атрибут action=""
в форме.
Route::any('/success', ['as' => 'success', 'uses' =>'[email protected]']);
вот мой контроллер с код, предоставляемый полоска ... как вы можете видеть, что это не будет работать
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Requests\CreateSongRequest;
use Illuminate\Foundation\Http\FormRequest;
use Billable;
use Input;
class ChargeController extends Controller
{
public function pay(Request $request){
if(Input::has('stripeToken')){
$token = Input::get('stripeToken');
$amount = 10;
// I cannot use this part even though it is in the stripe documentation
$customer = Stripe_Customer::create(array(
'card' => $token
));
$charge = Stripe_Charge::create(array(
'customer' => $customer->id,
'amount' => ($amount*100),
'currency' => 'usd',
'description' => "test"
));
echo 'success!';
}
}
}
Я смотрю на использование StripeJS documentation вместо кассира. В настоящее время я смотрю на эту ошибку
Fatal error: Class 'App\Http\Controllers\Stripe_Customer' not found
И вот где документация заканчивается. Любая помощь? Я бы предпочел использовать кассир, но я не могу найти никакой документации для использования без подписки, а веб-сайт laravel не очень помогает.
у вас есть класс Stripe_Customer? –
Эта ошибка ищет контроллер, существует ли Stripe_Controller в этом месте? –
@AchrafKhouadja класс не существует, потому что нет учебников, чтобы рассказать мне, что добавить туда. документы StripeJS останавливаются там –