#banyman-connection-error
1 messages · Page 1 of 1 (latest)
I'm doing user onboarding. Standard Account.
Do you hit this error when you attempt to complete the connection as shown here: https://stripe.com/docs/connect/oauth-standard-accounts#token-request?
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
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
Thanks, let me do some digging on my end and see if I can find the error you are hitting
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.*"
}
},
Okay so I think https://github.com/stripe/stripe-php/issues/625 is a similar issue here
Can you try disabling HTTP/2 as shown in that issue?
Have you been able to successfully connect any other accounts?
Where can I disable this?
I don't have successful connections. This is my 1st experience.
Can you try adding $curl = new \Stripe\HttpClient\CurlClient(); $curl->setEnableHttp2(false); \Stripe\ApiRequestor::setHttpClient($curl);
Like shown in the issue comment
Where is this file?
I not understand where I need this include
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.
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):
Okay so same error after you implemented that code
<?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',
]);
please stop sharing your livemode secret key
Can you share your PHP version and libcurl version?
Just a moment.
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?
PHP Version 8.0.20
cURL Information 7.84.0
You're right. Such code is in another file, but I have not seen it now.
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.
I don't use it code.
I'm sorry but I don't understand what that means.
I have Only one server.. The code doesn't work only here.
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?
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
Hi @main lotus
Hello. Thank you. I want to taste your code.
PHP: 8.0.20 Stripe: 8.9.0 cURL: 7.84.0 not OAuth : OAuth :
I have a result.
Hi @main lotus do you have a follow-up question?
I need to solve this problem. I do not know what it is.
And what result did you get after running the script?
PHP: 8.0.20 Stripe: 8.9.0 cURL: 7.84.0 not OAuth : OAuth :
I have running this script. And I get this result. PHP: 8.0.20 Stripe: 8.9.0 cURL: 7.84.0 not OAuth : OAuth :
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
acct_1HewGDIUsaOmdTy7
I don't see any errors.
When did you run the script? did you run in live or test mode?
I did run this script with live mode.
Did you change anything to the script rather than the secret key?
Yes, sure. I included my key.
OK, then it's very strange. I'm expecting at least an OAuthError because the code in not real.
Just a moment.
PHP: 8.0.20 Stripe: 8.9.0 cURL: 7.84.0 not OAuth : 9 OAuth : Stripe\OAuthErrorObject JSON: { "error": "invalid_grant", "error_description": "Authorization code does not exist: not_a_real_code" }
Great, it seems like it's working now.
Okay. Let me do it real test.
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.
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
It is important for me that the user returns to the /stripecallback page to complete the authorization.
If a person does not want to log in, he can simply return to the site, and for this I have a page /gefunds
How can I be sure to customize these pages?
stepping in on behalf of jack. I don't understand the question, can you try rephrasing perhaps?