#banyman-connection-error

1 messages · Page 1 of 1 (latest)

kindred tinsel
#

Hi there! Is this from the OAuth flow?

main lotus
#

I'm doing user onboarding. Standard Account.

kindred tinsel
#

I deleted your message as it contained your live API key

#

This is a public server and that compromises your secret key

#

I recommend you roll that key

#

Feel free to re-post your code without your secret key

main lotus
#

I'm sorry, I forgot it.

#

<?php

$userid = CurrentUserID();

\Stripe\Stripe::setApiKey('sk_live_51H....');

Log('get code ' . @Get('code'));

$response = \Stripe\OAuth::token([
'grant_type' => 'authorization_code',
'code' => @Get('code'),
]);

ExecuteStatement("UPDATE accounts SET
    stripe_account = '" . $response->stripe_user_id . "',
    stripe_publishable_key = '" . $response->stripe_publishable_key . "',
    stripe_user_id = '" . $response->stripe_user_id . "'
    WHERE id = '" . $userid ."' ");
#

I got the taken

kindred tinsel
#

Thanks, let me do some digging on my end and see if I can find the error you are hitting

main lotus
#

I hope you succeed.

#

"node_modules/stripe": {
"version": "9.14.0",
"resolved": "https://registry.npmjs.org/stripe/-/stripe-9.14.0.tgz",
"integrity": "sha512-nonEpYI7kPxZI8BGqlichBont9oHTBKFdKQV4LW6SvMAfYyQ95pL3vw1kqnW38oAui/c1sJqDOE2t8AoosOC9w==",
"dependencies": {
"@types/node": ">=8.1.0",
"qs": "^6.10.3"
},
"engines": {
"node": "^8.1 || >=10.*"
}
},

kindred tinsel
#

Can you try disabling HTTP/2 as shown in that issue?

#

Have you been able to successfully connect any other accounts?

main lotus
#

Where can I disable this?

main lotus
kindred tinsel
#

Can you try adding $curl = new \Stripe\HttpClient\CurlClient(); $curl->setEnableHttp2(false); \Stripe\ApiRequestor::setHttpClient($curl);

#

Like shown in the issue comment

main lotus
#

I not understand where I need this include

kindred tinsel
#

You would include it in your PHP code above prior to making any request to Stripe. So you can drop it right above your API key initialization.

main lotus
#

Just a moment.

#

[2022-07-20T16:37:25.501156+00:00] log.DEBUG: Slim Application Error Type: Stripe\Exception\ApiConnectionException Code: 0 Message: Unexpected error communicating with Stripe. If this problem persists, let us know at support@stripe.com. (Network error [errno 92]: HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)) File: /home/mentiumfi/public_html/vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php Line: 579 Trace: #0 /home/mentiumfi/public_html/vendor/stripe/stripe-php/lib/HttpClient/CurlClient.php(531):

kindred tinsel
#

Okay so same error after you implemented that code

main lotus
#

<?php

$userid = CurrentUserID();

$curl = new \Stripe\HttpClient\CurlClient();
$curl->setEnableHttp2(false);
\Stripe\ApiRequestor::setHttpClient($curl);

\Stripe\Stripe::setApiKey('sk_live_51.....
');

$response = \Stripe\OAuth::token([
'grant_type' => 'authorization_code',
'code' => 'ac_M5qgNZm1rF84vT6AHULYY2F87NhXSLP3',
]);

fallow bridge
#

please stop sharing your livemode secret key

kindred tinsel
#

Can you share your PHP version and libcurl version?

main lotus
#

Just a moment.

fallow bridge
#

what confuses me is that you have other code that works and is working right now, also from PHP(for creating Express accounts and AccountLinks), I can see it in your account logs. Is this OAuth stuff happening on a new/different server or environment than your existing code?

main lotus
#

PHP Version 8.0.20
cURL Information 7.84.0

main lotus
fallow bridge
#

hmm. What does that mean, what does "have not seen it now" mean?

#

to be clear, if you're getting this low level networking error, I'd expect to to happen on any PHP script calling our API using our SDK in that server's environment. It would be strange that it only happens for some code and not others. So I'm really curious how many servers or environments you have and what the differences between the environment where the code works and where it doesn't.

fallow bridge
#

I'm sorry but I don't understand what that means.

main lotus
fallow bridge
#

hmm.

#

can you add some code to explicitly check at runtime what versions of things are actually being used when your OAuth script is run?

#

for example :

echo(" PHP: " . phpversion());
echo(" Stripe: " . \Stripe\Stripe::VERSION. " ");
echo(" cURL: " . curl_version()['version']. " ");
#

what do those print when you run the script?

main lotus
#

okay

#

PHP: 8.0.20 Stripe: 8.9.0 cURL: 7.84.0

fallow bridge
#

can you run this script for me and share the output? you need to edit it first

<?php

ini_set('display_errors', 1);
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
error_reporting(E_ALL);

// CHANGE AS NEEDED FOR HOW YOUR PROJECT IS SET UP
require_once('vendor/autoload.php');

// CHANGE AS NEEDED
$key = "sk_xxxx";

\Stripe\Stripe::setApiKey($key);
\Stripe\Stripe::setApiVersion("2020-08-27");

echo(" PHP: " . phpversion());
echo(" Stripe: " . \Stripe\Stripe::VERSION. " ");
echo(" cURL: " . curl_version()['version']. " ");

echo(" not OAuth : ");
try{
  $customers = \Stripe\Customer::all(array("limit" => 25));
  echo(count($customers->data));
}catch (\Stripe\Exception\ApiErrorException $e) {
  echo($e->getError());
}

echo(" OAuth : ");
try{
  $response = \Stripe\OAuth::token([
    'grant_type' => 'authorization_code',
    'code' => 'not_a_real_code',
  ]);
  echo($response);
}catch (\Stripe\Exception\ApiErrorException $e) {
  echo($e->getError());
}

?>
#

@main lotus

slow bough
#

Hi @main lotus

main lotus
#

Hello. Thank you. I want to taste your code.

main lotus
slow bough
#

Hi @main lotus do you have a follow-up question?

main lotus
slow bough
#

And what result did you get after running the script?

main lotus
main lotus
slow bough
#

OK, so you don't see any respones nor errors?

#

Can you share with me your merchant ID? you can find it from the Stripe Dashboard -> Settings ->Account Details

main lotus
main lotus
slow bough
#

When did you run the script? did you run in live or test mode?

main lotus
slow bough
#

Did you change anything to the script rather than the secret key?

main lotus
slow bough
#

OK, then it's very strange. I'm expecting at least an OAuthError because the code in not real.

main lotus
slow bough
#

Great, it seems like it's working now.

main lotus
#

Okay. Let me do it real test.

main lotus
#

I have 2 link for redirects. Which is link for call back with code parameter? And which is link for return to my site Without parameters?

#

It is important for me that 1 link is only for authorization. 2 link is needed only for the person to return without completing the authorization.

slow bough
#

Stripe will redirect your users to one of the URLs and pass along the authorization code in the URL.

If you didn't specify redirect_uri param in your OAuth authorization URL, Stripe will redirect your users to the default URI that you specify in the list

main lotus
heady bloom
#

stepping in on behalf of jack. I don't understand the question, can you try rephrasing perhaps?