How do I get PayPal_Express response using OmniPay? - laravel-4

I have searched all over and have ran in circles on OmniPays github trying to find documentation on how to implement PayPal Express in OmniPay.
$response = Omnipay::purchase([
'amount' => $total,
'encodedTestIDs' => serialize($payForTestID),
'returnUrl' => 'http://php.bhiceu.com/payment/return',
'cancelUrl' => 'http://php.bhiceu.com/payment/cancel'
])->send();
//dd($response);
//die;
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
The above code successfully sends me to PayPal with the proper amount and when I cancel or check I am returned to the appropriate URLS, however all that I get back is the paypal token which I cannot find any documentation on what to do with.

You need to complete the purchase by using completePurchase() method.
look at omnipay/example code at https://github.com/thephpleague/omnipay-example/blob/master/index.php#L203-L218

The answer ended up being quite simple, but I had to go digging through the source code for it as the documentation for the library is non-existent.
$response = Omnipay::completePurchase([
'amount' => $price,
'currency' => $currency
])->send();
You simply call Omnipay::completePurchase with the same amount and currency as the initial Omnipay::purchase call.
After this, you would use Omnipay::fetchCheckout()->send() to obtain information like the shipping address etc.

Related

Hi iam sending card details via paypal omnipay. payment showing success but not appearing in paypal

Hi I am ingerating paypal/omnipay. o am sending credit card details
to paypal,this is showing success. but i cannot find any of the
transactions in my paypal sandbox account.
My code is like this:
$card = new CreditCard($formData);
$response = $this->gateway->purchase(
[
'amount' => '10.00',
'currency' => 'USD',
'card' => $card ,
'returnUrl' =>url('/paypalreturn'),
'cancelUrl' =>url('/cancelpaypal'),
]## Heading ##
)->send();
the response from paypal like
"TOKEN" => "EC-262806394V614015G"
"TIMESTAMP" => "2019-07-25T16:40:24Z"
"CORRELATIONID" => "3cc9ebc7e1458"
"ACK" => "Success"
"VERSION" => "119.0"
"BUILD" => "53374502"
all is going well , except i cannot see the transaction in paypal sandbox.Can any one tell me where i am going
wrong? Thanks for help in advance
after a long research i found out that paypal rest api is the best answer for this question. after a long headache i found the answer here : Does the creditCard function exist in Omnipay PayPal Express? Or only in PayPal Pro?
Hope this helps some one

Payments with Laravel Omnipay (mollie gateway)

I'm currently stuck trying to create a payment with Omnipay. I have the following libraries installed in my project:
https://github.com/barryvdh/laravel-omnipay
https://github.com/thephpleague/omnipay-mollie
But I'm having problems starting. I see in the example that I need these params:
$params = [
'amount' => $order->amount,
'issuer' => $issuerId,
'description' => $order->description,
'returnUrl' => URL::action('PurchaseController#return', [$order->id]),
];
But what's the $issuerId? I would like to have an integration with Mollie.
Does someone maybe has an example of using laravel Omnipay with Mollie?
UPDATE:
I'm trying to submit my form with an ajax call. In my PHP function I have the following code:
$gateway = Omnipay\Omnipay::create('Mollie');
$gateway->setApiKey('test_gSDS4xNA96AfNmmdwB3fAA47zS84KN');
$params = [
'amount' => $ticket_order['order_total'] + $ticket_order['organiser_booking_fee'],
'description' => 'Kapelhoek wijkfeesten',
'returnUrl' => URL::action('EventCheckoutController#fallback'),
];
$response = $gateway->purchase($params)->send();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response); die;
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
return $response->getRedirectResponse(); die;
} else {
// payment failed: display message to customer
echo $response->getMessage(); die;
}
But now I'm getting the following console error:
XMLHttpRequest cannot load https://www.mollie.com/payscreen/select-method/PRMtm6qnWG. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://kapelhoektickets.dev' is therefore not allowed access.
How can I fix this?
But what's the $issuerId?
Issuer ID is The issuer's unique identifier, for example ideal_ABNANL2A. When creating a payment, specify this ID as the issuer parameter to forward the consumer to their banking environment directly.
You can see a list of available issuers by calling this API url:
https://api.mollie.nl/v1/issuers
as stated in https://www.mollie.com/be/docs/reference/issuers/list
To read more about the issuer visit this part of the API-documentation:
https://www.mollie.com/be/docs/reference/issuers/get

Laravel - Payone

