How do Integrate eWay Payment System in PHP - php

I have followed the document site https://eway.io/api-v3/ to integrate the Payment system into my PHP application. And I run the command composer require eway/eway-rapid-php from terminal in the application. After that I load autoload.php.
Now I want to send customer into eWay payment site for choose payment method(paypal, CC) as well as paypal/CC information. So that customer can feel that they are paying by eWay payment gateway. I have the following code into my controller method:
$apiKey = '5XwiMIQ3EBkSlP5XwiMIQ3EBkSlP5XwiMIQ3EBkSlP...................';
$apiPassword = '12222......';
$apiEndpoint = \Eway\Rapid\Client::MODE_SANDBOX; // Use \Eway\Rapid\Client::MODE_PRODUCTION when you go live
$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);
$transaction = [
'RedirectUrl' => 'http://www.eway.com.au',
'CancelUrl' => "http://www.eway.com.au",
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
'Payment' => [
'TotalAmount' => 1000,
]
];
$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::RESPONSIVE_SHARED, $transaction);
It's returning the "Error connecting to Rapid gateway" | error code S9992
Also I followed the url https://github.com/eWAYPayment/eway-rapid-php.
Do I miss anything? Would you please help me out?

Most of the time a S9992 connection error is due to an incorrect CA bundle, which prevents SSL verification from working correctly. There are a number of questions with solutions already on SO, like this one.
You can confirm the issue by enabling logging in the eWAY PHP SDK, this gist has some examples.

I have had the exact same Eway S9992 issue using XAMPP on Mac OSX. I managed to fix the issue by downloading the latest CA bundle from here:
https://curl.haxx.se/ca/cacert.pem
Saving it to my /Applications/XAMPP/etc/ folder then editing my XAMPP/etc/php.ini file and updating the path to the openssl.cafile:
openssl.cafile=/Applications/XAMPP/etc/cacert.pem
Restarted Apache and it worked a treat!

Related

any idea of how curl cacert broke my php app?

------Answer below--------
I know many post already talk about this but I've tried everything and I think nothing worked.
I use Google API for connection to a website and after to manage Google drive with API and Google library in PHP.
Pretty simple, I've got an issue with curl error 60, so I've checked curl.se website to get the last cacert.pem.
for those who would have my code, in my connection module, if i delete the verify line :
$client = new Client([
'timeout' => 2.0,
'verify' => __DIR__ . '/cacert.pem'
]);
i got this :
cURL error 60: SSL certificate problem: unable to get local issuer certificate
If i keep the verify, it work.
And my drive manager module :
$client = new Google_Client([
'timeout' => 2.0,
'verify' => __DIR__ . '/cacert.pem'
]);
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_Drive::DRIVE);
$driveManager = new Google_Service_Drive($client);
$client->setSubject('api#test.fr');
// Print the names and IDs for up to 10 files.
$optParams = array(
'fields' => 'nextPageToken, files( name)',
'q' => 'folder',
);
$results = $driveManager->files->listFiles($optParams);"
Of course there is require vendor/autoload and putenv blablabla to open my credentials json file before and the printf foreach $results under..
The thing is, with the same cacert.pem verification, since the last update of cacert.pem on curl.se website (aka the 19/01/2021), this module doesn't work at all with the same error!
I'm a new user with Google API and I don't understand everything.
i've finally hosted my app today, to get it online, and it seems to work.
As my host use ssl by let's encrypt, my app dont use the cacert.pem as scpecified just above in the post, but it use the main certificate of my website, which is my host certificate.
When i've tested it, the error seems appear when the app request to : https://oauth2.googleapis.com/token, and it appear just when i've updated to the last cacert.pem file, so i guess there is an error somewhere that is not made by my hand...

Laravel Passport: 401 Unauthenticated, but encryption keys are the same

