Code Monkey home page Code Monkey logo

laravel-paypal's People

Contributors

buzzclue avatar dasundev avatar divdax avatar ericdowell avatar ilsyaa avatar jtolj avatar laravel-shift avatar matheo-2001 avatar matheusbenedet avatar otnansirk avatar raja-omer-mustafa avatar risteacatalin avatar ronheywood avatar shekenz avatar srmklive avatar tomshaw avatar willcurry avatar yob-yob 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

laravel-paypal's Issues

Error on adaptive payments

Adaptive payments

When i try to send an adaptive payment, show this error.

Error message.
Client error: POST https://api-3t.sandbox.paypal.com/nvp/Pay resulted in a 404 Not Found response:

something about the actionType

Adaptive 520003 Authentication failed

When trying to do chained payment I always get this error:

"'1.0' encoding='UTF-8'?>2016-06-13T18:04:28.165-07:00Failure002d6b3b4261a20420247520003PLATFORMApplicationErrorApplicationAuthentication failed. API credentials are incorrect./ns3:FaultMessage

ErrorId 520003
Message Authentication failed. API credentials are incorrect.

I double check my sandbox credentials and are correct:

    'username' => 'jorge.alexandro-facilitator_api1.gmail.com',
    'password' => '1364842417',
    'secret' => 'A8.lGiHnS.gATAUMTDDqJEv32m7eAEygtB5hcwPxiugnKJ6bio.Hl6xY',
    //'certificate' => '',
    'app_id' => 'APP-80W284485P519543T',

Same credentials works good in express checkout only adaptive is not working. Any idea or help?

Method [parsePayPalIPN] does not exist.

please explain how to use this method

public function postNotify(Request $request)
{
$response = $this->parsePayPalIPN($request);

if ($response === 'VERIFIED') {                      
    // Your code goes here ...
}                            

}

overriding the config file variables for SAAS platform

I am working on a saas system where site partners add their paypal info and then get paid by their users directly. But the config file hardcodes this info, is it possible to override these variables from the controller ?

some problems with guzzle post

ErrorException in PayPalRequest.php line 291:
Object of class GuzzleHttp\Psr7\Request could not be converted to string

Can you help me? I use guzzle 6.0.1. When I do verifyIPN, I get this error.
Thanks.

[Question] Recurring payments value

Hi.

Using this package I can create recurring payments, right?

My question is, is it possible to change the amount to pay in the future? (notifying the user)

Thank you in advance.

Error from guzzle

Attempting to do ExpressCheckout. I am following the sample array $data
But I get this error from guzzle (v 6) "error" ["message"]=> string(47) "No method can handle the form_params config key"

I have not connected to my cart yet. Using Laravel 5.1

paypal.php Configuration

Hello!

I tried to execute the sample process in the readme but this is what I got:

array:9 [▼ "TIMESTAMP" => "2016-11-10T07:09:09Z" "CORRELATIONID" => "a4fc0e9a1e21" "ACK" => "Failure" "VERSION" => "123" "BUILD" => "26899334" "L_ERRORCODE0" => "10002" "L_SHORTMESSAGE0" => "Security error" "L_LONGMESSAGE0" => "Security header is not valid" "L_SEVERITYCODE0" => "Error" ]

