anouarabdsslm / laravel-paypalpayment Goto Github PK
View Code? Open in Web Editor NEWLaravel paypal payment package , help you process credit card payment using paypal api
License: Apache License 2.0
Laravel paypal payment package , help you process credit card payment using paypal api
License: Apache License 2.0
Hi, using paypal method I've modified the create controller in this way:
public function create()
{
$payer = Paypalpayment::Payer();
$payer->setPayment_method("paypal");
$amount = Paypalpayment:: Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$transaction = Paypalpayment:: Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("This is the payment description.");
$paymentId = '1234';
$PayerID = '[email protected]';
$payment = Paypalpayment:: Payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->get($paymentId, $this->_apiContext);
$execution = Paypalpayment::PaymentExecution();
$execution->setPayer_id($PayerID);
//Execute the payment
$payment->execute($execution,$this->_apiContext);
}
And this is the error:
PayPal \ Exception \ PPConnectionException
Got Http response code 404 when accessing https://api.sandbox.paypal.com/v1/payments/payment/1234. Retried 0 times.
PaymentId is 1234 only for test, what is the problem? The $_ClientId and $_ClientSecret are correctly setted.
And another question, how can i redirect to my site after payment?
Thankyou very much
Whenever i try to call Paypalpayment::OAuthTokenCredential() i get this error:
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'PPConfigManager' not found","file":"***\vendor\anouar\paypalpayment\src\Anouar\Paypalpayment\PaypalPayment.php","line":156}}
Laravel doesn't seem to find the normal PayPal SDK Classes, although they are correctly installed by composer. Haven't been able to fix this in about three hours now... any ideas?
Am getting this error while a successful payment is made on Sandbox/Live
Method PayPal\Api\Sale::getTransactionFee() does not exist
While digging in google found that it was a PayPal API SDK bug, which was fixed on a newer release of the SDK. Could you please update the PayPal SDK version of this project? That might fix this issue.
$details = Paypalpayment::Details();
$details->setShipping($postage)
->setSubtotal(Cart::totalPrice());
Call to undefined method Anouar\Paypalpayment\PaypalPayment::Details()
Hello, for some reasons I'm not allowed to upgrade to Laravel 4.1. I'm using Laravel 4.0. So how can I use the package with this version of Laravel?
I'm trying to add several products in a settlement but sends me an error
Is this
public function addItem($items){
$item=Paypalpayment::item();
$item->setName($item->name)
>setDescription($items>descripcion)
->setCurrency('USD')
>setQuantity($items>cantidad)
->setTax(0.2)
>setPrice($items>precio);
return $item;
}
$prod=Producto::all();
$productos=array();
//$productos [];
$total = Producto::sum('precio');
foreach ($prod as $p) {
array_push($productos,$this->addItem($p));
}
el error
PayPalConnectionException in PayPalHttpConnection.php line 176: Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
There is an error when i try to get any url:
BadMethodCallException in ServiceProvider.php line 226:
Call to undefined method [package]
I only installed project according to instruction.
PayerID is from paypal return value, not some payer id value of your database records.
At the time of payment I got an error:
Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
Am getting an error -
exception 'ReflectionException' with message 'Method PayPal\Api\Sale::getTransactionFee() does not exist'
in /opt/lampp/htdocs/************/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PPReflectionUtil.php:73
When I digged in Google found that it was some weird compatibility error from PayPal SDK itself.
(Refer: https://github.com/paypal/PayPal-PHP-SDK#latest-updates).
In their page they said:
Seeing this error: 'Method PayPal\Api\Sale::getTransactionFee() does not exist' in paypal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PPReflectionUtil.php:73, Please upgrade the SDK to latest version v1.3.0.
So please update your 1.0
release to the latest PayPal SDK (1.3.0
) version to fix this error! Currently it seems to use a very old 0.15.1
.
Awaiting your fix!!
Package will not install when running on Laravel 4.2
Got this little error while trying to get payment details by id:
[2014-12-19 11:53:27] production.ERROR: exception 'ErrorException' with message 'Array to string conversion' in /home/glissand/domains/ebooks.glissando.pl/vendor/paypal/rest-api-sdk-php/lib/PayPal/Auth/OAuthTokenCredential.php:185
rest-api-sdk-php have newer version, maybe it could resolve the problem?
Hi,
I know we can merge the config directly from the controller. But, would be nice if we can update the config via Laravel config instead of ini
file. My suggestion is added a config file that can be publish to the config
folder, maybe.
What if I want to use other method payment like donation?
/*
* Process payment using credit card
*/
public function store(Request $request)
{
$paypalPayment = new Paypalpayment();
// ### Api Context
// Pass in a `ApiContext` object to authenticate
// the call. You can also send a unique request id
// (that ensures idempotency). The SDK generates
// a request id if you do not pass one explicitly.
$this->_apiContext = $paypalPayment->ApiContext($this->_ClientId, $this->_ClientSecret);
// Uncomment this step if you want to use per request
// dynamic configuration instead of using sdk_config.ini
$this->_apiContext->setConfig(array(
'mode' => 'sandbox',
'service.EndPoint' => 'https://api.sandbox.paypal.com',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => __DIR__.'/../PayPal.log',
'log.LogLevel' => 'FINE'
));
$data = $this->validateInput($request);
if (!empty($data['error'])) {
return $this->returnInvalid($data['error'], self::INVALID_MESSAGE);
}
if (($data['expiration_year'] == date('Y')) && ($data['expiration_month'] <= date('m'))) {
return $this->returnInvalid(['Expiration date of card is less than current date']);
}
if (empty($data['post']) || (!empty($data['post']) && !$data['post']['id'])) {
return $this->returnInvalid(['Please select the post before procced']);
}
$postRow = Post::getRowById($data['post']['id']);
if (!$postRow) {
return $this->returnInvalid(['This post does not exist']);
}
// ### CreditCard
$card = $paypalPayment->creditCard();
$card->setType($data['type'])
->setNumber($data['card'])
->setExpireMonth($data['expiration_month'])
->setExpireYear($data['expiration_year'])
->setCvv2($data['cvv'])
->setFirstName($data['first_name'])
->setLastName($data['last_name']);
// ### FundingInstrument
// A resource representing a Payer's funding instrument.
// Use a Payer ID (A unique identifier of the payer generated
// and provided by the facilitator. This is required when
// creating or using a tokenized funding instrument)
// and the `CreditCardDetails`
$fi = $paypalPayment->fundingInstrument();
$fi->setCreditCard($card);
// ### Payer
// A resource representing a Payer that funds a payment
// Use the List of `FundingInstrument` and the Payment Method
// as 'credit_card'
$payer = $paypalPayment->payer();
$payer->setPaymentMethod("credit_card")
->setFundingInstruments(array($fi));
$item1 = $paypalPayment->item();
$item1->setName($postRow->title)
->setDescription($postRow->description)
->setCurrency('USD')
->setQuantity(1)
->setPrice($postRow->price);
$itemList = $paypalPayment->itemList();
$itemList->setItems(array($item1));
$details = $paypalPayment->details();
$details->setSubtotal($postRow->price);
//Payment Amount
$amount = $paypalPayment->amount();
$amount->setCurrency("USD")
// the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
->setTotal($postRow->price)
->setDetails($details);
// ### Transaction
// A transaction defines the contract of a
// payment - what is the payment for and who
// is fulfilling it. Transaction is created with
// a `Payee` and `Amount` types$payments = Paypalpayment::getAll(array('count' => 1, 'start_index' => 0), $this->_apiContext);
$transaction = $paypalPayment->transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$baseUrl = $request->root();
$redirectUrls = $paypalPayment->redirectUrls();
$redirectUrls->setReturnUrl($baseUrl.'/payment/confirmpayment');
// ### Payment
// A Payment Resource; create one using
// the above types and intent as 'sale'
$payment = $paypalPayment->payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
$request = clone $payment;
try {
// ### Create Payment
// Create a payment by posting to the APIService
// using a valid ApiContext
// The return object contains the status;
$response = $payment->create($this->_apiContext);
} catch (PayPal\Exception\PayPalConnectionException $e) {
$data = json_decode($e->getData());
$error_message = $data->details[0]->issue;
echo $error_message;
exit;
}
$this->_paymentId = $response->id;
// dd($response);
$redirectUrl = $response->links[0]->href;
return Redirect::to( $redirectUrl );
}
public function getConfirmpayment()
{
$payer_id = Input::get('PayerID');
$payment = Paypalpayment::get($this->_paymentId, $this->_apiContext);
$paypalPayment = new Paypalpayment();
$paymentExecution = $paypalPayment->paymentExecution();
$paymentExecution->setPayer_id( $payer_id );
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
dd($executePayment);
}
I have written this code in my controller but after return Redirect::to( $redirectUrl ); when I am redirecting to https://api.sandbox.paypal.com/v1/payments/payment/PAY-9U637020G4057981HKZKV5FA . It's giving me 401 unautherized error.
Please can you help me out to resolve this problem
I have this code, but i want to define de amount details, but the response of the api is the code 400. Help me please.
$payer = Paypalpayment::Payer();
$payer->setPayment_method("paypal");
$item = Paypalpayment::Item();
$item->setQuantity("1");
$item->setName("Servicio nubeGAN");
$item->setPrice($inputs['precio']);
$item->setCurrency("MXN");
$item_list = Paypalpayment::ItemList();
$item_list->setItems(array($item));
$amount = Paypalpayment::Amount();
$amount->setCurrency("MXN");
$amount->setTotal($inputs['precio']);
$transaction = Paypalpayment::Transaction();
$transaction->setAmount($amount);
$transaction->setItem_list($item_list);
$transaction->setDescription("Pago para adquirir el Servicio nubeGAN");
$baseUrl = Request::root();
$redirectUrls = Paypalpayment:: RedirectUrls();
$redirectUrls->setReturn_url($baseUrl.'/paypal/ejecutar');
$redirectUrls->setCancel_url($baseUrl);
$payment = Paypalpayment:: Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
$this->_paymentId = $response->id;
$redirectUrl = $response->links[1]->href;
There is an error with this new parameter in json.
Method PayPal\Api\Sale::getTransactionFee() does not exist
Apparently the current classes are not contemplating this new response parameter.
I get this error when trying to start a transaction:
PayPal\Exception\PPConnectionException error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
It's fixed in new sdk-core-php release, but i can't update sdk-core-php lib because of the requirements:
"paypal/rest-api-sdk-php": "v0.7.0" > "paypal/sdk-core-php": "2.4.*"
But for the fix I need latest sdk-core-php version. What can I do?
When I run this piece of code with paypal item list set, I get Error:
Got Http response code 400 when accessing https://api.sandbox.paypal.com/v1/payments/payment.
But if I comment out$transaction->setItemList($itemList)
, I'm successfully redirected to paypal confirmation page.
What I'm doing wrong?
public function someFunction()
{
$payer = PaypalPayment::payer();
$payer->setPayment_method("paypal");
$amount = PaypalPayment::amount();
$amount->setCurrency('USD')
->setTotal(20);
$paypalItem = PaypalPayment::item();
$paypalItem->setName('dasfasdl')
->setCurrency('USD')
->setQuantity(1)
->setPrice(20);
$itemList = Paypalpayment::itemList();
$itemList->setItems([$paypalItem]);
$transaction = PaypalPayment::transaction();
$transaction->setAmount($amount);
$transaction->setItemList($itemList); // This line cause the issue, Item list is array of one paypal item object
$transaction->setDescription("Payment description");
$transaction->setInvoiceNumber(545465);
$baseUrl = Request::root();
$redirectUrls = PaypalPayment::redirectUrls();
$redirectUrls->setReturn_url($baseUrl.'/payment/confirmpayment');
$redirectUrls->setCancel_url($baseUrl.'/payment/cancelpayment');
$payment = PaypalPayment::payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setRedirectUrls($redirectUrls);
$payment->setTransactions([$transaction]);
$response = $payment->create($this->apiContext);
$this->paymentId = $response->id;
$redirectUrl = $response->links[1]->href;
return Redirect::to($redirectUrl);
}
Does it support paypal direct payment where you insert directly credit cart information?
I got this when I send my request to paypal for payments Got Http response code 401 when accessing https://api.sandbox.paypal.com/v1/oauth2/token.
I got this error log:
[2014-12-19 11:45:46] production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Anouar\Paypalpayment\Self' not found' in /home/glissand/domains/ebooks.glissando.pl/vendor/anouar/paypalpayment/src/Anouar/Paypalpayment/PaypalPayment.php:236
Should it be self:: instead of Self:: ?
Copied the example code to test, client id and secret are fine but i get this error
Got Http response code 401 when accessing https://api.sandbox.paypal.com/v1/oauth2/token. Retried 0 times
Hi, please help me.
It's possible work with SetExpressCheckout? How
Tankyou
how can i set payment type to paypal so users will pay it from paypal and get me response back
I have payment ID, but i don't generate payer ID.
My payment method is "paypal"
$payer = Paypalpayment::Payer();
$payer->setPayment_method("paypal");
$amount = Paypalpayment:: Amount();
$amount->setCurrency("MXN");
$amount->setTotal("250");
$transaction = Paypalpayment:: Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("Pago por Servicio nubeGAN");
$baseUrl = Request::root();
$redirectUrls = Paypalpayment:: RedirectUrls();
$redirectUrls->setReturn_url($baseUrl.'/payment/confirmpayment');
$redirectUrls->setCancel_url($baseUrl.'/payment/cancelpayment');
$payment = Paypalpayment:: Payment();
$payment->setIntent("sale");
$payment->setRedirectUrls($redirectUrls);
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$response = $payment->create($this->_apiContext);
The response of state is created.
I want to generate a execution of the payment.
I have this errors how can i fix it thanks
PayPalInvalidCredentialException in PayPalCredentialManager.php line 154:
Credential not found for default user. Please make sure your configuration/APIContext has credential information
how can i enable refund in paypal
when I try to run any command or access any page I get this:
console error:
HP Fatal error: Call to undefined method Anouar\Paypalpayment\Facades\PaypalPayment::isDeferred() in /Users/gages/laravel/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 94
{{
"error":{
"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException",
"message":"Call to undefined method Anouar\\Paypalpayment\\Facades\\PaypalPayment::isDeferred()",
"file":"\/Users\/joeolivas\/Desktop\/gages\/butterfly-laravel\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/ProviderRepository.php",
"line":94
}
}
I have tried with and without a controller file, same error, breaking laravel as an entirety.
I'm using L5 and with command anouar/paypalpayment:~1.* I have an error and if I use 1.* I have old version not for L5, to solv problem I have overwrite folder from the online version.
Hi,
i dont see in doc and code about installment, this package have it ?
Thanks!
Please support Laravel 4.1. There should be no breaking changes, you would only have to update your dependencies to 4.1
Please support Laravel 5.0.*
Could you use this to find details of the transaction by going to a url like
/paypal/{transaction_id}/get
Im trying to access transactions on my account via a dashboard.
I am setting custom field like this :
$transaction = Paypalpayment:: Transaction();
$transaction->setAmount($amount);
$transaction->setDescription('Make Payemnt');
$transaction->setCustom('8');
but i am not getting it any where in return url action:
public function getConfirmpayment()
{
$payment_id = Input::get('paymentId');
$payer_id = Input::get('PayerID');
$token = Input::get('token');
$payment = Paypalpayment::get($payment_id, $this->_apiContext);
$paymentExecution = Paypalpayment::PaymentExecution();
$paymentExecution->setPayer_id( $payer_id );
$executePayment = $payment->execute($paymentExecution, $this->_apiContext);
//check your response and whatever you want with the response
//....
return var_dump($executePayment );
}
solved
Does this support lumen? Can you document it please.
How to get your script listen for IPN ?
link about IPN
https://developer.paypal.com/docs/classic/products/instant-payment-notification/
Even when i am setting mode to live like below its redirecting to https://www.sandbox.paypal.com
$this->_apiContext->setConfig(array(
'mode' => 'live',
'http.ConnectionTimeOut' => 30,
'log.LogEnabled' => true,
'log.FileName' => DIR.'/../PayPal.log',
'log.LogLevel' => 'FINE'
));
how to make it redirect to https://www.paypal.com and not https://www.sandbox.paypal.com?
I have used us account client id and secret ,but still i got the 400 response error ,please guide me.
Thanks in advance
Sorry i've some trouble to post the issue. However using paypal method I've modified the create controller in this way:
public function create()
{
$payer = Paypalpayment::Payer();
$payer->setPayment_method("paypal");
$amount = Paypalpayment:: Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$transaction = Paypalpayment:: Transaction();
$transaction->setAmount($amount);
$transaction->setDescription("This is the payment description.");
$paymentId = '1234';
$PayerID = '[email protected]';
$payment = Paypalpayment:: Payment();
$payment->setIntent("sale");
$payment->setPayer($payer);
$payment->setTransactions(array($transaction));
$payment->get($paymentId, $this->_apiContext);
$execution = Paypalpayment::PaymentExecution();
$execution->setPayer_id($PayerID);
//Execute the payment
$payment->execute($execution,$this->_apiContext);
}
And this is the error:
PayPal \ Exception \ PPConnectionException
Got Http response code 404 when accessing https://api.sandbox.paypal.com/v1/payments/payment/1234. Retried 0 times.
PaymentId is 1234 only for test, what is the problem? The $_ClientId and $_ClientSecret are correctly setted.
And another question, how can i redirect to my site after payment?
Thankyou very much
Still looking around if it is ok in laravel 5.2
Anyone can shed me some light?
This Support Subscription payment in paypal?
unless you bind it into itemslist
$addr = ....
$itemList->setShippingAddress($addr);
It doesn't support PHP currency it will give a response of currency is not supported. I've check it in https://developer.paypal.com/docs/integration/direct/rest-api-payment-country-currency-support/ but they support PHP currency. What will I do? Thanks
Examples in readme.md won't work since methods are not longer static.
Make use of the config file. This way laravel can allow overriding them by the developer.
I just want to implement paypal in laravel for paying the people who request for payout. Is there any method so that i can use the feature of paypal?
Thanks in advance
HI all, please help me.
I am using Laravel 4.*
in file composer
...
"anouar/paypalpayment": "1.0"
...
Made payment success on Paypal but when redirect to Pay Success page (my website)
Error: Call to undefined method Anouar\Paypalpayment\PaypalPayment::get()
My code succes page:
// Get the payment Object by passing paymentId
// payment id and payer ID was previously stored in database in
// create() fuction , this function create payment using "paypal" method
$paymentId = $_GET['paymentId'];
$PayerID = $_GET['PayerID'];
$payment = Paypalpayment::get($paymentId, $this->_apiContext);
// PaymentExecution object includes information necessary
// to execute a PayPal account payment.
// The payer_id is added to the request query parameters
// when the user is redirected from paypal back to your site
$execution = Paypalpayment::PaymentExecution();
$execution->setPayerId($PayerID);
//Execute the payment
$payment->execute($execution,$this->_apiContext);
Please help me.
Thanks so much.
The code causes this problem.
$amountDetails = Paypalpayment::AmountDetails();
The odd thing is that it seems to be included in this code:
File: PaypalPayment.php
<?php namespace Anouar\Paypalpayment;
use PayPal\Api\Address;
use PayPal\Api\Amount;
use PayPal\Api\AmountDetails; // It's here but.... not...
use PayPal\Api\Authorization;
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.