I have a weird problem with Passport authentication deploying my application to a new site, in spite of the fact that I haven't had a problem with this before.
I'm using Passport's password grant feature to log in to the application (Laravel 5.4). This happens by the user posting his username/password as JSON to the site, and from there it posts those credentials to OAuth/token to get the API key for the site. This has worked fine in the past, and my OAuth keys are committed to the repository.
The other day I managed to deploy the site to a new server (with the same OAuth keys), regenerated (I think) the app key, loaded my data that has the encrypted passwords, and authentication worked fine. Today, however, I did the same thing on a different branch and now logging in returns 401 Unauthorized.
I've done nearly every permutation I could think of: delete the OAuth keys, regenerate app key, reinstall passport, and yet the app refuses to log in. I don't believe it has anything to do with the source code because no changes I made on this branch would affect the login system.
I even tried copying the working site's app key and OAuth keys to the broken site still don't work.
What makes this even more puzzling to me is that I have another site with a different app key, different OAuth keys, but the same data, and the login system works fine.
I don't understand the league/oauth2 package enough to understand why this isn't working. What am I missing?
Thanks, Matt
Well, bad code doesn't pay.
What I didn't mention was that the site I'm trying to deploy is an attempt to move a domain over to a new server. Both the broken site and it's active sister site have the same domain name. This is the code that posts to my own domains /oauth/token endpoint:
$username = Input::json('username');
$password = Input::json('password');
$page = Input::get('page');
$client = Client::find(2);
$http = new GuzzleHttp\Client();
try {
$response = $http->post(url('oauth/token'), [ # <-- see the problem?
'form_params' => [
'grant_type' => 'password',
'client_id' => '2',
'client_secret' => $client->secret,
'username' => $username,
'password' => $password,
'scope' => '',
],
]);
#...
The problem is rather hilarious. Since the DNS hasn't switched for the site yet, the requests to my own site are going to the old site, not this one. Hence I'm getting back Unauthenticated. Because I'm not.
The solution was to edit the /etc/hosts file on the server to point the domain to itself. That way, any calls to its own api will actually go its own api. Problem solved.

Active Collab SSL related error

I am creating an extension for Active Collab leveraging their SDK. Before installing SSL certificate their were no problems and my code ran fine. After the SSL installation and updating my root_URL and updating the url in the connector portion of my code I now get
Fatal error: Uncaught exception 'ActiveCollab\SDK\Exceptions\CallFailed' with message 'Peer's Certificate issuer is not recognized.'
However my SSL is installed properly. I have no other problems with it.
the relevant portion of code:
error_reporting(E_ALL);
ini_set('display_errors', 1);
require_once '/path/to/public_html/activecollab/5.8.7/activecollab-feather-sdk/vendor/autoload.php';
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('****', '********','username','password', 'https://url.domain.com'); <=dummy entry
$token = $authenticator->issueToken();
The back trace shows the issue coming up in issueToken(). Does anyone know what may be causing this?
Active Collab SDK 3.1 lets you turn off SSL peer verification, like this:
$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('ACME Inc', 'My Awesome Application', 'you#acmeinc.com', 'hard to guess, easy to remember', 'https://my.company.com/projects', false);
$authenticator->setSslVerifyPeer(false);
Run composer update and tweak your code to turn off SSL verification, and you should be able to connect.

Magento admin login failed on cloud server

I have purchased a magento theme to build my fashion store. At first I purchased a Linux 10GB web hosting package and I finished my website successfully on that. But after that I realized the web server that I purchased is not stable. There were multiple server down times. So I decided to buy a unlimited Cloud Hosting package. After that I tried to install the same theme "quick-start package" on it. But after installing it it doesn't allow me to login to the admin panel. It says Invalid Username or Password. Please help me to fix this problem. Is there any service that I have to enable? cURLS and mod-rewrite are enabled.
I modified the password from database. But it didn't work.
This may help - this isn't my answer but I know its worked for people with the same issue.
Id put your password back as it was - hope you kept a backup!
If you are having trouble to get logged in with the correct username and password, here are some ideas. If you have used google chrome to install magento, use firefox to open magento and edit the app/code/core/Mage/Core/Model/Session/Abstract/Varien.php file within your magento directory and comment those below lines
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath()
// 'domain' => $cookie->getConfigDomain(),
// 'secure' => $cookie->isSecure(),
// 'httponly' => $cookie->getHttponly()
);
And use your credentials to log in. I hope this works for you!!!

SSl Certificate issue with Omnipay and CI

I am trying to make a simple payment through my paypal sandbox from my local machine. I am using the Omnipay library in Codeigniter.
I setup a sandbox account at developer.paypal.com and a test application. This is the code I am using:
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername([username]);
$gateway->setPassword([password]);
$gateway->setSignature([signature]);
$gateway->setTestMode(true);
$params = array(
'amount' => '1.00',
'currency' => 'USD',
'description' => 'test purchase',
'transactionId' => '123',
'transactionReference' => '123ref',
'returnUrl' => [returnUrl],
'cancelUrl' => [cancelUrl],
);
$response = $gateway->purchase($params);
I am getting the following error:
Fatal error: Uncaught exception 'Buzz\Exception\ClientException' with message 'SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed' in...
I installed omnipay using composer with something called BUZZ. I am pretty new to doing paypal transactions online and not sure If I need to setup a local ssl certificate. If I do, can someone point me in the direction for setting that up?
Thanks.
That sounds pretty dodgy. Omnipay uses Guzzle to make the HTTPS requests to PayPal, and Guzzle bundles the latest root SSL certificates for you. So you should not see any HTTPS warnings.
Does this work locally for you? Have you tried different servers? If you are on shared hosting it is possible that your web host is trying to proxy your requests, which means they are essentially performing a man in the middle attack, potentially making your website insecure.
EDIT: Just noticed that error is actually coming from Buzz, not Guzzle. How did you install that? What does your composer.json file look like? Which version of Omnipay are you running? If you upgrade to the latest version of Omnipay (2.0) it will use Guzzle internally and this should fix the SSL error.
I found an answer on omnipay's issues page (at least for testing): https://github.com/omnipay/omnipay/issues/13
For Local Testing Only:
Add these lines to the file /buzz/lib/Buzz/Client/Curl.php, just before curl_exec method...
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

Categories