thephpleague / omnipay-paypal Goto Github PK
View Code? Open in Web Editor NEWPayPal driver for the Omnipay PHP payment processing library
License: MIT License
PayPal driver for the Omnipay PHP payment processing library
License: MIT License
I have a REST JSON api and I need to charge user in 2 steps(purchase->completePurchase). I got purchase
call return token and PayerID, now I'm trying to do completePurchase
$paypal_token = $this->input->post('paypal_token');
$paypal_payerid = $this->input->post('paypal_payerid');
$request = $this->paypalGateway->completePurchase(
array(
'token' => $paypal_token,
'payerid' => $paypal_payerid,
'amount' => $total,
'currency' => 'USD',
)
);
This issues invalid request to paypal without token and payerid. In fact, if you look in omnipay/paypal/src/Message/ExpressCompleteAuthorizeRequest.php
, line 22, you can see
$data['TOKEN'] = $this->httpRequest->query->get('token');
$data['PAYERID'] = $this->httpRequest->query->get('PayerID');
This is horribly wrong. Even if we pass params manually in completePurchase, they got clobbered by values from GET params and there is no chance to disable this behavior.
I suggest:
setPayerId
to ExpressCompleteAuthorizeRequest
to setPayerId to existing request. Currently, you can do setToken
on request, but no setPayerId
Hi guys,
i've a serious problem with paypal method.
The point is, in the first call that i do with paypal class is:
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername(PaypalPayment::first()->pp_payment_api_username);
$gateway->setPassword(PaypalPayment::first()->pp_payment_api_password);
$gateway->setSignature(PaypalPayment::first()->pp_payment_api_signature);
$gateway->setTestMode(PaypalPayment::first()->pp_payment_sandbox);
$cancel = action('CartController@getRefuse', Session::get('current_lang'));
$return = action('CartController@getConfirm', Session::get('current_lang'));
try {
$response = $gateway->purchase(
array(
'cancelUrl' => $cancel,
'returnUrl' => $return,
'amount' => $total,
'currency' => 'EUR'
)
)->send();
if ($response->isSuccessful()) {
} elseif ($response->isRedirect()) {
$response->redirect(); // this will automatically forward the customer
} else {
exit($response->getMessage());
}
} catch(Exception $e) {
exit('Sorry, there was an error processing your payment. Please try again later.');
}
So days ago i've read that to complete definitively, i just call in the success page stored in return url, the function completePurchase:
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername(PaypalPayment::first()->pp_payment_api_username);
$gateway->setPassword(PaypalPayment::first()->pp_payment_api_password);
$gateway->setSignature(PaypalPayment::first()->pp_payment_api_signature);
$response = $gateway->completePurchase(
array(
'cancelUrl' => $cancel,
'returnUrl' => $return,
'amount' => $total,
'currency' => 'EUR'
)
)->send();
$data = $response->getData(); // this is the raw response object
Now with my sandbox account i see all the notification about the transaction. But with my real business account i dont see anything. Where i'm wrong ? Or why is this happening?
This happened when the user out of italy try to complete a transaction. Please i hope to have a solution as soon as possible. Thanks
So, after talking to PayPal today, the latest API version for the Express Checkout is 119.0
. Since the current library is listed as 85.0
with no mechanism for overriding it, I'd like to know what the best foot forward is - is it better to have a look at the list of changelogs and update the functionality while leaving keyed to a specific API version, or provide a means to set the API version you'd like to call and use the constant as a back up if none is supplied?
Hi,
How can I set the token and payerid at GetExpressCheckoutDetails? because I am writing a mobile app that establish the SetExpressCheckout at the mobile side, and passed the returnurl to web server, after that, webserver do the rest process(GetExpressCheckoutDetails and DoExpressCheckoutPayment). Thanks.
How can I add ability to support more currencies in addition to exiting currencies in Common\Currency.php to use Paypal Express checkout?
I've been troubleshooting an issue that I found was already fixed in #45 and is also on dev-master. Can you please make a new tag that includes this fix?
running the code from the example written in RestGateway.php
produces this exception. Update your code or your documentation.
RestUpdateCardRequest does not work in its current format. The issues are several:
Hi guys,
i notice that, when i complete the payment from paypal like logged user on my site, after the redirect it seems that Session did reset data and i lost the logged state. Why ?
I'm using Paypal_Express like gateway.
From @robuedi on March 4, 2015 8:23
In the PayPal Gateway (omnipay/omnipay/src/omnipay/paypal/messages/ExpressAuthorizeRequest) is only one parameter for the items.
Currently this parameter looks like this:
$data['PAYMENTREQUEST_0_DESC'] = $this->getDescription();
In PayPal an items has many others parameters. Other parameters that should be added are:
$data['L_PAYMENTREQUEST_0_NAME0'] = $this->getName();
$data['L_PAYMENTREQUEST_0_AMT0'] = $this->getAmount();
$data['L_PAYMENTREQUEST_0_NUMBER0'] = $this->getNumber();
$data['L_PAYMENTREQUEST_0_QTY0'] =
$data['ITEMAMT'] = $this->getDescription();
Copied from original issue: thephpleague/omnipay#240
I haven't been able to find option to require a billing address for my SetExpressCheckout calls - am I missing it or is this something I could add and send a PR for?
It should be noted that this option needs to be enabled by PayPal for the account, here are the docs: https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/limited-release/PP_LRD_BillingAddress.pdf
Does this integration allow for REST API calls? If so, could you provide some direction?
Is there an authorization with redirect example available?
I can get the redirect working but only for capture(final sale) but not authorization only.
$formData = [
'number' => '4242424242424242',
'expiryMonth' => '6',
'expiryYear' => '2016',
'cvv' => '123'
];
$response = $gateway->authorize([
'amount' => '10.00',
'card' => $formData,
'returnUrl' => 'https://www.example.com/return',
'cancelUrl' => 'https://www.example.com/cancel'
])->send();
In the past month, I've been getting quite a few transactions that are being flagged as successful, but have actually been denied. Still trying to figure out why they're being denied, but regardless, the isSuccessful() method needs to also check PAYMENTSTATUS to see if the payment actually went through.
Here's a vardump of some of the response data I have:
["TIMESTAMP"]=>
string(20) "2014-04-28T12:10:25Z"
["ACK"]=>
string(7) "Success"
["VERSION"]=>
string(4) "85.0"
["BUILD"]=>
string(8) "10277387"
["TRANSACTIONTYPE"]=>
string(15) "expresscheckout"
["PAYMENTTYPE"]=>
string(7) "instant"
["ORDERTIME"]=>
string(20) "2014-04-28T12:09:48Z"
["AMT"]=>
string(6) "120.00"
["TAXAMT"]=>
string(4) "0.00"
["CURRENCYCODE"]=>
string(3) "AUD"
["PAYMENTSTATUS"]=>
string(6) "Denied"
["PENDINGREASON"]=>
string(4) "None"
["REASONCODE"]=>
string(4) "None"
Completely untested, but I think the the following should fix it. Will look at sending a PR once the dust settles...
public function isSuccessful()
{
$isAck = isset($this->data['ACK']) && in_array($this->data['ACK'], array('Success', 'SuccessWithWarning'));
$isPaid = isset($this->data['PAYMENTSTATUS']) && !in_array(strtolower($this->data['PAYMENTSTATUS']), array('denied', 'failed', 'expired', 'voided'));
return $isAck && $isPaid;
}
The documentation here says this:
$gateway = Omnipay::create('RestGateway');
Which results in this error message for me:
Class '\Omnipay\RestGateway\Gateway' not found
Why is it looking for RestGateway\Gateway
? My composer.json has this line "omnipay/paypal": "~2.0",
and the files are in place.
Update: I 've a made guess how this works and tried it with 'PayPal\Rest'
and made it work this way. The documentation should be updated.
Honestly, from previous experiences with the older versions of Omnipay, I feel all the adapter configuration seems to be pretty inconsistent any way. Depending on where you look you get slightly different instructions on how to set things up.
As far as I know there is no way to set the "L_PAYMENTREQUEST_0_ITEMCATEGORY0" flag to "Digital" in order for micropayment pricing to apply.
I might be missing something but I haven't found a way to use this.
Explained here: https://developer.paypal.com/docs/classic/express-checkout/ht_ec-basicDigGoodsPayment-curl-etc/
Paypal has added an in-context variation for Express checkout
https://developer.paypal.com/webapps/developer/docs/classic/express-checkout/in-context/integration/
On the server, its essentially identical - but makes use of a different redirect url which eliminates the cmd parameter and replaces /cgi-bin/webscr
with /checkoutnow
Easy to work around, but would be nice to have baked into either a different gateway (PayPal_ExpressInContext?) or an optional override on the response object.
For now, munging the redirect url at arms length is enough to get it working:
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername(env('PAYPAL_USERNAME'));
$gateway->setPassword(env('PAYPAL_PASSWORD'));
$gateway->setSignature(env('PAYPAL_SIGNATURE'));
$gateway->setTestMode(env('PAYPAL_ENVIRONMENT') != 'production');
$response = $gateway->purchase(
array(
'cancelUrl'=> url($location),
'returnUrl'=> url('/paypal/success'),
'amount' => $order->finalOrderTotal(),
'currency' => 'USD'
)
)->send();
if ($response->isRedirect()) {
$url = $response->getRedirectUrl();
$url = preg_replace('/cgi-bin\/webscr/', 'checkoutnow', $url);
$url = preg_replace('/cmd=_express-checkout&/', '', $url);
return redirect($url, 302, [], true);
}
For the completePurchase parameters, why do we have to pass them?
The completePurchase parameters are simply grabbed from the url parameters "PayerID" and "transcationReference", correct? Why doesn't it do it automaticially or is to keep consistency? I'm just trying to make sure I am PASSING the correct values.
We've being using this for an eCommerce system and come across the same as #39
We created a new bridge to Omnipay and PayPal Rest in which we added a 'fetchCard' request, when this is used it dumps the return from the API into our root directory as a file named "[]"
This would not be an issue if it wasn't for the fact our customer's addresses and information are publicly accessible.
I have noticed "dev-master" currently holds a fix for this so having it tagged would be a god send.
As this is a live environment we do not want to be using development code on our site.
Hello,
Have anyway to know if user used credit card (and the flag) or another payment type?
Thanks in advance.
Hi.
I use this great package in my laravel site. I log payed items. But, can I use this package to admin can pay to user via paypal, and how? Or you can offer me a another package for that? I now know that method is called 'Adaptive Payments' -> 'Simple Payments' (https://developer.paypal.com/docs/classic/adaptive-payments/integration-guide/APIntro/).
After completing my payments with gateway->completePurchase($params)->send()
, There is no way to get the buyers email for the paypal transaction?
I need to fire send invoice over email to customer after payment from PayPal
how can i do that?
I'm doing my own e-commerce website by using CI with omnipay. I'm facing one problem after paypal express checkout is finished like "Invalid token" - error code:10410.
Below is my code.
require 'vendor/autoload.php';
use Omnipay\Omnipay;
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername("MY-PAYPAL-PRO-USERNAME");
$gateway->setPassword("MY-PAYPAL-PRO-PASSWORD");
$gateway->setSignature("MY-PAYPAL-PRO-SIGNATURE");
$gateway->setTestMode(true); // right now i'm using testing environment
$order_id = $this->insert_order(); // i wrote separate method to insert the order items and it will return the order id.
$params = array(
'amount' => '500',
'currency' => 'USD',
'returnUrl' => base_url("checkout/returnBack/$order_id"),
'cancelUrl' => base_url("checkout/returnBack/$order_id"));
$response = $gateway->completePurchase($params)->send();
$data = $response->getData(); // this is the raw response object
echo '<pre>';
print_r($data);
echo '</pre>';die;
Following is the error:
Array
(
[TIMESTAMP] => 2014-03-04T10:41:49Z
[CORRELATIONID] => 570332778c46c
[ACK] => Failure
[VERSION] => 85.0
[BUILD] => 9917844
[L_ERRORCODE0] => 10410
[L_SHORTMESSAGE0] => Invalid token
[L_LONGMESSAGE0] => Invalid token.
[L_SEVERITYCODE0] => Error
)
Please help me out for this issue. I'm trying last two days, i'm not getting anything from google. Thanks in advance.
When I use
$gatewayFactory=Omnipay::getFactory();
$gateway=$gatewayFactory->create('PayPal_Pro');
error orcurred: "The merchant country is not supported.", Does PayPal_Pro means "Website Payments Pro"(https://developer.paypal.com/docs/classic/paypal-payments-pro/integration-guide/WPWebsitePaymentsPro/)
This should be support China,but why this happened?
All of the REST requests sent by subclasses of AbstractRestRequest are POST requests because the default getHttpMethod method always returns POST. This is not over-ridden in the RestFetchTransactionRequest class however the PayPal documentation states that the fetch transaction request must be GET.
See https://developer.paypal.com/docs/api/#sale-transactions
I have a PR coming for this.
I have setted the credit card information in this way:
$card = new CreditCard(array(
'firstName' => $user->first_name,
'lastName' => $user->last_name,
'number' => Input::get('card_number'),
'expiryMonth' => Input::get('expiry_month'),
'expiryYear' => Input::get('expiry_year'),
'cvv' => Input::get('cvv'),
'billingAddress1' => $user->address,
'billingCity' => $user->city,
'billingPostcode' => $user->zip,
'billingCountry' => $user->country_code,
'billingPhone' => $user->phone,
'email' => $user->email
));
Then i sent them to PayPal_Express gateway. While all the information are sent to PayPal, the 'number', 'expiryMonth', 'expiryYear', 'cvv' values are never sent to PayPal, event if i try to send them manually (like 'number' => '654656677445654654'').
Also i always validate the card number using Helper::validateLuhn(Input::get('card_number')), so the card number is valid.
It would be really nice to have this ont he readme:
TODO: Billing Plans and Agreements -- set up recurring payments.
it was frustrating going through the code and seeing that recurring is still in TODO list...
From @robuedi on March 4, 2015 8:28
When sending client details to PaPal (like adress, name) the automatic refill is not happening. This is caused by the missing of two parameters that should be added in the PayPal Gateway (omnipay/omnipay/src/omnipay/paypal/messages/ExpressAuthorizeRequest):
$data['ADDROVERRIDE'] = 1;
The solution code would look like this:
if ($card = $this->getCard()) {
$data['ADDROVERRIDE'] = 1;
$data['PAYMENTREQUEST_0_SHIPTONAME'] = $card->getName();
$data['PAYMENTREQUEST_0_SHIPTOSTREET'] = $card->getAddress1();
Copied from original issue: thephpleague/omnipay#241
Are there any plans for adding support for making payments with third party token authorization?
For those who are unfamiliar, this is when an access token and secret token are obtained via the PayPal API, and are then used to create an authorization header, allowing transactions to be completed on behalf of a merchant.
Obtaining the access/secret token is beyond the scope of Omnipay, however adding the X-PAYPAL-AUTHORIZATION
header is well within scope. More details at https://developer.paypal.com/docs/classic/permissions-service/ht_permissions-invoice/ (see "Creating the Authorization Header" section).
Paypal Adaptive payments are largerly used in online marketplaces, it would be a really cool feature for Omnipay
In the past I have used html forms to pass hidden 'custom' and 'invoice' parameters to Paypal , during Credit Card transactions using Paypal-Pro, so that I can use them in the IPN response later. However I can't seem to work out how to set/send these two parameters using Omnipay. If anyone could point me in the right direction here it would be appreciated.
PayPal Express checkout has transactions that are held in review which need to be identified differently from a regular successful transaction. They're transactions marked as "Success" in the ACK
field, but they also have PAYMENTINFO_0_PAYMENTSTATUS = Pending
and PAYMENTINFO_0_PENDINGREASON = PaymentReview
as a part of the response. These transactions need to be alerted to the end-user that they aren't successful until reviewed by PayPal.
Is there any kind of pending status as a part of Omnipay to adjust the flow, or does the isSuccessful()
need to be adjusted? It's not really an error condition, so I'm not sure how to handle this in the general case, only some ways that would be specific to PayPal, which I'd like to avoid if there's a better way.
Hi guys,
i've a question, if i wanted to set a locale to display in that current language that i choose, how can i do that ? I remember that with classic paypal api you can set the lc parameter inside the form, but i don't remember how works omnipay/paypal about this parameter.
For some reason when I add this to my composer json, then run update, I'm getting the following error:
But it never resolves, any ideas?? - All my other packages are fine :)
Cheers,
Ben
PayPal is disabling ssl3 next week. https://devblog.paypal.com/poodle-ssl-3-0-vulnerability/
Anybody dealing with this?
Thanks
How to Set up a Reference Transaction
Hi.
I need set the language of my payment gateway to english, i see a mention in an issue of the "setLocaleCode()" function, but how i can use that function?
thanks
Hi,
i'm testing PayPal Express. In doc (https://github.com/thephpleague/omnipay readme) about "Successful Response" i read:
"...
The following methods are always available:
...
$response->getTransactionId(); // the reference set by the originating website if available.
...."
but if i try to use getTransactionId() method, i get the following:
Fatal error: Call to undefined method Omnipay\PayPal\Message\ExpressAuthorizeResponse::getTransactionId()
For PayPal Express this method not exists.
Thanks,
Achille
No support for adaptive payments engine? Is it planned to be any?
Has there been any discussion around using Paypal's vault API (https://developer.paypal.com/webapps/developer/docs/api/#vault) to implement create/update/deleteCard? Would such a pull request be welcomed?
Great Package so far, thanks for your awesome work +1
Will you upgrade the package for PayPal Plus ?
Hi,
currently i try to get my paypal checkout working with laravel.
Therefore i used your awesome package.
I have a question - currently this is a snippet of my post method
public function postPayment()
{
$params = array(
'cancelUrl' => 'http://localhost/cancel_order',
'returnUrl' => 'http://localhost/payment_success',
'name' => Input::get('name'),
'description' => Input::get('description'),
'amount' => Input::get('price'),
'currency' => Input::get('currency'),
);
Session::put('params', $params);
Session::save();
$gateway = Omnipay::create('PayPal_Express');
......
....
........
$response = $gateway->purchase($params)->send();
.......
So far its working. The payment was made and saved to the database.
But where can i set the tax for my product ?
Where do i find the variables which i can post to paypal ?
In the dev docu i didnt found anything so far.
There is no direct option to set USERSELECTEDFUNDINGSOURCE
in config.
http://stackoverflow.com/questions/22799030/paypal-expresscheckout-api-behavior-changed-recently
http://stackoverflow.com/questions/24890228/paypal-express-checkout-pay-without-account/25460906#25460906
If we specify SHIPPINGAMT
, TAXAMT
, HANDLINGAMT
, SHIPDISCAMT
, INSURANCEAMT
along with line item details during authorization, purchase complete request should send these data along. Or we get an exception
The total amount and item amounts do not match.
Right now it is not sending these fields for purchase request. Even if we set the parameters, getData
in ExpressCompletePurchaseRequest
is not looking for these parameters.
I will create a PR for this.
Hi there - Love the easy and effective integration to PayPal's classic API's... Is there anyway to use this to make additional calls to actions such as GetTransactionDetails etc?
Thanks for any help!
how to get details after purchase process?
When trying to use paypal express to authorize a payment and return to the site for confirmation, one issue that I found was that when I was on paypal as the intermediary step between start and confirmation, paypal was calling the buttons 'pay' and 'pay now'. With the desired payment flow I only wanted paypal to confirm the authorisation of the payment at this point, and confirm when back on site.
The offending code is here which forces the buttons to display 'pay'
https://github.com/thephpleague/omnipay-paypal/blob/master/src/Message/ExpressAuthorizeResponse.php#L29
When this value is set, the buttons are displayed as 'pay', when it is ommitted the buttons are displayed as 'review'
We need to be able to re-enforce the fact that payment won't be taken until you've returned back to the original website and confirmed the payment (more data collection is required at this point from my use-case).
I've managed to get this library working completely, except for the lack of naming of the buttons as per the hard coded 'useraction' as illustrated in the link above.
Express documentation showing the examples :
Excerpt from documentation (Bottom of the page)
With Express Checkout, you can shorten your checkout flow to let buyers complete their purchases on PayPal. Then, you can skip your order confirmation page.
Generally, buyers select payment methods as the last step before they complete their purchases. If you collect no additional information after buyers return from PayPal, you can skip the confirm-order page on your website. If you collect additional information that does not affect the payment, PayPal recommends that you collect it after buyers complete their purchases.
The useraction URL parameter in your redirect to PayPal determines whether buyers complete their purchases on PayPal or on your website. If you set useraction to commit, PayPal sets the button text to Pay Now on the PayPal Review your informaton page. This text lets buyers know that they complete their purchases if they click the button.
I want to transfer money between some customer and some seller (not my self). I though this method is exactly what I need. When I am redirected to paypal, I see that seller account is defined right. But when payment is processed, money goes to my account (api account), not to the seller I have defined.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.