Stripe Payment Issue

Brand new to InvoicePlane, seems great so far. I tried to integrate it with Stripe tonight, using test API keys, and am getting this error:

Payment failed. Please try again.
Invalid request: unsupported Content-Type . If error persists and you need assistance, please contact support at Stripe: Help & Support.

I have debug logging on but there was nothing telltale generated in the log file.

I’ve perused the Internet and this forum and while I did see some other posts about various Stripe issues, I didn’t find anything about this one.

I’m using version 1.6, with PHP 8.1 and NGINX, hosted on an Ubuntu server. I’m guessing this is something with the integration to Stripe, and not something that I’ve done, and am hoping for some guidance on getting it resolved.

Hey, welcome,
If you want, i can guide you through making a pull-request.
Fiest things first, you need to go to the location where the ‘payment’ towards Stripe is made.
I think it’s this file:
application/modules/guest/controllers/Payment_handler.php
This piece: $response = $gateway->purchase($request)->send(); sends the request.

We have to add extra things to the sending of the request, to satisfy Stripe’s Api.

Wether that’s in InvoicePlane or in the package that we use, omnipay, remains to be seen

Focus on this function: private function initialize_gateway($driver). In there, skme prelarations are done, right before we ask Omnipay for the ‘connection with Stripe’

Focus on this Stackoverflow answer: Laravel Omnipay/Stripe unable to send request on linux - Stack Overflow it has part of the solution

This was the issue at the omnipay github page Unable to send Stripe request · Issue #197 · thephpleague/omnipay-stripe · GitHub and a link to the solution: Laravel Omnipay/Stripe unable to send request on linux - Stack Overflow

Nobody else has a pending PR to resolve this?

I’m trying to solve the issue with my small PHP skill’s but I get error…

I have edited the file application/modules/guest/controllers/Payment_handler.php like this on the line 109 :

            // Send the request
//          $response = $gateway->purchase($request)->send();
            $response = $gateway->purchase([
                'headers' => ['Content-Type' => 'application/x-www-form-urlencoded'],
                'amount' => $amount,
                'currency' => $currency,
                'token' => $token,
                'confirm' => true,
                'description' => auth()->user()->name
            ])->send();

Now, I get this error after payment :


A PHP Error was encountered

Severity: Warning

Message: Undefined variable $amount

Filename: controllers/Payment_handler.php

Line Number: 112

Backtrace:

File: /home/Hedy/web/mydomain.fr/public_html/application/modules/guest/controllers/Payment_handler.php
Line: 112
Function: _error_handler

File: /home/Hedy/web/mydomain.fr/public_html/index.php
Line: 329
Function: require_once
An uncaught Exception was encountered

Type: Omnipay\Common\Exception\InvalidRequestException

Message: The amount parameter is required

Filename: /home/Hedy/web/mydomain.fr/public_html/vendor/omnipay/common/src/Common/ParametersTrait.php

Line Number: 81

Backtrace:

File: /home/Hedy/web/mydomain.fr/public_html/vendor/omnipay/stripe/src/Message/AuthorizeRequest.php
Line: 260
Function: validate

File: /home/Hedy/web/mydomain.fr/public_html/vendor/omnipay/stripe/src/Message/PurchaseRequest.php
Line: 71
Function: getData

File: /home/Hedy/web/mydomain.fr/public_html/vendor/omnipay/common/src/Common/Message/AbstractRequest.php
Line: 686
Function: getData

File: /home/Hedy/web/mydomain.fr/public_html/application/modules/guest/controllers/Payment_handler.php
Line: 117
Function: send

File: /home/Hedy/web/mydomain.fr/public_html/index.php
Line: 329
Function: require_once

However the $amount variable looks set just before (line 82 in the same file).
I’m not a php dev, so I’m OK to make a PR for helping other, but I before need help to debug this !

Very good question, i’ll take a look this weekend.
Now, i haven’t looked yet, but that amount has to be known in the same function

So if it’s known in the same file, that’s less important than the same function.

I guess sending that amount comes from the frontend, right?
frontend => post form, validate, then send to payment gateway?

Then the thing to look at is the validate function. In the validate function that amount should be required

More during/after this weekend