Я прошел обучение электронной коммерции, используя laravel, и я хочу совершить онлайн-платеж с помощью корзины PayPal, но это дает мне ошибку в поле payment_gateway
таблиц заказов, Column not found: 1054 Field 'payment_gateway' unknown in field list
.
Здравствуйте , Я прошел обучение электронной коммерции с использованием laravel, и я хочу произвести онлайн-платеж с помощью корзины PayPal, но это дает мне ошибку в поле payment_gateway
таблиц заказов, Column not found: 1054 Field 'payment_gateway' unknown in field list
.
checkoutController. php
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function paypalCheckout(Request $request)
{
// Check race condition when there are less items available to purchase
if ($this->productsAreNoLongerAvailable()) {
return back()->withErrors('Sorry! One of the items in your cart is no longer avialble.');
}
$gateway = new \Braintree\Gateway([
'environment' => config('services.braintree.environment'),
'merchantId' => config('services.braintree.merchantId'),
'publicKey' => config('services.braintree.publicKey'),
'privateKey' => config('services.braintree.privateKey')
]);
$nonce = $request->payment_method_nonce;
$result = $gateway->transaction()->sale([
'amount' => round(getNumbers()->get('newTotal') / 100, 2),
'paymentMethodNonce' => $nonce,
'options' => [
'submitForSettlement' => true
]
]);
$transaction = $result->transaction;
if ($result->success) {
$order = $this->addToOrdersTablesPaypal(
$transaction->paypal['payerEmail'],
$transaction->paypal['payerFirstName'].' '.$transaction->paypal['payerLastName'],
null
);
Mail::send(new OrderPlaced($order));
// decrease the quantities of all the products in the cart
$this->decreaseQuantities();
Cart::instance('default')->destroy();
session()->forget('coupon');
return redirect()->route('confirmation.index')->with('success_message', 'Thank you! Your payment has been successfully accepted!');
} else {
$order = $this->addToOrdersTablesPaypal(
$transaction->paypal['payerEmail'],
$transaction->paypal['payerFirstName'].' '.$transaction->paypal['payerLastName'],
$result->message
);
return back()->withErrors('An error occurred with the message: '.$result->message);
}
}
функция addToOrdersTablesPaypal
protected function addToOrdersTablesPaypal($email, $name, $error)
{
// Insert into orders table
$order = Order::create([
'user_id' => auth()->user() ? auth()->user()->id : null,
'billing_email' => $email,
'billing_name' => $name,
'billing_discount' => getNumbers()->get('discount'),
'billing_discount_code' => getNumbers()->get('code'),
'billing_subtotal' => getNumbers()->get('newSubtotal'),
'billing_tax' => getNumbers()->get('newTax'),
'billing_total' => getNumbers()->get('newTotal'),
'error' => $error,
'payment_gateway' => 'paypal',
]);
// Insert into order_product table
foreach (Cart::content() as $item) {
OrderProduct::create([
'order_id' => $order->id,
'product_id' => $item->model->id,
'quantity' => $item->qty,
]);
}
return $order;
}
таблица заказов
ошибка