I have followed the guide from https://developer.paypal.com/docs/classic/api/apiCredentials/ have the
API USERNAME (from Manage API Certificate page classic)
API PASSWORD (from Manage API Certificate page classic)
API SECRET (from sandbox, i created an app and it gave me secret key)
API CREDENTIAL (from Manage Api Certificate page classic, put in storage_path('app/cert_key_pem.txt')

Is there anything I'm missing here?

Thanks!

refundTransaction

refundTransaction() in PayPalRequestTrait.php is private, so it's not possible to call it from the ExpressCheckout class.

Recuring Profile not created its given an error.

here is my code

express_checkout_provider = new ExpressCheckout; // To use express checkout. $this->adaptive_payment_provider = new AdaptivePayments; // To use adaptive payments. } /_* _function for create customer *_/ public function createCardCustomer($customer_details, $form_data){ try{ /_Create customer_/ $customer = \Stripe\Customer::create([ 'card' => $form_data['stripeToken'], 'email' => $customer_details['email'], 'metadata' => [ "First Name" => $customer_details['first_name'], "Last Name" => $customer_details['last_name'], ], ]); ``` if(!empty($customer->id)){ return $customer; }else{ return false; } ``` }catch (Exception $e) { Session::flash('exception-message', $e->getMessage() ); return redirect()->back(); } } /** - Get the customer id and - Return customer details from stripe - @return Response _/ public function getCardCustomeDetails($customer_id) { if(!empty($customer_id)){ try{ $customer = \Stripe\Customer::retrieve($customer_id); if(!empty($customer->id)){ return $customer; }else{ return false; } }catch (Exception $e) { Session::flash('exception-message', $e->getMessage() ); return redirect()->back(); } }else{ return false; } } /_get one time payment for card type user_/ public function oneTimePlanChargeCardUser($card_customer_response, $plan_details){ /_get proration amount_/ $prorate_amount = $this->calculateAmount($plan_details); if($prorate_amount != false){ // $plan_details->plan_amount; try{ //take one time charge from user $charge = \Stripe\Charge::create(array( "amount" => $prorate_amount_100, "currency" => env('CURRENCY'), "customer" => $card_customer_response->id, "metadata" => array("Plan Name" => $plan_details->plan_name, "Amount" => $plan_details->plan_amount) // send additinal detilas for paymnet )); ``` if(!empty($charge->id)){ return $charge; }else{ return false; } }catch (Exception $e) { Session::flash('exception-message', $e->getMessage() ); return redirect()->back(); } ``` }else{ Session::flash('exception-message', 'Payment failed' ); return redirect()->back(); } } public function calculateDaysLeft(){ /_calculate number of days left_/ $currnt_day = date("d",time()); $current_month = date("m",time()); $current_year = date("y",time()); $total_days = cal_days_in_month(CAL_GREGORIAN,$current_month,$current_year); $total_days_left = $total_days - $currnt_day; return $total_days_left; } public function calculateAmount($plan_details){ /_Get the number of days left in current month_/ $total_days_left = $this->calculateDaysLeft(); //echo 'currnt_day '.$currnt_day.'current_month '.$current_month.'current_year '.$current_year.'total_days '.$total_days.'total_days_left '.$total_days_left;die; /_calculate one time amout_/ if( $total_days_left != 0 ){ if($plan_details->frequency == 1){ $amount = ( $total_days_left )_( (float)env('ONE_DAY_CHARGE_FOR_MONTHLY_PLAN') ); }else{ $amount = ( $total_days_left )_( (float)env('ONE_DAY_CHARGE_FOR_YEARLY_PLAN') ); } return $amount; }else{ return false; } } /** - Display the home page. * - @return Response */ public function SetExpressCheckout(Request $request) { $form_data = $request->all(); $request->session()->forget('paypal_plan_id'); $request->session()->forget('paypal_plan_type'); Session::put('paypal_plan_id',$form_data['plan_id']); Session::put('paypal_plan_type',$form_data['payment_type']); $request->session()->forget('TOKEN'); $data = $this->setDataPaypal(); $response = $this->express_checkout_provider->setExpressCheckout($data, true); Session::put('decs',$data['invoice_description']); // Use the following line when creating recurring payment profiles (subscriptions) if($response['ACK'] == 'Success'){ ``` Session::put('token',$response['TOKEN']); // This will redirect user to PayPal return redirect($response['paypal_link']); ``` }else{ return false; } } /_Get express checkout for single payment_/ public function GetExpressCheckoutDetails(){ $token = Session::get('token'); $response = $this->express_checkout_provider->getExpressCheckoutDetails($token); $data = $this->setDataPaypal(); $get_express_checkout_details_response = $this->doExpressCheckoutPayment($data, $response, $response['TOKEN'], $response['PAYERID']); if($get_express_checkout_details_response['ACK'] == 'Success'){ ``` $payment_plan_id = Session::get('paypal_plan_id'); $payment_plan_type = Session::get('paypal_plan_type'); /*get the user plan details*/ $plan_obj = new Plans; $plan_details = $plan_obj->getPlanDetails($payment_plan_id); /*update transaction table and membership table*/ $plan_controller_obj = new \App\Http\Controllers\PlanController; $plan_controller_obj->addNewMembership($response, $plan_details, $payment_plan_type); $plan_controller_obj->addTransactionDetails($get_express_checkout_details_response, $payment_plan_type, $response); ``` $plan_controller_obj->markUserAsPaidUser($response, $plan_details, $payment_plan_type); /_add new taransaction detial for user_/ Session::put('message','You have successfully subscribe to'.$plan_details->name); return redirect('dashboard'); } } /_This function use for transcation from paypal_/ public function doExpressCheckoutPayment($data, $response_exp, $token, $PayerID){ $response = $this->express_checkout_provider->doExpressCheckoutPayment($data, $token, $PayerID); $createBill = $this->express_checkout_provider->createBillingAgreement($response['TOKEN']); // The $token is the value returned from SetExpressCheckout API call $data=$this->setDataPaypal(); $profile_desc=Session::get('decs'); $profile_desc = !empty($data['subscription_desc']) ? $data['subscription_desc'] : $data['invoice_description']; /_$profile_desc = !empty($data['subscription_desc']) ? $data['subscription_desc'] : $data['invoice_description'];_/ $startdate= Carbon::now()->toAtomString();//date("Y-m-d",time()); $data = [ 'PROFILESTARTDATE' => $startdate, 'DESC' => $profile_desc, 'BILLINGPERIOD' => 'Month', // Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year' 'BILLINGFREQUENCY' => 12, // set 12 for monthly, 52 for yearly 'AMT' => 9, // Billing amount for each billing cycle 'CURRENCYCODE' => 'USD' // Currency code //'TRIALBILLINGPERIOD' => 'Day', // (Optional) Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year' //'TRIALBILLINGFREQUENCY' => 10, // (Optional) set 12 for monthly, 52 for yearly //'TRIALTOTALBILLINGCYCLES' => 5, // (Optional) Change it accordingly //'TRIALAMT' => 9, // (Optional) Change it accordingly ]; $recurring = $this->express_checkout_provider->createRecurringPaymentsProfile($data, $token); print_r($recurring);die; return $recurring; } /_set paypal setExpress checkout detail_/ public function setDataPaypal(){ $token = Session::get('token'); $payment_plan_id = Session::get('paypal_plan_id'); /_get the user plan details_/ $plan_obj = new Plans; $plan_details = $plan_obj->getPlanDetails($payment_plan_id); $data = []; if(!empty($plan_details->plan_name)){ $data['items'] = [ [ 'name' => $plan_details->plan_name, 'price' => $plan_details->plan_amount ] ]; $data['subscription_desc'] = "test123"; //$data['DESC'] = urlencode('test form'); $data['invoice_id'] = 'abc1xyz12'; //rand(); $data['invoice_description'] = "Order$data[invoice_id]Invoice"; ``` $data['return_url'] = url('/paypal-sucess'); $data['cancel_url'] = url('/cart'); $total = 0; foreach($data['items'] as $item) { $total += $item['price']; } $data['total'] = $total; return $data; ``` }else{ return false; } } ////// /\* public function setRecurrinProfilePaypal(){ // The $token is the value returned from SetExpressCheckout API call $token = Session::get('token'); $data = $this->setDataPaypal(); ``` $profile_desc = !empty($data['subscription_desc']) ? $data['subscription_desc'] : $data['invoice_description']; $startdate=date("Y-m-d",time()); // $data['subscription_desc']; $data['invoice_description']; $data = [ 'PROFILESTARTDATE' => $startdate, 'DESC' => $profile_desc, 'BILLINGPERIOD' => 'Month', // Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year' 'BILLINGFREQUENCY' => 12, // set 12 for monthly, 52 for yearly 'AMT' => 10, // Billing amount for each billing cycle 'CURRENCYCODE' => 'USD', // Currency code 'TRIALBILLINGPERIOD' => 'Day', // (Optional) Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year' 'TRIALBILLINGFREQUENCY' => 10, // (Optional) set 12 for monthly, 52 for yearly 'TRIALTOTALBILLINGCYCLES' => 1, // (Optional) Change it accordingly 'TRIALAMT' => 0, // (Optional) Change it accordingly ]; $response = $this->express_checkout_provider->createRecurringPaymentsProfile($data, $token); print_r($response); die(); }*/ ``` } ------------- response is---------------------- Array ( [TIMESTAMP] => 2016-08-17T07:31:11Z [CORRELATIONID] => 947e6c20944d5 [ACK] => Failure [VERSION] => 123 [BUILD] => 000000 [L_ERRORCODE0] => 11581 [L_SHORTMESSAGE0] => Invalid Data [L_LONGMESSAGE0] => Profile description is invalid [L_SEVERITYCODE0] => Error )

declaration

how can i get my sandbox username , password,secret ,appid, certicate
for express checkout for config file

return [
    'mode' => 'sandbox', // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
    'sandbox' => [
        'username' => 'solyooo398523_api1.gmail.com',
        'password' => 'LPEP4ZJNMW3UY746',
        'secret' => '',
        'certificate' => '',
        'app_id' => '',    // Used for testing Adaptive Payments API in sandbox mode
    ],
    'live' => [
        'username' => '',
        'password' => '',
        'secret' => '',
        'certificate' => '',
        'app_id' => '',         // Used for Adaptive Payments API 
    ],

'payment_action' => 'Sale', // Can Only Be 'Sale', 'Authorization', 'Order'
'currency' => 'USD',
'notify_url' => 'http://localhost:8000/home', // Change this accordingly for your application.

];

some declaration

I am so sorry. I am brand new to laravel and PayPal and I can't find any place inside your code to put my Client ID & Secret so still confused. if you made a video to explain how to use this package i will be
so happy

missed LOCALCODE

there is a reason why LOCALECODE is missed in setExpressCheckout call ?
(to force gateway language)

Some issues with ipn listner sandboxed

So i have a local setup, with ngrok (ngrok exposes your local site to the internet). I have also updated the ipn url in paypal's website.

The issue is that i dont get any notification back from paypal after the payment is complete. But when i try using the ipn simulator it responds back with proper post request. Now when the post request is passed through the "verifyIPN" method, it just gives an empty array shown below.

Array
(
    [INVALID] => 
)

So i have 2 questions,

  1. does ipn work with Sandbox?
  2. why does the verifyIpn takes in a proper POST request from the simulator and destroys it? Is it a bug?

Thanks again for this great library, i am really loving it :)

