I am working on a Stripe Checkout Extension that redirects to the Stripe checkout page.
I have created my own extension: myvendor/StripeCheckout.
Here is the code for my StripeCheckout controller.
namespace MyVendor\StripeCheckout\Payments;
use Igniter\PayRegister\Payments\BasePaymentGateway;
use Stripe\Stripe;
use Stripe\Checkout\Session;
class StripeCheckout extends BasePaymentGateway
{
public function getConfig()
{
return [
'code' => 'stripe_checkout',
'name' => 'Stripe Checkout',
'description' => 'Pay with Stripe Checkout',
];
}
public function getConfigFields()
{
return [
'stripe_live_secret_key' => [
'label' => 'Live Secret Key',
'span' => 'left',
'type' => 'text',
],
'stripe_live_publishable_key' => [
'label' => 'Live Publishable Key',
'span' => 'right',
'type' => 'text',
],
'stripe_test_secret_key' => [
'label' => 'Test Secret Key',
'span' => 'left',
'type' => 'text',
],
'stripe_test_publishable_key' => [
'label' => 'Test Publishable Key',
'span' => 'right',
'type' => 'text',
],
'mode' => [
'label' => 'Mode',
'type' => 'radio',
'options' => [
'live' => 'Live',
'test' => 'Test',
],
'default' => 'test',
],
];
}
public function processPaymentForm($data, $host, $order)
{
$mode = $this->getSetting('mode');
$secretKey = $mode == 'live' ? $this->getSetting('stripe_live_secret_key') : $this->getSetting('stripe_test_secret_key');
Stripe::setApiKey($secretKey);
$session = Session::create([
'payment_method_types' => ['card'],
'line_items' => [[
'price_data' => [
'currency' => $order->currency_code,
'product_data' => [
'name' => 'Order #' . $order->order_id,
],
'unit_amount' => $order->order_total * 100,
],
'quantity' => 1,
]],
'mode' => 'payment',
'success_url' => url('/checkout/success?session_id={CHECKOUT_SESSION_ID}'),
'cancel_url' => url('/checkout/cancel'),
]);
return redirect($session->url);
}
}
When I try to edit payment method I get the following error:
Call to undefined method Admin\Models\Payments_model::getConfigFields()" on line 71 of /homepages/u71705/demo/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php#0 /homepages/u71705/demo/vendor/laravel/framework/src/Illuminate/Support/Traits/ForwardsCalls.php(36): Illuminate\Database\Eloquent\Model::throwBadMethodCallException(‘getConfigFields’)
#1 /homepages/u71705/demo/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(2132): Illuminate\Database\Eloquent\Model->forwardCallTo(Object(Igniter\Flame\Database\Builder), ‘getConfigFields’, Array)
Thank you in advance for your help