GithubHelp home page GithubHelp logo

anouarabdsslm / laravel-paypalpayment Goto Github PK

View Code? Open in Web Editor NEW
335.0 32.0 198.0 119 KB

Laravel paypal payment package , help you process credit card payment using paypal api

License: Apache License 2.0

PHP 100.00%

laravel-paypalpayment's Introduction

Important :The use of the PayPal REST /payments APIs to accept credit card payments is restricted by paypal and they recomand to use Braintree Direct if you want to accept credit card payments.

Update: I may re-create the package to use Braintree in future but with no deadline. You can also use the braintree/braintree_php library.

Note :

If you're going to use this package with Laravel 4, make sure to require the Laravel 4 branch:

"require": {
    "anouar/paypalpayment": "dev-l4"
}

laravel-paypalpayment

Build Status

laravel-paypalpayment is a simple package that helps you to process direct credit card payments, stored credit card payments and PayPal account payments with your Laravel 4/5 projects using PayPal REST API SDK.

Donation :

donate a cup of ☕ 😊 : Click here to lend your support to: github and make a donation at pledgie.com !

Installation

Install this package through Composer. To your composer.json file:

"require": {
    "anouar/paypalpayment": ">=3.0"
}

Next, run composer update.

Add the service provider to config/app.php (app/config/app.php for Laravel 4), in the providers array.

'providers' => array(
    // ...

    Anouar\Paypalpayment\PaypalpaymentServiceProvider::class,
)

Then add an alias under aliases array.

'aliases' => array(
    // ...

    'Paypalpayment'   => Anouar\Paypalpayment\Facades\PaypalPayment::class,
)

Finaly Pulish the package configuration by running this CMD

php artisan vendor:publish --provider="Anouar\Paypalpayment\PaypalpaymentServiceProvider"

Configuration

Under config/paypal_payment.php configuration file set your paypal client_id and client_secert keys

Samples

Note: If you are not fan of using facade calls, you can resove the paypal payment service like so app('paypalpayment') then assign it to a property.

1-Using credit card as paypent method

Create new controller PaypalPaymentController:

use Paypalpayment;
class PaypalPaymentController extends BaseController {

    /*
    * Process payment using credit card
    */
    public function paywithCreditCard()
    {
        // ### Address
        // Base Address object used as shipping or billing
        // address in a payment. [Optional]
        $shippingAddress = Paypalpayment::shippingAddress();
        $shippingAddress->setLine1("3909 Witmer Road")
            ->setLine2("Niagara Falls")
            ->setCity("Niagara Falls")
            ->setState("NY")
            ->setPostalCode("14305")
            ->setCountryCode("US")
            ->setPhone("716-298-1822")
            ->setRecipientName("Jhone");

        // ### CreditCard
        $card = Paypalpayment::creditCard();
        $card->setType("visa")
            ->setNumber("4758411877817150")
            ->setExpireMonth("05")
            ->setExpireYear("2019")
            ->setCvv2("456")
            ->setFirstName("Joe")
            ->setLastName("Shopper");

        // ### 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([$fi]);

        $item1 = Paypalpayment::item();
        $item1->setName('Ground Coffee 40 oz')
                ->setDescription('Ground Coffee 40 oz')
                ->setCurrency('USD')
                ->setQuantity(1)
                ->setTax(0.3)
                ->setPrice(7.50);

        $item2 = Paypalpayment::item();
        $item2->setName('Granola bars')
                ->setDescription('Granola Bars with Peanuts')
                ->setCurrency('USD')
                ->setQuantity(5)
                ->setTax(0.2)
                ->setPrice(2);


        $itemList = Paypalpayment::itemList();
        $itemList->setItems([$item1,$item2])
            ->setShippingAddress($shippingAddress);


        $details = Paypalpayment::details();
        $details->setShipping("1.2")
                ->setTax("1.3")
                //total of items prices
                ->setSubtotal("17.5");

        //Payment Amount
        $amount = Paypalpayment::amount();
        $amount->setCurrency("USD")
                // the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
                ->setTotal("20")
                ->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

        $transaction = Paypalpayment::transaction();
        $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid());

        // ### Payment
        // A Payment Resource; create one using
        // the above types and intent as 'sale'

        $payment = Paypalpayment::payment();

        $payment->setIntent("sale")
            ->setPayer($payer)
            ->setTransactions([$transaction]);

        try {
            // ### Create Payment
            // Create a payment by posting to the APIService
            // using a valid ApiContext
            // The return object contains the status;
            $payment->create(Paypalpayment::apiContext());
        } catch (\PPConnectionException $ex) {
            return response()->json(["error" => $ex->getMessage()], 400);
        }

        return response()->json([$payment->toArray()], 200);
    }
     
}

