403 ошибка запрещенного ответа при инициализации платежа - PullRequest
0 голосов
/ 07 июля 2019

Я пытаюсь интегрировать платеж Paystack в мой проект Laravel. Он отлично работает в среде разработки, так как возвращает успех. Однако, когда я перемещаю проект в производство, он возвращает следующую ошибку.

Ошибка клиента: POST https://api.paystack.co/transaction/initialize в результате 403 Запрещенный ответ

лезвие

<form method="POST" action="{{ route('pay') }}" accept-charset="UTF-8" class="form-horizontal" role="form">
    <div class="row" style="margin-bottom:40px;">
        <div class="col-md-8 col-md-offset-2">
            <div>

                <p><strong><i>*You are required to make a payment of N5,000 as Application and Processing
                            fee</i></strong></p>
            </div>
        </div>
        <input type="hidden" name="email" value="{{ Auth::user()->email }}"> {{-- required --}}
        <input type="hidden" name="orderID" value="{{ Auth::user()->id }}">
        <input type="hidden" name="amount" value="500000"> {{-- required in kobo --}}
        <input type="hidden" name="quantity" value="3">
        <input type="hidden" name="metadata"
               value="{{ json_encode($array = ['key_name' => 'value',]) }}"> {{-- For other necessary things you want to add to your payload. it is optional though --}}
        <input type="hidden" name="reference" value="{{ Paystack::genTranxRef() }}"> {{-- required --}}
        <input type="hidden" name="key" value="{{ config('paystack.secretKey') }}"> {{-- required --}}
        {{ csrf_field() }} {{-- works only when using laravel 5.1, 5.2 --}}
        <input type="hidden" name="_token"
               value="{{ csrf_token() }}"> {{-- employ this in place of csrf_field only in laravel 5.0 --}}
        <p>
            <button class="btn btn-success btn-lg btn-block text-center" type="submit" value="Pay Now!">
                <i class="fa fa-plus-circle fa-lg"></i> Process My Application
            </button>
        </p>
    </div>
</form>

Контроллер

class PaymentController extends Controller
{
    /**
     * Redirect the User to Paystack Payment Page
     */
    public function redirectToGateway()
    {
        return Paystack::getAuthorizationUrl()->redirectNow();
    }

    /**
     * Obtain Paystack payment information
     */
    public function handleGatewayCallback()
    {
        $paymentDetails = Paystack::getPaymentData();

        // Now you have the payment details,
        // you can store the authorization_code in your db to allow for recurrent subscriptions
        // you can then redirect or do whatever you want
        if (array_key_exists('data', $paymentDetails) && array_key_exists('status',
                $paymentDetails['data']) && ($paymentDetails['data']['status'] === 'success')) {
            echo 'Transaction Was Successful';

            if (auth()->user()->update(['reference' => $paymentDetails['data']['reference']])) {

                \Mail::to(Auth::user()->email)->send(new Payments(Auth::user()));
                \Mail::to('info@example.com')->send(new Confirmation(Auth::user()));
            }
        } else {
            echo 'Transaction Was Unsuccessful';
        }

        return redirect()->back()->with('success', 'Your Payment Was Received. Thank You.');
    }
}
...