Use Paypal Pro instead of Paypal Express - Omnipay for Laravel - php

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');

Related

No $_POST data in callback from PayPal

I'm integrating Standard PayPal payment via NVP. I've created everything, but my problem is that on my complete page PayPal doesn't return any $_POST and $_GET data. Even, so I put rm=2 in my request to PayPal. That's totally odd. As I have checked my old PP integration as that also doesn't return any data. But I have checked it only on my localhost. Any idea? As that seems to me for PayPal issues.
Part of my call to PP NVP below:
'PWD' => $password,
'USER' => $user,
'SIGNATURE' => $signature,
'METHOD' => $method
'BUTTONTYPE' => 'BUYNOW',
'BUTTONCODE' => 'HOSTED',
'BUTTONSUBTYPE' => 'PRODUCTS',
'BUTTONCOUNTRY' => 'GB',
'BUTTONIMAGEURL' => 'https://www.paypalobjects.com/webstatic/en_US/btn/btn_buynow_107x26.png',
'L_BUTTONVAR1' => 'return=' . $this->getReturnUrl(),
'L_BUTTONVAR2' => 'notify_url=' . $this->getNotifyUrl(),
'L_BUTTONVAR3' => 'invoice=' . $this->getInvoice(),
'L_BUTTONVAR4' => 'currency_code=GBP',
'L_BUTTONVAR5' => 'item_number=1',
'L_BUTTONVAR6' => 'item_name=' . $this->getItemName(),
'L_BUTTONVAR7' => 'amount=' . $this->getAmount(),
'L_BUTTONVAR8' => 'cpp_header_image=' . $this->getHeaderImage(),
'L_BUTTONVAR9' => 'rm=2', // return data by POST method

How to integrate eway payment gateway to a php website?

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';

Omnipay with Paypal Express

I have an ecommerce website that redirects to a Paypal express checkout using Omnipay. It will correctly redirect the user to Paypal and return with a successful message with payerID and everything. However, it does not actually take any payment and it does not show up on our paypal account as any payment taken. I am not sure if this is a paypal issue or a configuration problem with Omnipay. I would imagine that Paypal handles this part of it but since it's not working (on our old site it works fine but we do not use Omnipay.)
$gateway = Omnipay::gateway('paypal');
//production
$gateway->setUsername('11111111');
$gateway->setPassword('1111111111');
$gateway->setSignature('111111111');
$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);
//live
$response = Omnipay::purchase(
array(
'cancelUrl' => 'http://store.site.com/cart/cancel-payment',
'returnUrl' => 'http://store.site.com/cart/successful-payment',
'amount' => Input::get('total'),
'currency' => 'USD',
'card' => $card,
'description' => 'Stuff'
)
)->send();
if ($response->isSuccessful()) {
return Redirect('cart/successful-payment');
} elseif ($response->isRedirect()) {
$response->redirect(); // this will automatically forward the customer
} else {
return Redirect::back()->with('error', 'There was a problem. Please try again.');
}
} else {
return Redirect::to('cart/successful-payment');
}
So basically what this will do is redirect them to Paypal to make a payment then redirect back to our store. That all works fine. They can input their card number and then come back to our store after submitting it. The issue is after it gets return nothing happens through paypal. No orders or payment are exchanged.
In your return function, the function that gets called when this URL is executed: http://store.site.com/cart/successful-payment you need to call completePurchase. Something like this:
$gateway = Omnipay::gateway('paypal');
//production
$gateway->setUsername('11111111');
$gateway->setPassword('1111111111');
$gateway->setSignature('111111111');
$purchaseId = $_GET['PayerID'];
$response = $gateway->completePurchase([
'transactionReference' => $purchaseId
])->send();
// .. check $response here.

Show billing and shipping information in Paypal Express using Omnipay

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.

Paypal Refund Option Programmatically

I have integrated paypal payment in my project .
I would like to include automatic refund option.
require_once('includes/paypal.class.php');
require_once('includes/paypal.adaptive.class.php');
include('includes/config.php');
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject
);
$PayPal = new PayPal_Adaptive($PayPalConfig);
// Prepare request arrays
$RefundFields = array(
'CurrencyCode' => USD',
// Required. Must specify code used for original payment. You do not need to specify if you use a payKey to refund a completed transaction.
'PayKey' => '',
// Required. The key used to create the payment that you want to refund.
'TransactionID' => '7C0359353Y165821P',
// Required. The PayPal transaction ID associated with the payment that you want to refund.
'TrackingID' => ''
// Required. The tracking ID associated with the payment that you want to refund.
);
$Receivers = array();
$Receiver = array(
'Email' => 'jilu#newagesmb.com',
// A receiver's email address.
'Amount' => '100.00',
// Amount to be debited to the receiver's account.
'Primary' => '',
// Set to true to indicate a chained payment. Only one receiver can be a primary receiver. Omit this field, or set to false for simple and parallel payments.
'InvoiceID' => '',
'PaymentType' => 'GOODS'
// The transaction subtype for the payment. Allowable values are: GOODS, SERVICE
);
array_push($Receivers, $Receiver);
$PayPalRequestData = array(
'RefundFields' => $RefundFields,
'Receivers' => $Receivers
);
//print_r($PayPalRequestData);exit;
$PayPalResult = $PayPal->Refund($PayPalRequestData);
echo '<pre />';
print_r($PayPalResult);
My Output is:
2014-04-28T02:54:20.805-07:00Failure55b35d9b576e810680030560022PLATFORMApplicationErrorApplicationThe X-PAYPAL-APPLICATION-ID header contains an invalid valueX-PAYPAL-APPLICATION-ID
Did your application fully approved via PayPal?
You can check it from below link:
https://www.paypal-apps.com/user/my-account/applications
You can use application ID if it has been fully approved via PayPal. You can try this after confirmation from above URL.

Categories