2-Using Express Checkout as payment method

    /*
    * Process payment with express checkout
    */
    public function paywithPaypal()
    {
        // ### Address
        // Base Address object used as shipping or billing
        // address in a payment. [Optional]
        $shippingAddress= Paypalpayment::shippingAddress();
        $shippingAddress->setLine1("3909 Witmer Road")
            ->setLine2("Niagara Falls")
            ->setCity("Niagara Falls")
            ->setState("NY")
            ->setPostalCode("14305")
            ->setCountryCode("US")
            ->setPhone("716-298-1822")
            ->setRecipientName("Jhone");

        // ### 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("paypal");

        $item1 = Paypalpayment::item();
        $item1->setName('Ground Coffee 40 oz')
                ->setDescription('Ground Coffee 40 oz')
                ->setCurrency('USD')
                ->setQuantity(1)
                ->setTax(0.3)
                ->setPrice(7.50);

        $item2 = Paypalpayment::item();
        $item2->setName('Granola bars')
                ->setDescription('Granola Bars with Peanuts')
                ->setCurrency('USD')
                ->setQuantity(5)
                ->setTax(0.2)
                ->setPrice(2);


        $itemList = Paypalpayment::itemList();
        $itemList->setItems([$item1,$item2])
            ->setShippingAddress($shippingAddress);


        $details = Paypalpayment::details();
        $details->setShipping("1.2")
                ->setTax("1.3")
                //total of items prices
                ->setSubtotal("17.5");

        //Payment Amount
        $amount = Paypalpayment::amount();
        $amount->setCurrency("USD")
                // the total is $17.8 = (16 + 0.6) * 1 ( of quantity) + 1.2 ( of Shipping).
                ->setTotal("20")
                ->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

        $transaction = Paypalpayment::transaction();
        $transaction->setAmount($amount)
            ->setItemList($itemList)
            ->setDescription("Payment description")
            ->setInvoiceNumber(uniqid());

        // ### Payment
        // A Payment Resource; create one using
        // the above types and intent as 'sale'

        $redirectUrls = Paypalpayment::redirectUrls();
        $redirectUrls->setReturnUrl(url("/payments/success"))
            ->setCancelUrl(url("/payments/fails"));

        $payment = Paypalpayment::payment();

        $payment->setIntent("sale")
            ->setPayer($payer)
            ->setRedirectUrls($redirectUrls)
            ->setTransactions([$transaction]);

        try {
            // ### Create Payment
            // Create a payment by posting to the APIService
            // using a valid ApiContext
            // The return object contains the status;
            $payment->create(Paypalpayment::apiContext());
        } catch (\PPConnectionException $ex) {
            return response()->json(["error" => $ex->getMessage()], 400);
        }

        return response()->json([$payment->toArray(), 'approval_url' => $payment->getApprovalLink()], 200);
    }

3-List Payment

Add the index() function to the PaypalPaymentController Controller

    /*
        Use this call to get a list of payments. 
        url:payment/
    */
    public function index()
    {

        $payments = Paypalpayment::getAll(['count' => 1, 'start_index' => 0], Paypalpayment::apiContext());
        
        return response()->json([$payments->toArray()], 200);

    }

4-Get Payment details

Add the show() function to the PaypalPaymentController Controller

    /*
        Use this call to get details about payments that have not completed, 
        such as payments that are created and approved, or if a payment has failed.
        url:payment/PAY-3B7201824D767003LKHZSVOA
    */

    public function show($payment_id)
    {
       $payment = Paypalpayment::getById($payment_id, Paypalpayment::apiContext());
        
        return response()->json([$payment->toArray()], 200);
    }

Under the (routes.php for previous versions) or web.php file and register your routing.

Conclusion

Please feel free to report issues and open any PRs that you thinks will help to improve the package.

laravel-paypalpayment's People

Contributors

al0mie avatar anouarabdsslm avatar chriskonnertz avatar ghostprofile avatar grahamcampbell avatar haplifeman avatar jonathanfreites avatar josephting avatar justgage avatar kasperfranz avatar mferrara avatar mix5003 avatar nemo3000 avatar pelhage avatar webwizo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-paypalpayment's Issues

Http response code 400 when list of items is added

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

using paypal method

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

not getting custom field in return url

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

Add multiple items

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.

Payer ID

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.

Please Upgrade the PayPal SDK to fix an error in 1.0 release

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!!

Error new parameter in Json 'TransactionFee'

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.

Response Code 400

I have used us account client id and secret ,but still i got the 400 response error ,please guide me.

Thanks in advance

Array to string conversion during OAuth

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?

Installment payment

Hi,

i dont see in doc and code about installment, this package have it ?

Thanks!

PayPal SDK Classes not found

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?

401 Unauthorized in sandbox redirect url

/*
* 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

Laravel 4.2 error when Paypal redirect PatmentSuccess page.

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.

Error directly after install.

when I try to run any command or access any page I get this:
screen shot 2013-10-22 at 3 03 07 pm
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.

SSL3 wrong version number

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?

Accessing Transactions

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.

Details

$details = Paypalpayment::Details();
$details->setShipping($postage)
        ->setSubtotal(Cart::totalPrice());
Call to undefined method Anouar\Paypalpayment\PaypalPayment::Details()

Laravel 5 error

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.

Class 'PayPal\Api\AmountDetails' not found

The code causes this problem.

$amountDetails = Paypalpayment::AmountDetails(); 

screen shot 2013-12-05 at 2 28 00 pm

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;

Support Laravel 4.1

Please support Laravel 4.1. There should be no breaking changes, you would only have to update your dependencies to 4.1

Amount Details

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;

Composer

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.

Problem with Self

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:: ?

Use Laravel Config

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.

Lumen Support

Does this support lumen? Can you document it please.

Support Laravel 4.0.x ?

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?

using paypal method

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.