I am using stripe charge card api for card payment. Token successfully created and this information goes to stripe server also. But when go for charge payment it give fatal error.
I am using amazone ubuntu instance for publish my website.
My php code is :-
$token=$this->input->post('stripeToken');
var_dump($token);
\Stripe\Stripe::setApiKey("xxx");
// Get the credit card details submitted by the form
//$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => 100, // amount in cents, again
"currency" => "usd",
"source" => $token,
"description" => "Example charge"
));
} catch(\Stripe\Error\Card $e) {
// The card has been declined
}
It give fatal error.
Fatal error: Uncaught exception 'Stripe\Error\ApiConnection' with message 'Could not connect to Stripe
(https://api.stripe.com/v1/charges). Please check your internet
connection and try again. If this problem persists, you should check
Stripe's service status at https://twitter.com/stripestatus, or let us
know at support#stripe.com. (Network error [errno 28]: Connection
timed out after 30055 milliseconds)' in
/opt/lampp/htdocs/devbeacon/application/libraries/stripe/lib/HttpClient/CurlClient.php:216
Stack trace: #0
/opt/lampp/htdocs/devbeacon/application/libraries/stripe/lib/HttpClient/CurlClient.php(178):
Stripe\HttpClient\CurlClient->handleCurlError('https://api.str...',
28, 'Connection time...') #1
/opt/lampp/htdocs/devbeacon/application/libraries/stripe/lib/ApiRequestor.php(184):
Stripe\HttpClient\CurlClient->request('post', 'https://api.str...',
Array, Array, false) #2
/opt/lampp/htdocs/devbeacon/application/libraries/stripe/lib/ApiRequestor.php(59):
Stripe\ApiRequestor->_requestRaw('post', '/v1/charges', Array, Ar in
/opt/lampp/htdocs/devbeacon/application/libraries/stripe/lib/HttpClient/CurlClient.php
on line 216
I don't know the reason behind that.
The message shows Network error [errno 28], which is a curl error, defined as a CURLE_OPERATION_TIMEDOUT error. This is a connection error.
Connection errors are usually due to security group settings and not allowing outbound https, in this case to the API endpoint (https://api.stripe.com/v1/charges).
Can you try to curl https://api.stripe.com/v1/charges and confirm you can connect?
You should get the following:
{
"error": {
"type": "invalid_request_error",
"message": "You did not provide an API key. You need to provide your API key in the Authorization header, using Bearer auth (e.g. 'Authorization: Bearer YOUR_SECRET_KEY'). See https://stripe.com/d
ocs/api#authentication for details, or we can help at https://support.stripe.com/."
}
}
If you do not get that response the command line on your server, then your code will not be able to connect either. Review your outgoing security group settings, and allow outbound HTTPS to the IP of the endpoint, or 0.0.0.0/0.
Related
I am asking for help on an error I got when I try to integrate the MasterCard Payment Gateway Sample Code:
Gateway sample code link: https://ap-gateway.mastercard.com/api/documentation/downloads/example/Sample_REST-JSON_PHP.zip?locale=en_US
I configure the following field in the configuration.php
// Base URL of the Payment Gateway. Do not include the version.
$configArray["gatewayUrl"] = "https://ap-gateway.mastercard.com/api/rest/";
// Merchant ID supplied by your payments provider
$configArray["merchantId"] = "[INSERT-MERCHANT-ID]";
// API username in the format below where Merchant ID is the same as above
$configArray["apiUsername"] = "merchant.[INSERT-MERCHANT-ID]";
// API password which can be configured in Merchant Administration
$configArray["password"] = "";
I am pretty sure my Merchant ID, which is provided by a financial provider, is correct. However, I got the following error, could you please help to advise? Thanks.
{
"error": {
"cause": "INVALID_REQUEST",
"explanation": "Value '[INSERT-MERCHANT-ID]' is invalid. No valid Merchant Acquirer Relationship available",
"field": "merchantId",
"validationType": "INVALID"
},
"result": "ERROR"
}
Regards,
Carlos
You need the merchantId from a payment service provider. It says as much in the error.
I have hosted my PHP application and everything is working fine except for the Stripe Payment integration in it.
Can someone suggest what could be the error?
require_once('../../Stripe/init.php');
\Stripe\Stripe::setApiKey('sk_test_************');
$e="";
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
try {
$charge = \Stripe\Charge::create(array(
"amount" => $stripe_amount, // amount in cents, again
"currency" => "cad",
"source" => $token,
"description" => "Buy Gift Card"
));
} catch(\Stripe\Error\Card $e) {
$e = "Your card has been declined, please enter a valid card";
}
It's working fine on my local machine, but on my hosting it gives me this error:
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
I'm trying to fetch a given email from my own inbox (as project owner) using the Google API 2.0.0 RC4 for PHP.
I have a project setup, a downloaded authentication file in JSON format and I have enabled the gmail API in the Google Developers Console.
But when I run the following code I get a "Bad Request" error with reason "failedPrecondition". Now this leads me to believe that there is something wrong with the access rights, but I can't figure out what I need to do here.
Code:
<?php
require_once("google-api-php-client-2.0.0-RC4/vendor/autoload.php");
$client = new Google_Client();
// set the scope(s) that will be used
$client->setScopes(["https://www.googleapis.com/auth/gmail.readonly"]);
$client->setApplicationName("MyProject");
// set the authorization configuration using the 2.0 style
$client->setAuthConfigFile("myAuthFile.json");
$gmailHandle = new Google_Service_Gmail($client);
$messages = $gmailHandle->users_messages->get("myemail#mydomain.com", "12343445asd56");
echo json_encode($messages);
?>
And the complete error looks like this:
Fatal error: Uncaught exception 'Google_Service_Exception' with message '{ "error": { "errors": [ { "domain": "global", "reason":
"failedPrecondition", "message": "Bad Request" } ], "code": 400,
"message": "Bad Request" } } '
I just ran into this and finally found the solution. You are getting that error because you are using a service account without specifying a "subject" as part of the configuration. That is required for the API to know which email address you are acting as when using the service account. You can see it attempting to use this subject in Google_Client::createApplicationDefaultCredentials
The solution is to add the following line in the code after you have called setAuthConfig()
$client->setConfig('subject', 'you#email.com');
Be sure to then use the keyword 'me' when fetching the messages from the inbox as you are now acting as the email address which you have configured as 'subject'.
my Payeezy is throwing an error “payment method is missing”
im testing authorize transaction which i believe doesnt require payment method.
here’s my code
http://pastebin.com/gEyAfyuf
here’s the response on our site at http://wolcottschoolpay.com/test/payeezy_php/test.php
{
correlation_id: "228.1440254919101",
Error:
{
messages:
[
{
code: "payment_method_missing",
description: "The payment method is missing"
},
{
code: "missing_amount",
description: "The amount is missing"
},
{
code: "missing_currency",
description: "The currency is missing"
}
]
},
transaction_status: "Not Processed",
validation_status: "failed",
transaction_type: "authorize",
currency: "USD”
}
I copied most of the part here on the official payeezy php direct library on github.
authorize transaction is on line 127
https://github.com/payeezy/payeezy_direct_API/blob/master/payeezy_php/example/tests/PayeezyTest.php
i also tried both my merchant test details and the one provided at payeezy library but none worked.
Is this a library issue? any idea?
First you need to add x_currency_code and x_amount in api request. without amount and currency it can not process transaction.
And to process payment you need to select payment method like VISA, AMERICAN EXPRESS, DISCOER etc...
As the error message suggests, your request JSON payload is missing amount, currency and payment method. Please add those and try again.
I use Inchoo's extension for connecting Magento and Stripe payment. Inchoo component is simple and it is based on https://github.com/stripe/stripe-php. When I use it for test payments it works as it should be.
But I need stripe connect because of 'application_fee' and I now have problem.
According tutorial stripe.com/docs/connect/oauth I use https://gist.github.com/afeng/3507366
and everything still works great.
According stripe.com/docs/connect/collecting-fees :
We have following code -
// Get the credit card details submitted by the form
$token = $_POST['stripeToken'];
// Create the charge on Stripe's servers - this will charge the user's card
$charge = Stripe_Charge::create(array(
"amount" => 1000, // amount in cents
"currency" => "usd",
"card" => $token,
"description" => "payinguser#example.com"),
"application_fee" => 123 // amount in cents
),
**ACCESS_TOKEN** // user's access token from the Stripe Connect flow
);
But ACCESS_TOKEN is problem, because I use the one that I get in previous step 'stripe.com/docs/connect/oauth'
and get error:
OAuth based requests must use card tokens from Stripe.js, but card details were directly provided.
Why and where I should use Stripe.js? Everything works great until 'ACCESS_TOKEN' is requested and it says :
// user's access token from the Stripe Connect flow - I already have ACCESS_TOKEN
from
(stripe.com/docs/connect/oauth)
{
"token_type": "bearer",
"stripe_publishable_key": PUBLISHABLE_KEY,
"scope": "read_write",
"livemode": "false",
"stripe_user_id": USER_ID,
"refresh_token": REFRESH_TOKEN,
"access_token": ACCESS_TOKEN
}
problem w