Is there an easy wrapper for the payone(https://www.payone.de/) API for Laravel? I only found one company who sells a package but nothing that is open source. I would appreciate any help.
You should consider Omnipay: http://omnipay.thephpleague.com/
Because:
It is gateway independent.
It is framework independent. It works well with Laravel but also Symfony, Yii, etc.
There is an Omnipay plugin for PayOne: https://github.com/academe/OmniPay-Payone
The code to make a purchase via Omnipay is pretty much the same regardless of the gateway. Here is some sample code that should work, although you should check the details of the Payone classes for other information that you need to send. The Payone gateway can work in multiple different ways depending on how your account is set up.
$gateway = Omnipay::create('Payone_ShopServer');
$card = new CreditCard(array(
'firstName' => 'Example',
'lastName' => 'User',
'number' => '4111111111111111',
// ... etc
));
$transaction = $gateway->purchase(array(
'amount' => '10.00',
'currency' => 'USD',
'description' => 'This is a test purchase transaction.',
'card' => $card,
));
$response = $transaction->send();
if ($response->isSuccessful()) {
echo "Purchase transaction was successful!\n";
}
// At this point you should get $response->getTransactionReference()
// and store that or something similar.

How to send 'description' of products to Paypal express (omnipay)?

I have setup a checkout system with Ominpay and Paypal express and it worked fine in test mode so I just went 'live' with it. Unfortunately I didn't check whether all the information was sent to paypal after checkout. It seems only the amount and currency are getting sent and not the description/name of the products. This means the seller doesn't know what got sold!
N.B: Everything gets sent to the Paypal checkout page fine. But after payment is made the product names don't show up on the seller's paypal page - only the quantity and price do.
How can I get the product names to show up on the seller's paypal account? It will be an array because multiple products will be sold.
If it helps here's the site: http://threemarchhares.sukeates.com/
I'm using Laravel 4. My payments controller:
public function postPayment() {
$cart = Session::get('cart');
$allProducts = [];
foreach($cart->aContents as $productID=>$quantity){
$product = Product::find($productID);
$allProducts[] = array('name' => $product->name, 'quantity' => $quantity, 'price'=> $product->price);
}
$params = array(
'cancelUrl' => \URL::to('cancel_order'),
'returnUrl' => \URL::to('payment_success'),
'amount' => Input::get('price'),
'currency' => Input::get('currency'),
'description' => Input::get('name'), //I assume this is wrong as it doesn't work.
);
Session::put('params', $params);
Session::save();
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('*****');
$gateway->setPassword('****');
$gateway->setSignature('***');
$gateway->setTestMode(false);
$response = $gateway->purchase($params)->setItems($allProducts)->send();
$data = $response->getData();
if ($response->isSuccessful()) {
// payment was successful: update database
print_r($response);
} elseif ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
}
public function getSuccessPayment()
{
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('****');
$gateway->setPassword('****');
$gateway->setSignature('*****');
$gateway->setTestMode(false);
$params = Session::get('params');
$response = $gateway->completePurchase($params)->send();
$paypalResponse = $response->getData(); // this is the raw response object
if(isset($paypalResponse['PAYMENTINFO_0_ACK']) && $paypalResponse['PAYMENTINFO_0_ACK'] === 'Success') {
etc
Your assumption is correct. It is a bad idea in general to fill payment data from input. Instead you should use data from your product:
'amount' => $product->price,
'currency' => 'USD',
'description' => $product->description,
Otherwise the user can modify the price in html and enjoy cheap checkout ;)
You need to send the item information again, when you send the 'completePurchase' request.
$response = $gateway->completePurchase($params)->setItems($allProducts)->send();

receive more response data in ci-merchant library codeigniter

How can I receive more response data in the ci-merchant codeigniter library ?
I am using the Paypal Express checkout payment method.
And I am passing the following parameters:
$params = array(
'amount' => 100.00,
'currency' => 'USD',
'return_url' => my return url,
'cancel_url' => my cancel url );
Right now am getting just the following response
Merchant_paypal_api_response Object
(
[_status:protected] => complete
[_message:protected] =>
[_reference:protected] => 1K088384XU0947545
[_data:protected] =>
[_redirect_url:protected] =>
[_redirect_method:protected] => GET
[_redirect_message:protected] =>
[_redirect_data:protected] =>
)
How can I get the data like paypal id, shipping address, item name and other stuff that paypal returns in the DoExpressCheckoutPayment response ?
Actually, that info wouldn't come back in the DECP response. It would come back in GetExpressCheckoutDetails.
Your library should provide some way to see the RAW API requests and responses. If it's not parsing out all of the details for you you'll need to do that on your own.
This isn't exactly an answer to your question, but you should try using Omnipay instead. Omnipay is basically CI-Merchant V2 (I'm the author of both libraries).
Omnipay lets you have direct access to the raw response. E.g. you would do something like this:
$params = array( 'amount' => 1000, 'currency' => 'USD', 'returnUrl' => 'my return url', 'cancelUrl' => 'my cancel url' );
$response = $gateway->completePurchase($params)->send();
$reference = $response->getTransactionReference(); // paypal transaction id
$data = $response->getData(); // this is the raw response object

Resources