I have been working with this code for a while and still couldn't figure out what is the problem with it.
Maybe some of the code has a problem, but Omnipay didn't show anything as the error message.
Can anyone please help me find out my mistakes?
$gateway = Omnipay::create('Eway_RapidDirect');
write_log($gateway->getDefaultParameters());
$gateway->initialize([
'apiKey' => 'API KEY',
'password' => 'PASSWORD',
'testMode' => true
]);
$card = new CreditCard([
'number' => '4444333322221111',
'expiryMonth' => '6',
'expiryYear' => '2030',
'cvn' => '123'
]
);
$transaction = $gateway->purchase([
'amount' => '10.00',
'currency' => 'AUD',
'transactionId' => 'RAM0001',
'card' => $card,
]
);
$response = $transaction->send();
if ($response->isSuccessful()) {
write_log('success');
} else {
write_log('failed');
write_log($response->getMessage());
}
The code always print
[07-Aug-2018 09:07:01 UTC] failed
[07-Aug-2018 09:07:01 UTC]
Plugin github: Omnipay Eway
This issue was due to a bug in the OmniPay eWAY library where the authentication headers were not set. Making matters worse, authentication failures aren't handled gracefully, resulting in the blank error message.
Version 3.0.1 contains a fix for the missing authentication.
Related
I have two questions
One:
What values can we send to Stripe using Omnipay authorize(), example below is only sending amount and description
$response = $gateway->authorize([
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'paymentMethod' => $paymentMethod,
'returnUrl' => $completePaymentUrl,
'confirm' => true,
])->send();
what if we want name and email to be sent, how can we achieve this also
Two:
the payment intent we get back from the above request, is generating error log on Godaddy server, I am using the following code;
$paymentIntentReference = $response->getPaymentIntentReference();
$response = $gateway->confirm([
'paymentIntentReference' => $paymentIntentReference,
'returnUrl' => $completePaymentUrl,
])->send();
error log: PHP Fatal error: Uncaught Omnipay\Common\Exception\InvalidRequestException: The paymentIntentReference parameter is required
by my confusion is that in spite of this error log the payment process is being complete, so should I worry about this error or not,
and I hope this time I asked my question in the right manner
thanks in advance
I am having a little trouble with the SOAP API I need to consume. It requires authorization, so I log in with the following.
Basically, I need to log in with the following, I don't get a "Login Required", which is fine.
$client = new \SoapClient('localwsdlfile.wsdl', array(
'local_cert' => 'localcert.pem',
'passphrase' => 'passphrase',
'location' => 'https://wsmurl/login/'
));
$response = $client->Get(array(
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id'=>'MOREDATATOLOOKUP'))
));
print_r($response);
So, basically, in the client, I need to uncomment the line
'location' => 'https://wsmurl/login/'
If I don't, I get this login error. The server I am trying to consume has a cache, so I no longer need to send this login for future operations for the next 10 minutes.
So, now, I have logged in, I can go the following, with success.
$client = new \SoapClient('localwsdlfile.wsdl', array(
'local_cert' => 'localcert.pem',
'passphrase' => 'passphrase',
// 'location' => 'https://wsmurl/login/' // Uncomment to login
));
$response = $client->Get(array(
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id'=>'MOREDATATOLOOKUP'))
));
print_r($response);
If I keep 'location' => 'https://wsmurl/login/' uncommented, I get errors about not sending a valid WSDL.
So in summary:-
I am consuming this soap API in Laravel, using PHP's SoapClinet per the above code.
My understanding is that the soap service I am trying to consume required login first.
After quite a lot of testing, I managed to get to the point there were no errors by including the line 'location' => 'https://wsmurl/login/' as shown above in the call to SoapClient.
This seems to be required the first time I call this soap service I guess it is logging me in. If I don't include it, I get the error
"SoapFault
Login Required"
So, if I include the line 'location' => 'https://wsmurl/login/', it appears to log me in, but I now get the error
"SoapFault
looks like we got no XML document"
If I keep the line, I continue to get this error
"SoapFault
looks like we got no XML document"
Removing the line then gives me the expected SOAP response and all is ok.
I have tried catching for errors using try{} ... catch{} looking for exceptions/errors etc, but it isn't catching the "Login Required" or "Looks like we got no XML document" as faults.
So, I guess, is there a better way to detect this condition so I can either send or not without the line or is there a better way to login to the service (note, it just uses the cert and passphrase).
Thanks in advance, I hope the little re-write above makes it clearer.
Because the location for the login and localwsdlfile.wsdl is different, I could not do it with one call. So we created a function using curl to login and if login is successful it will proceed to the soap client. Thanks to Brian from freelancer for his assistance here.
$client = new SoapClient('wsdl/VocusSchemas/localwsdlfile.wsdl', array(
'trace' => 1,
'exception' => true
));
try {
$response = $client->Get(array(
// "AccessKey" => "MADAITABNSAATOT1",
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id' => 'MOREDATATOLOOKUP'))
));
Basically, I am trying to connect to a SOAP service with 2 way SSL (HTTP client certificate authentication).
I am using PHP SoapClient for this within Laravel.
This is what I have, and it allows me to connect and returns the expected response. So the method is basically correct and the certificate is fine etc. It's just I am having trouble with what I guess is the 2 way SSL part.
$client = new \SoapClient('localwsdlfile.wsdl', array(
'local_cert' => 'localcert.pem',
'passphrase' => 'passphrase',
// 'location' => 'https://wsmurl/login/' // Uncomment to login
));
$response = $client->Get(array(
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id'=>'MOREDATATOLOOKUP'))
));
print_r($response);
The only problem is (obviously because I'm doing something wrong), is I need to add the line 'location' => 'https://wsmurl/login/' the first time I try to connect, otherwise I get an error "SoapFault Login Required"
I then remove the line 'location' => 'https://wsmurl/login/', otherwise, I get an error "SoapFault looks like we got no XML document".
The service provider has a 600 second timeout, where I don't have to "login" again for upto 600 seconds.
After removing this line 'location' => 'https://wsmurl/login/', then it works as expected. Obviously, I can't manually add and remove this line, and I guess I am not doing this correctly.
Can someone tell me a better way to do this please?
Thanks,
Because the location for the login and localwsdlfile.wsdl is different, I could not do it with one call. So we created a function using curl to login and if login is successful it will proceed to the soapclient. Thanks to Brian from freelancer for his assistance here.
$client = new SoapClient('wsdl/VocusSchemas/localwsdlfile.wsdl', array(
'trace' => 1,
'exception' => true
));
try {
$response = $client->Get(array(
// "AccessKey" => "MADAITABNSAATOT1",
"AccessKey" => "accesskey",
"ProductID" => "SOMEPRODUCT",
"Scope" => "SOMESCOPE",
"Parameters" => array('Param' => array('_' => 'DATATOLOOKUP', 'id' => 'MOREDATATOLOOKUP'))
));
I have set up PayPal Sandbox to test my PayPal Express integration, but whenever I log in to the sandbox from the payment page, I get greeted by the following error message;
I am using laravel-omnipay and omnipay-paypal with the PayPal_Express gateway.
I think this is likely to be a configuration issue (or a bug..? Although I'm hoping it's not.) in PayPal, but this is the piece of code I am using to initiate the payment:
public function checkout ()
{
$cart = Cart::forSession ();
$response = Omnipay::purchase
(
[
'amount' => $cart->getPrice (),
'currency' => preferred_currency ()->name,
'description' => (string) $cart,
'returnUrl' => URL::action ('OrderController#checkoutReturn'),
'cancelUrl' => URL::action ('OrderController#checkoutCancel')
]
)->send ();
if ($response->isSuccessful ())
dd ('successful', $response);
else if ($response->isRedirect ())
return $response->getRedirectResponse ();
else
return Redirect::to ('/cart')->with ('alerts', [new Alert ('An error occurred while attempting to process your order: ' . $response->getMessage (), Alert::TYPE_ALERT)]);
}
And the omnipay.php configuration file:
return array(
'gateway' => 'PayPal_Express',
'defaults' => array(
'testMode' => true,
),
'gateways' => array(
'PayPal_Express' => array(
'username' => '<>',
'password' => '<>',
'signature' => '<>',
'landingPage' => array('billing', 'login'),
),
),
);
The username, password and signature I am using are the ones I created in the PayPal Sandbox for my account.
The sandbox account I am using to test this is a "personal"/buyer account, with funding sources and "Payment Review" disabled. The Sandbox Accounts overview on the PayPal Developer website indicates the sandbox account's status as "complete".
I'm hoping I didn't miss something obvious. I checked out some of the other answers on Stack Overflow but none of those seemed to offer a solution for this exact problem.
Contact PayPal support, as there is something wrong on their end.
Does anyone know how to integrate eway payment gateway to a normal php website ?
I have conected but it is showing the error when I am writing the code in this link :https://www.eway.com.au/developers/sdk/php
Its showing the error which is given below :
Error: eWAY library has encountered a problem connecting to Rapid
<?php
require_once 'lib/eway-rapid-php-master/include_eway.php';
// eWAY Credentials
$apiKey = 'F9802AS8MHb/rAm6UyRbT2d5eHjOZWhff++jtFOtMU';
$apiPassword = 'V6E';
$apiEndpoint = 'Sandbox';
// Create the eWAY Client
$client = \Eway\Rapid::createClient($apiKey, $apiPassword, $apiEndpoint);
// Transaction details - these would usually come from the application
$transaction = [
'Customer' => [
'FirstName' => 'John',
'LastName' => 'Smith',
'Street1' => 'Level 5',
'Street2' => '369 Queen Street',
'City' => 'Sydney',
'State' => 'NSW',
'PostalCode' => '2000',
'Country' => 'au',
'Email' => 'demo#example.org',
],
// These should be set to your actual website (on HTTPS of course)
'RedirectUrl' => "http://$_SERVER[HTTP_HOST]" . dirname($_SERVER['REQUEST_URI']) . '/response.php',
'CancelUrl' => "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]",
'TransactionType' => \Eway\Rapid\Enum\TransactionType::PURCHASE,
'Payment' => [
'TotalAmount' => 1000,
]
];
// Submit data to eWAY to get a Shared Page URL
$response = $client->createTransaction(\Eway\Rapid\Enum\ApiMethod::RESPONSIVE_SHARED, $transaction);
// Check for any errors
if (!$response->getErrors()) {
$sharedURL = $response->SharedPaymentUrl;
} else {
foreach ($response->getErrors() as $error) {
echo "Error: ".\Eway\Rapid::getMessage($error)."<br>";
}
die();
}
echo 'Pay with our secure payment page';
?>
I have written the code as shown above.
I realize you've sorted it by now or given up Lena but please find code is like below
$apiEndpoint = '\Eway\Rapid\Client::MODE_SANDBOX';