Curl issue

i'm constantly getting the following from my local

error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

Missing 'qty' data parameter in docs

* The doc was also missing a few new changes and some clarifications, so i sent a pull request*

  1. A new 'qty' attribute has been added, so the new format should be
 $data['items'] = [
            [
                'name' => 'Product 1',
                'price' => 9.99,
                'qty' => 1
            ],
            [
                'name' => 'Product 2',
                'price' => 4.99,
                'qty' => 1
            ]
        ];
  1. Also in the docs it should be clear that secret refereces the signature.

RecurringPayments

Hi,

I want to implement recurring payments with a trial period. Do you have an example of a complete flow for this?

currently when the user approves I do the following steps. but this doesn't create anything according to my test buyer account.

$response = PayPal::getProvider()->createBillingAgreement($request->token);

        $data = [
            'PROFILESTARTDATE' => \Carbon\Carbon::now()->addDays(14),
            'DESC' => 'Plan',
            'BILLINGPERIOD' => 'Month', // Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year'
            'BILLINGFREQUENCY' => 12, // set 12 for monthly, 52 for yearly
            'AMT' => 15, // Billing amount for each billing cycle
            'CURRENCYCODE' => 'USD', // Currency code 
            'TRIALBILLINGPERIOD' => 'Day',  // (Optional) Can be 'Day', 'Week', 'SemiMonth', 'Month', 'Year'
            'TRIALBILLINGFREQUENCY' => 14, // (Optional) set 12 for monthly, 52 for yearly 
            'TRIALTOTALBILLINGCYCLES' => 1, // (Optional) Change it accordingly
            'TRIALAMT' => 0, // (Optional) Change it accordingly
        ];
        $response = PayPal::getProvider()->createRecurringPaymentsProfile($data, $request->token);
        //$response = PayPal::getProvider()->doExpressCheckoutPayment($data, $request->token, $request->PayerID);
        dd($response);

