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';
Related
I am trying to do the refund process and it is connected to the nab test mode server but not processing the refund transaction.
I did a transaction yesterday and wanted to refund the part money but it is not going through and shows the error that Credit card details not available (Error Code 133).
I am sending the request using TransactionID and TransactionReference and the amount to be deducted but not working.
My code:-
public function pay()
{
$gateway = Omnipay::create('NABTransact_SecureXML');
$gateway->setMerchantId('XYZ0010');
$gateway->setTransactionPassword('abcd1234');
$gateway->setTestMode(true);
$card = new CreditCard([
'firstName' => 'ABC',
'lastName' => 'DEF',
'number' => '4444333322221111',
'expiryMonth' => '05',
'expiryYear' => '2025',
'cvv' => '123',
]
);
$transaction = $gateway->purchase([
'amount' => '5000.00',
'currency' => 'AUD',
'transactionId' => '100321', // (My order ID)
'card' => $card,
]
);
$response = $transaction->send();
}
The transactionID i got here is: 706256
please view the screenshot for the above transaction in the NAB:
public function refund()
{
$gateway = Omnipay::create('NABTransact_SecureXML');
$gateway->setMerchantId('XYZ0010');
$gateway->setTransactionPassword('abcd1234');
$gateway->setTestMode(true);
$card = ([
'firstName' => 'ABC',
'lastName' => 'DEF',
'number' => '4444333322221111',
'expiryMonth' => '05',
'expiryYear' => '2025',
'cvv' => '123',
]
);
$refund = $gateway->refund([
'transactionReference' => "706256",
'amount' => "5.00",
'currency' => "AUD",
'transactionId' => "100321",
'messageID' => '4',
'card' => $card,
]);
$refund->send();
}
please view the screenshot for the above transaction in the NAB when
trying to refund:
yes, i had solved it.
this is the sample of my code:
$gateway = Omnipay::create('NABTransact_SecureXML');
gateway->setMerchantId('_ID_');
$gateway->setTransactionPassword('_PASSWORD_');
$gateway->setTestMode(false);
$refund = $gateway->refund([
'transactionReference' => "12345",
'amount' => "500",
'transactionId' => 765897, (hope u must have saved this number in DB)
]);
$response = $refund->send();
$message = $response->getMessage();
if ($response->isSuccessful()) {
return "I m Happy"
} else {
return back()->with('amountError', $message);
}
Let me know how did it go :)
I am running a PHP 7.3, running on apache server. I used composer to get this library:
https://github.com/SecureTrading/PHP-API
For the code provided, I am now using the test site reference. I already managed to use for regular transitions. I now started managing 3D secure transactions, with the test MAESTRO card provided by secure trading here: https://docs.securetrading.com/document/testing/. the one designed not to demand 3D auth - that is 5000000000000421
The code provided next, will sum up the way I think thought this should work: I start by creating AUTH request, get error 30004, using CACHETOKENISE request to get a token, run THREEDQUERY to figure out if I need a full auth sceme on this card, get N as an answer, and run another AUTH request, this time with the transactionreference.
I am providing a version of the code I am testing (obviously, username, password and site reference name was removed to protect my privacy, but the code otherwise is the same)
<?php
$configData = array(
'username' => 'api#gigsberg.com',
'password' => 'xq!Kq$j4',
);
$site_refrance = 'test_gigsberg74319';
?>
<?php
$configData = array(
'username' => '*****',
'password' => '*****',
);
$site_refrance = '*****';
if (!($autoload = realpath(__DIR__ . '/vendor/autoload.php'))) {
throw new \Exception('Composer autoloader file could not be found.');
}
require_once($autoload);
$api = \Securetrading\api($configData);
$requestData = array(
'sitereference' => $site_refrance,
'requesttypedescription' => 'AUTH',
'accounttypedescription' => 'ECOM',
'currencyiso3a' => 'GBP',
'mainamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'securitycode' => '123',
);
echo '<pre>';
print_r($requestData);
$response = $api->process($requestData)->toArray();
print_r( $response['responses'] ); // $response['responses'][0]['errorcode'] == 30004
echo "\n--------------------------------------\n";
$transactionreference = $response['responses'][0]['transactionreference'];
$requestData = array(
'sitereference' => $site_refrance,
'expirymonth' => '12',
'expiryyear' => '2030',
'requesttypedescriptions' => array('CACHETOKENISE'),
'securitycode' => '123',
'orderreference' => $transactionreference,
'pan' => '5000000000000421'
);
print_r($requestData);
$response = $api->process($requestData)->toArray();
echo "\n--------------------------------------\n";
$cachetoken = $response['responses'][0]['cachetoken'];
$requestData = array(
'termurl' => 'https://termurl.com',
'accept' => 'text/html,*/*',
'currencyiso3a' => 'GBP',
'requesttypedescription' => 'THREEDQUERY',
'accounttypedescription' => 'ECOM',
'sitereference' => $site_refrance,
'baseamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'cachetoken' => $cachetoken,
);
print_r($requestData);
$response = $api->process($requestData)->toArray(); // $response['responses'][0]['enrolled'] == 'N'
/* Copying from the docs here: https://docs.securetrading.com/document/api/security/3-d-secure/
* If the enrolled value returned in the response is “Y”, the customer’s card is enrolled in 3-D secure. Please refer to the following table for enrolled values:
* .
* .
* N - The card is not enrolled in the card issuer’s 3-D Secure scheme. - Perform an AUTH Request, including the transactionreference returned in the THREEDQUERY response.
* .
* .
*/
print_r( $response['responses'] );
echo "\n--------------------------------------\n";
$transactionreference = $response['responses'][0]['transactionreference'];
$requestData = array(
'sitereference' => $site_refrance,
'requesttypedescription' => 'AUTH',
'accounttypedescription' => 'ECOM',
'currencyiso3a' => 'GBP',
'mainamount' => '1000',
'pan' => '5000000000000421',
'expirymonth' => '12',
'expiryyear' => '2030',
'securitycode' => '123',
'transactionreference' => $transactionreference
);
print_r($requestData);
$response = $api->process($requestData)->toArray();
print_r( $response['responses'] ); // Still get $response['responses'][0]['errorcode'] == 30004
I expected it to give me a note that all works well, but I still got error 30004, as if the transactionreference wasn't provided. Any idea what I can do, to fix this code, and prevent this error?
Thanks in advance
Yair
Well, I read the Api tests, and I found my error. On the last request data, instead of
$requestData = array(
.
.
'transactionreference' => $transactionreference
.
.
);
I should use
$requestData = array(
.
.
'parenttransactionreference' => $transactionreference
.
.
);
Anyway, home this helps somone
I have a shopping cart that currently is redirecting users to paypal directly to make their payment. I am wanting to allow customers to input their credit card on the site and paypal to process it. I have Paypal Pro account but I am having trouble using it. I am not sure how I can use the Paypal Pro package via Omnipay. In my vendors folder I have a ExpressGateway.php and a Progateway.php but not sure how to call the Progateway.php page. The only way I can see to set it is by using Omnipay::getway('paypal') which I currently do for express. What is the process i need to use in order to use Paypal Pro?
$gateway = Omnipay::gateway('paypal');
if(Auth::user() != NULL && Auth::user()->super_user == 1) {
//sandbox
$gateway->setUsername('#######');
$gateway->setPassword('#######');
$gateway->setSignature('#######');
$gateway->setTestMode('true');
} else {
//production
$gateway->setUsername('#######');
$gateway->setPassword('#######');
$gateway->setSignature('######');
}
$cardInput = array(
'firstName' => $info['first_name_bill'],
'lastName' => $info['last_name_bill'],
'billingAddress1' => $info['street_address_1_bill'],
'billingAddress2' => $info['street_address_2_bill'],
'billingPhone' => $info['phone_bill'],
'billingCity' => $info['city_bill'],
'billingState' => $info['state_bill'],
'billingPostCode' => $info['zip_bill'],
'shippingAddress1' => $info['street_address_1_ship'],
'shippingAddress2' => $info['street_address_2_ship'],
'shippingPhone' => $info['phone_ship'],
'shippingCity' => $info['city_ship'],
'shippingState' => $info['state_ship'],
'shippingPostCode' => $info['zip_ship'],
);
$card = Omnipay::creditCard($cardInput);
$response = Omnipay::purchase(
array(
'cancelUrl' => URL::to('cart'),
'returnUrl' => URL::action('CartController#getSuccessPayment', array('id' =>$invoice->id)),
'amount' => Input::get('total'),
'currency' => 'USD',
'card' => $card,
'description' => '#####'
)
)->send();`
Set the gateway this way:
$gateway = Omnipay::gateway('Paypal_Pro');
I am using Laravel with Omnipay for our ecommerce application. We direct the customers to Paypal to make their purchase. We require shipping and billing information prior to placing an order and we would like that information to continue to Paypal to make it easier for them. However, only the first name and last name are crossing over to Paypal correctly. We can also use email with no issues.
public function postPayment() {
//var_dump(Session::get('shipping_info')); die;
$info = Session::get('shipping_info');
$gateway = Omnipay::gateway('paypal');
//sandbox
$gateway->setUsername('xxxx');
$gateway->setPassword('xxxx');
$gateway->setSignature('xxx');
$gateway->setTestMode('true');
//production
// $gateway->setUsername('xxxx');
// $gateway->setPassword('xxxx');
// $gateway->setSignature('xxxx');
$cardInput = array(
'firstName' => $info['first_name_bill'],
'lastName' => $info['last_name_bill'],
'billingAddress1' => $info['street_address_1_bill'],
'billingAddress2' => $info['street_address_2_bill'],
'billingPhone' => $info['phone_bill'],
'billingCity' => $info['city_bill'],
'billingState' => $info['state_bill'],
'billingPostCode' => $info['zip_bill'],
'shippingAddress1' => $info['street_address_1_ship'],
'shippingAddress2' => $info['street_address_2_ship'],
'shippingPhone' => $info['phone_ship'],
'shippingCity' => $info['city_ship'],
'shippingState' => $info['state_ship'],
'shippingPostCode' => $info['zip_ship'],
);
$card = Omnipay::creditCard($cardInput);
// var_dump($card); die;
$response = Omnipay::purchase(
array(
'cancelUrl' => 'http://localhost/public/',
'returnUrl' => 'http://localhost/public/',
'amount' => Input::get('total'),
'currency' => 'USD',
'card' => $card,
'description' => 'Stuff'
)
)->send();
$response->redirect();
}
According to the docs https://github.com/omnipay/omnipay it should work with no issues. dumping the sessions reveals the correct billing and shipping parameters.
It was just needing a cache refresh.
I'm using Joomla with PHP, there is one component(payplans) is available for Joomla. In that component they configured lot of payment methods, including Authorize.net. We can select the payment method in the Joomla back-end, our client using Authorize.net so we selected Authorize.net.I did not change anything in the code, its working in our local m/c. I'm getting error only in live server even i have put the live account details not test account.
protected function _processNonRecurringRequest(PayplansPayment $payment, $data)
{
$transactionData = array(
'amount' => $payment->getAmount(),
'card_num' => $data['x_card_num'],
'exp_date' => $data['x_exp_date'],
'first_name' => $data['x_first_name'],
'last_name' => $data['x_last_name'],
'address' => $data['x_address'],
'city' => $data['x_city'],
'state' => $data['x_state'],
'country' => $data['x_country'],
'zip' => $data['x_zip'],
'email' => $data['x_email'],
'card_code' => $data['x_card_code'],
'ship_to_first_name' => $data['x_ship_to_first_name'],
'ship_to_last_name' => $data['x_ship_to_last_name'],
'ship_to_address' => $data['x_ship_to_address'],
'ship_to_city' => $data['x_ship_to_city'],
'ship_to_state' => $data['x_ship_to_state'],
'ship_to_zip' => $data['x_ship_to_zip'],
'ship_to_country' => $data['x_ship_to_country']
);
// echo "Data \n";
$transaction = new AuthorizeNetAIM();
$transaction->setSandbox(true);
$transaction->setFields($transactionData);
// print_r($transaction); exit();
// echo "response";
$response = $transaction->authorizeAndCapture();
// print_r($response);exit();
$transactionArray = $response->toArray();
// to identify it sis testing mode or not
$transactionArray['testmode'] = $this->getAppParam('sandbox', 0);
// save transaction notification and transaction id
if(isset($transactionArray['transaction_id'])){
$payment->set('txn_id', $this->getId().'_'.$transactionArray['transaction_id']);
}
$payment->set('transaction',PayplansHelperParam::arrayToIni($transactionArray));
$errors = array();
if($response->approved){
$payment->set('status',XiStatus::PAYMENT_COMPLETE);
}
else{
$payment->set('status',XiStatus::PAYMENT_PENDING);
$errors['response_reason_code'] = $response->response_reason_code;
$errors['response_code'] = $response->response_code;
$errors['response_reason_text'] = $response->response_reason_text;
}
return $errors;
}
I got error in this line
$response = $transaction->authorizeAndCapture();
please help
You have the following set to True:
$transaction->setSandbox(true);
Surely it should be set to false for the live server environment.