thanks!

Config file not updated?

Hi!
When I try to get the data to the config file, I can only get these credentials from PayPal (sandbox and live):
Sandbox account (email)
Client ID
Secret

But the config wants these credentials:
username, password, secret, certificate,app_id
Any ideas?

Adaptive Payments Error

Hello,

even after fixing some SSL issues #20 I am still getting 'Authentication failed.' message.

'response' => array('responseEnvelope' => array('timestamp' => '2016-07-12T00:57:21.056-07:00', 'ack' => 'Failure', 'correlationId' => 'ff9b97cb3df5d', 'build' => '23046607'), 'error' => array(array('errorId' => '520003', 'domain' => 'PLATFORM', 'subdomain' => 'Application', 'severity' => 'Error', 'category' => 'Application', 'message' => 'Authentication failed. API credentials are incorrect.')

I am not sure why I am getting this error, I found older issue #15 but that did not helped me...

Any ideas where should be problem? I checked credentials and everything should be correct.

I will try to debug it even more...

some declaration

config.php require some things isn't familiar with me like
'username' => '',
'password' => '',
'secret' => '',
'certificate' => '',
but my paypal app gave me Client id and secret

still confused

Credentials

Hi srmklive, first of all, thanks for the great package, Im sorry to bother you but Im having real problems with the config/paypal file

For sandbox should we go to developer-> App api or paypal-> profile Certificates?
if its certificate, where can I get the secret? ( I just see the username,pass, and certificate)...
if its app I just see username(Sandbox account), secret and client_id (I don't know witch one is this), but no password or certificate...

Same goes for live (if its credentials, are they the same as live)?

Please help us, Im sure Im not the only one, appreciate the help
regards
Michael

Question about ipn implimentation

I followed the guide exactly and finally got everything working. But i have some confusions on the ipn implementation. Right now i am just testing the library, so i dont have any tables for orders, carts or any other table neither do i have any data in my sessions.

So i am following this order:
setExpressCheckout
getExpressCheckoutDetails
doExpressCheckoutPayment
createRecurringPaymentsProfile

Then on the notify url i am getting a verified status.
My question is how does the ipn check whether the payment is exactly what was supposed to go through?

Calling addOptions make provider `null`

Hi,

I cloned demo app from another srmklive/laravel-paypal-demo. Following the steps, everything worked fine and I can see orders being placed perfectly, DB being updated as well. I was even able to manage the running state with my own Paypal sandbox details.

However, when I tried to add options using following:

$options = [ 'BRANDNAME' => 'MyApp', 'LOGOIMG' => 'https://upload.wikimedia.org/wikipedia/commons/c/c3/Eye.png', 'CHANNELTYPE' => 'Merchant' ];

Then I changed
$response = express_checkout()->setExpressCheckout($cart); to
$response = express_checkout()->addOptions($options)->setExpressCheckout($cart);

But it started throwing error that setExpressCheckout is being called on a null object. I tried changing helper function to Facade method, but no luck. I even tried breaking it in 2 parts:

$provider = Paypal:: setProvider('express_checkout'); $provider->addOptions($options); $provider->setExpressCheckout($cart);

But it gives same error. However I remove call to addOptions method, it works fine. I tried to debug $provider after addOption and getting null instead of an object. Earlier, when I wasn't using this demo and was trying my own following the documentation, I didn't face this problem (though with that IPN was failing).

how can i get the transactionID in AdaptivePayment??

Login PayPal account, and u will see the transationID of a payment.
Ex: Payment Received (Unique Transaction ID #0SP037792C904160H)
How can i get this ID,??
And in function setPaymentOptions, I want to add a Description of ReceiverOptions fields, u can help me add this parameter in your package.

ErrorException file_get_contents(): Filename cannot be empty. PayPalRequest:95

Hello,
Am using this package for paypal IPN and its giving the following error
"ErrorException file_get_contents(): Filename cannot be empty. PayPalRequest:95"
Line 95 is this
$this->config['signature'] = file_get_contents($this->config['certificate']);

For IPN we don't need any credential or certificate file to respond with, so i have not provided any in the paypal config file, thus this error must be coming.

So there should also be a check for IPN, as did in line 264, and don't check and include credentials or certificate file when making request for IPN verification
if ($method == 'verifyipn') {

Issue with subscription: Invalid Token

I have this createSubscrption method, which first uses setExpresscheckout to get the token (as defined in the docs). Then it passes this token to createRecurringProfile to create a profile.


public function createSubscription(){
        $data['items'] = [   [
                'name' => 'ISO 27000 Foundation',
                'price' => 0.99,
                'qty' => 1
            ] ];
        $response = $this->setExpressCheckout($data);

        if( isset($response['TOKEN']) ){
            $data['subscription_desc'] = 'My new Subscription';
            $result = $this->CreateRecurringProfile($response['TOKEN'], $data);
            dd($result);
        }
    }

The first method i.e setExpressCheckout works fine and generates a token, but the next method gives an error

/********** Result from setExpressCheckout **************/
array:7 [▼
  "TOKEN" => "EC-8X3617038X889902Y"
  "TIMESTAMP" => "2016-08-16T14:58:26Z"
  "CORRELATIONID" => "84662783446a6"
  "ACK" => "Success"
  "VERSION" => "123"
  "BUILD" => "24362847"
  "paypal_link" => "https://www.sandbox.paypal.com/webscr?cmd=_express-checkout&token=EC-8X3617038X889902Y"
]

/********** Result from CreateRecurringProfile**************/
array:9 [▼
  "TIMESTAMP" => "2016-08-16T14:53:57Z"
  "CORRELATIONID" => "e54dd07c255f6"
  "ACK" => "Failure"
  "VERSION" => "123"
  "BUILD" => "000000"
  "L_ERRORCODE0" => "11502"
  "L_SHORTMESSAGE0" => "Invalid Token"
  "L_LONGMESSAGE0" => "The token is invalid"
  "L_SEVERITYCODE0" => "Error"
]

Is this the correct way to creating a profile?

Laravel 5.2

Are you looking to support 5.2 soon?

I noticed there was an issue when doing a vendor:publish

I updated the reference to the files in PayPalServiceProvider.php from

/../config/config.php to /../../config/config.php

After that I received an error

PHP Catchable fatal error: Argument 2 passed to Illuminate\Routing\UrlGenerator::__construct() must be an instance of Illuminate\Http\Request, null given

I commented out notify_url in the paypal.php file and then got this error

PHP Fatal error: Class 'Srmklive\PayPal\PayPalServiceProvider' not found

Illegal string offset 'name'

Ok, I dont know what I can be doing incorrectly here but I keep getting this error:

ErrorException in ExpressCheckout.php line 118:
Illegal string offset 'name'

When performing the doExpressCheckoutPayment($data,$token,$payerID);
Here is some sample code from my controller:

$response = \PayPal::getProvider()->getExpressCheckoutDetails($request->token);
$package = Package::whereName(array_get($response,'L_NAME0'))->first();
if($package)
{
  $data['items'] = [
    'name' => $package->name,
    'price' => $package->price,
    'qty' => 1
  ];
  $data['invoice_id'] = array_get($response,'INVNUM');
  $data['invoice_description'] = array_get($response,'PAYMENTREQUEST_0_DESC');
  $data['return_url'] = url('/return');
  $data['notify_url'] = url('/notify');
  $data['cancel_url'] = url('/cancel');

  $data['total'] = array_get($response,'L_PAYMENTREQUEST_0_AMT0');
  $provider = new ExpressCheckout;
  $doPayment = $provider->doExpressCheckoutPayment($data, $request->token, $request->PayerID);

ExpressCheckout.php:

    public function doExpressCheckoutPayment($data, $token, $payerid)
    {
        $num = 0;
        $post = [];

        foreach ($data['items'] as $item) {
            $tmp = [
                'L_PAYMENTREQUEST_0_NAME'.$num  => $item['name'], // This is my line 118
                'L_PAYMENTREQUEST_0_AMT'.$num   => $item['price'],
                'L_PAYMENTREQUEST_0_QTY'.$num   => $item['qty'],
            ];

            foreach ($tmp as $k => $v) {
                $post[$k] = $v;
            }

            $num++;
        }

        $tmp = [
            'TOKEN'                             => $token,
            'PAYERID'                           => $payerid,
            'PAYMENTREQUEST_0_ITEMAMT'          => $data['total'],
            'PAYMENTREQUEST_0_AMT'              => $data['total'],
            'PAYMENTREQUEST_0_PAYMENTACTION'    => !empty($this->config['payment_action']) ? $this->config['payment_action'] : 'Sale',
            'PAYMENTREQUEST_0_CURRENCYCODE'     => $this->currency,
            'PAYMENTREQUEST_0_DESC'             => $data['invoice_description'],
            'PAYMENTREQUEST_0_INVNUM'           => $data['invoice_id'],
            'PAYMENTREQUEST_0_NOTIFYURL'        => config('paypal.notify_url'),
        ];

        foreach ($tmp as $k => $v) {
            $post[$k] = $v;
        }

        $response = $this->doPayPalRequest('DoExpressCheckoutPayment', $post);

        return $response;
    }

Any help on this would be greatly appreciated. I know its probably something completely simple as well.

unexpected 'class' in PayPalRequest.php

Hello,

I'm getting this

FatalThrowableError in PayPalRequest.php line 87:
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting variable (T_VARIABLE) or '$'
in PayPalRequest.php line 87
at Composer\Autoload\includeFile('/Users/mauro/Sites/paypal/vendor/composer/../srmklive/paypal/src/Traits/PayPalRequest.php') in ClassLoader.php line 301
at ClassLoader->loadClass('Srmklive\PayPal\Traits\PayPalRequest')
at spl_autoload_call('Srmklive\PayPal\Traits\PayPalRequest') in AdaptivePayments.php line 7
at include('/Users/mauro/Sites/paypal/vendor/srmklive/paypal/src/Services/AdaptivePayments.php') in ClassLoader.php line 412
at Composer\Autoload\includeFile('/Users/mauro/Sites/paypal/vendor/composer/../srmklive/paypal/src/Services/AdaptivePayments.php') in ClassLoader.php line 301

Fresh install. Just required package, configured provider, alias, published config and put credentials on .env file variables + certificate in storage_path.

this code is throwing the error:

if ($this instanceof \Srmklive\PayPal\Services\AdaptivePayments::class) {
            $this->setAdaptivePaymentsOptions($mode);
        } else {
            $this->setExpressCheckoutOptions($credentials, $mode);
        }

I'm on Laravel 5.2. Tried to search on previous issues but had no clue. Did someone face this problem too? Thanks

How to receive $data in paymentSuccess function

Hello.
Tell me please!)
I created function:
public static function sendPayPallOrder($order){

$provider = express_checkout();

$data['items'] = [
    [
        'name' => 'Payment order',
        'price' => 100,
        'qty' => 1
    ],
];
$data['total'] = 100;

$data['invoice_id'] = $order->id;
$data['invoice_description'] = "Order #$data[invoice_id] Invoice";
$data['return_url'] = url('/payment/success');
$data['cancel_url'] = url('/cart');

$response = $provider->setExpressCheckout($data);

return $response['paypal_link'];

}
Also i created route:

Route::get('/payment/success', [ 'as' => 'order.payment-success', 'uses'=>'SiteController@paymentSuccess' ] );

And i created function:
public static function paymentSuccess(Request $request)
{
$data=[]; //???????????????
$input = $request->all();
$provider = express_checkout();
$response = $provider->doExpressCheckoutPayment($data, $input['token'], $input['PayerID']);
//dd($response);
}

How i can to receive $data in paymentSuccess function?

Question rather than issue

Hello,

Awesome package, but i'm just wondering how to use IPN, or if it's complete.
When I log

$response = $this->verifyIPN($post);
Log::error($response);

The output is

array(
'INVALID' => '',
);

maybe if the response is valid, instead of throwing an empty exception it could be more informative as -

array(
'VALID' => true/false,
'ERROR_MSG' => '',
);

Adaptive Payments return 404

I got this response from PayPal
Client error: POST https://api-3t.sandbox.paypal.com/nvp/Pay resulted in a404 Not Found response:

My Controller:

public function adaptive()
    {
      $provider = new AdaptivePayments;

      $data = [
          'receivers'  => [
              [
                  'email' => '[email protected]',
                  'amount' => 9,
                  'primary' => true,
              ],
              [
                  'email' => '[email protected]',
                  'amount' => 1,
                  'primary' => false
              ]
          ],
          'payer' => 'EACHRECEIVER',
          'return_url' => url('payment/success'),
          'cancel_url' => url('payment/cancel'),
      ];

      $response = $provider->createPayRequest($data);
      //dd($response);
      $redirect_url = $provider->getRedirectUrl('approved', $response['payKey']);

      return redirect($redirect_url);

    }```

$redirect_url says payKey does not exist, but the cause is that $response throws a 404, it seems that https://api-3t.sandbox.paypal.com/nvp/Pay is unreachable

bad error handling

in PayPalRequest.php
doPayPalRequest()

if (!empty($response['TOKEN'])) {....
else{
// no connection
}

but it's also thrown "no connection" if other error happen. As in my case when total of items is different from the order total. I suppose it's for the translation.
I think better way of this will be to return the error returned by paypal. To know what really happened.

Not able to process payment on Live mode via credit / debit card.

Currently I am using this library and I am able to make payment on sandbox environment.
On live user is trying to make payment via credit or debit card user is redirected to PayPal website, but payment is not completed.

Is this library supports for credit and debit card payment.?

I am getting below value in paypal_link:

"paypal_link" => "https://www.paypal.com/webscr?cmd=_express-checkout&token=EC-4RY600814B770294Y"

Also I checked with the paypal technical assistance they are saying "The API request stopped at SetExpressCheckOut" and from there it is not proceeding.

Kindly let me know is this correct for live or am I missing something.

setExpressCheckout and doExpressCheckOutPayment Fix

I dont know if anyone havent notice it...
but
When We Subscriptions our Logic at setExpressCheckout is already Wrong...
We Dont Submit Items if we Have Subscriptions...
Also I Added Additional Info to Customize Checkout Page of Paypal
So What i did was check if data['items'] is set if yes go with normal workflow
if not dont do foreach loop of items...

I Also Added Here A Way to Customize Checkout Page in Paypal
Like Border and Logo and Branding Name...

public function setExpressCheckout($data, $subscription = false)
    {
        $num = 0;
        $post = [];

        if( isset( $data['items'] ) ) {
            foreach ($data['items'] as $item) {



            $tmp = [
                'L_PAYMENTREQUEST_0_NAME'.$num  => $item['name'],
                'L_PAYMENTREQUEST_0_AMT'.$num   => $item['price'],
                'L_PAYMENTREQUEST_0_QTY'.$num   => $item['qty'],
            ];

            foreach ($tmp as $k => $v) {
                $post[$k] = $v;
            }

            $num++;
        }

           $tmp['PAYMENTREQUEST_0_ITEMAMT'] = $data['total'];
        }


        $tmp = [
            'PAYMENTREQUEST_0_AMT'              => $data['total'],
            'PAYMENTREQUEST_0_PAYMENTACTION'    => !empty($this->config['payment_action']) ? $this->config['payment_action'] : 'Sale',
            'PAYMENTREQUEST_0_CURRENCYCODE'     => $this->currency,
            'PAYMENTREQUEST_0_DESC'             => $data['invoice_description'],
            'PAYMENTREQUEST_0_INVNUM'           => $data['invoice_id'],
            'NOSHIPPING'                        => 1,
            'RETURNURL'                         => $data['return_url'],
            'CANCELURL'                         => $data['cancel_url'],
        ];
        // Styling
        $post['BRANDNAME']=!empty($this->config['brandname']) ? $this->config['brandname'] :'MyBrand';
        $post['LOGOIMG']=!empty($this->config['logo']) ? $this->config['logo'] : 'https://profugo.org/wp-content/uploads/2013/08/logo-190x60.png';
        $post['CARTBORDERCOLOR'] = !empty($this->config['bordercolor']) ? $this->config['bordercolor'] : '009688';
        $post['CHANNELTYPE']='Merchant';
        if ($subscription) {
            $post['L_BILLINGTYPE0'] = 'RecurringPayments';
            $post['L_BILLINGAGREEMENTDESCRIPTION0'] = !empty($data['subscription_desc']) ?
                $data['subscription_desc'] : $data['invoice_description'];
        }

        if (!empty($this->config['locale'])) {
            $post['LOCALECODE'] = $this->config['locale'];
        }

        foreach ($tmp as $k => $v) {
            $post[$k] = $v;
        }

        $response = $this->doPayPalRequest('SetExpressCheckout', $post);

        if (!empty($response['TOKEN'])) {
            $response['paypal_link'] = $this->config['gateway_url'].
                '/webscr?cmd=_express-checkout&token='.$response['TOKEN'];
        }

        return $response;
    }

Same with this method doExpressCheckoutPayment

public function doExpressCheckoutPayment($data, $token, $payerid)
    {
        $num = 0;
        $post = [];
        if( isset( $data['items'] ) ) {
            foreach ($data['items'] as $item) {
                $tmp = [
                    'L_PAYMENTREQUEST_0_NAME'.$num  => $item['name'],
                    'L_PAYMENTREQUEST_0_AMT'.$num   => $item['price'],
                    'L_PAYMENTREQUEST_0_QTY'.$num   => $item['qty'],
                ];

                foreach ($tmp as $k => $v) {
                    $post[$k] = $v;
                }

                $num++;
            }
            $tmp['PAYMENTREQUEST_0_ITEMAMT'] = $data['total'];
        }

        $tmp = [
            'TOKEN'                             => $token,
            'PAYERID'                           => $payerid,
            'PAYMENTREQUEST_0_AMT'              => $data['total'],
            'PAYMENTREQUEST_0_PAYMENTACTION'    => !empty($this->config['payment_action']) ? $this->config['payment_action'] : 'Sale',
            'PAYMENTREQUEST_0_CURRENCYCODE'     => $this->currency,
            'PAYMENTREQUEST_0_DESC'             => $data['invoice_description'],
            'PAYMENTREQUEST_0_INVNUM'           => $data['invoice_id'],
            'PAYMENTREQUEST_0_NOTIFYURL'        => config('paypal.notify_url'),
        ];

        foreach ($tmp as $k => $v) {
            $post[$k] = $v;
        }

        $response = $this->doPayPalRequest('DoExpressCheckoutPayment', $post);

        return $response;
    }

Curl + SSL version

I got this error:

Use of undefined constant CURL_SSLVERSION_TLSv1_2 - assumed 'CURL_SSLVERSION_TLSv1_2'

So I made a search from closed issues and found out I need to update my OpenSSL version to 1.x. So did I:
root@vps# openssl version OpenSSL 1.0.2j 26 Sep 2016

Restarted the VPS, got the same error. So I thought I should also update my Curl:
`>>> curl_version();
=> [
"version_number" => 471808,
"age" => 3,
"features" => 1016733,
"ssl_version_number" => 0,
"version" => "7.51.0",
"host" => "x86_64-redhat-linux-gnu",
"ssl_version" => "OpenSSL/1.0.1e",
"libz_version" => "1.2.3",
"protocols" => [
"dict",
"file",
"ftp",
"ftps",
"gopher",
"http",
"https",
"imap",
"imaps",
"ldap",
"ldaps",
"pop3",
"pop3s",
"rtsp",
"scp",
"sftp",
"smb",
"smbs",
"smtp",
"smtps",
"telnet",
"tftp",
],
]

`

But im still having the same exact error.

sample code

I wanna see sample code in simple laravel app

Issue with OpenSSL OR CURL

I am getting this error

Use of undefined constant CURL_SSLVERSION_TLSv1_2 - assumed 'CURL_SSLVERSION_TLSv1_2

But i already have OpenSSL 1.0.1 installed which supports TLS 1.2, do you think this might be some other issue?

SSL Certificate

Hi buddy, i am looking for a solution to my app without a SSL certificate.
Can i only use this Express Checkout if i have an SSL certificate?
Thanks!

Can i Possible Use this For Multiple User?

as i can see the paypal config is hard coded...
im planning to add a database for config...
with sandbox - boolean , username, password, secret, certificate , app_id and user_id
How can i Use Eloquent instead of the config file?
Is that possible thanks for the answer

paypal-developer site reference needed in readme

just a dumb question, I'm new to paypal (used cashier/stripe before)

on https://developer.paypal.com/developer/applications/ i see three kind of app-interaction

v.zero SDK, REST API apps, NVP/SOAP API apps.

this package is intended to works with REST API?
I've generated a new rest api app and all I can see are this kind of credentials:

  • Sandbox account (email)
  • Client ID (hash)
  • Secret (another hash)

this doesn't match the configuration of package
PAYPAL_LIVE_API_USERNAME
PAYPAL_LIVE_API_PASSWORD
PAYPAL_LIVE_API_SECRET
PAYPAL_LIVE_API_CERTIFICATE

So, can I have some reference link to paypal developer website?
thanks a lot for the package

undefined index paypal_link

I am trying to user express checkout. I am getting following error.

'response' => array('TIMESTAMP' => '2016-12-10T16:09:32Z', 'CORRELATIONID' => 'b1867d622585f', 'ACK' => 'Failure', 'VERSION' => '123', 'BUILD' => '000000', 'L_ERRORCODE0' => '10002', 'L_SHORTMESSAGE0' => 'Security error', 'L_LONGMESSAGE0' => 'Security header is not valid', 'L_SEVERITYCODE0' => 'Error')))

I think this is because I have not provided the certificate path in config/papal.php is it correct?
If yes then how I can create sandbox account certificate?

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.