PHP SDK for PayPal RESTful APIs

Overview

Deprecation Notice:

This SDK is deprecated. You can continue to use it, but no new features or support requests will be accepted. For alternatives, please visit the current SDK homepage on the PayPal Developer Portal

REST API SDK for PHP

Home Image

Build Status Coverage Status

Welcome to PayPal PHP SDK. This repository contains PayPal's PHP SDK and samples for REST API.

Direct Credit Card Support

Important: The PayPal REST API no longer supports new direct credit card integrations. Please instead consider Braintree Direct; which is, PayPal's preferred integration solution for accepting direct credit card payments in your mobile app or website. Braintree, a PayPal service, is the easiest way to accept credit cards, PayPal, and many other payment methods.

Please Note

The Payment Card Industry (PCI) Council has mandated that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. Click here for more information

Connections to the sandbox environment use only TLS 1.2.

SDK Documentation

Our PayPal-PHP-SDK Page includes all the documentation related to PHP SDK. Everything from SDK Wiki, to Sample Codes, to Releases. Here are few quick links to get you there faster.

Latest Updates

  • SDK now allows injecting your logger implementation. Please read documentation for more details.
  • If you are running into SSL Connect Error talking to sandbox or live, please update your SDK to latest version or, follow instructions as shown here
  • Checkout the latest 1.0.0 release. Here are all the breaking Changes in v1.0.0 if you are migrating from older versions.
  • Now we have a Github Page, that helps you find all helpful resources building applications using PayPal-PHP-SDK.

PayPal Checkout v2

Please note that if you are integrating with PayPal Checkout, this SDK and corresponding API v1/payments are in the process of being deprecated.

We recommend that you integrate with API v2/checkout/orders and v2/payments. Please refer to the Checkout PHP SDK to continue with the integration.

2.0 Release Candidate!

We're releasing a brand new version of our SDK! 2.0 is currently at release candidate status, and represents a full refactor, with the goal of making all of our APIs extremely easy to use. 2.0 includes all of the existing APIs (except payouts), and includes the new Orders API (Disputes and Marketplace coming soon). Check out the FAQ and migration guide, and let us know if you have any suggestions or issues!

Prerequisites

License

Read License for more licensing information.

Contributing

Read here for more information.

More help

Comments
  • Charge an initial payment with a billing agreement, don't create if user can't be charged (since plan with setup_fee can be created even for accounts with 0 funds)

    Charge an initial payment with a billing agreement, don't create if user can't be charged (since plan with setup_fee can be created even for accounts with 0 funds)

    In the sandbox, when I create a billing plan & agreement with setup_fee, the plan can be created even with an account that has no funds.

    My experience with the sandbox with setup_fee is that the setup_fee stays at 0, even though I configured it. However I heard it can take several minutes after the creation of the plan & agreement until it actually charges the account. How will we know until then if the user has sufficient funds in their account to pay the initial payment? What happens if the user cancels their plan before the setup_fee has gone through? I want my users to instantly utilize their subscription features after payment. Not require them to wait several minutes before the initial payment has (or hasn't) gone through.

    I know that with the classic API it's suggested to combine the billing plan with a Checkout for Digital Goods item, and have the user authorize a payment for the digital goods item & the billing agreement together. This way the user can only create the billing profile if it was able to pay for the digital goods item. Is this still the best practice? If so, how do we do this using the PHP SDK?

    opened by iadj 83
  • Billing agreements: taking the first payment immediately

    Billing agreements: taking the first payment immediately

    Again, this is for the REST API in general.

    When creating a billing agreement, the start_date parameter is required. It is formatted as an ISO8601 timestamp.

    Generally when people sign up to a subscription, we want to take the first payment immediately. Indeed, my system listens specifically for payment IPNs rather than "subscription started" IPNs.

    So what are we supposed to do here? Do we set the start_date to the exact current time? Do we set it in the past? Do we set it a few minutes in the future, hoping that we can guess how long the user will take to finish the Paypal signup?

    If we set it too far in the future (say, an hour), the user must wait a while before getting access to premium content. If we set it too soon (say, a minute), then the user may take too long filling in the form; when they come back to our website, we will attempt to start the billing agreement in the past. That worries me. How will Paypal respond if I ask them to take a payment in the past?

    Could this parameter be made optional, so that default behaviour is "pay immediately" and delaying the payment is optional?

    opened by MikeHopley 58
  • Missing

    Missing "Payer" object in Agreement

    The "Agreement" object should return the "payer" data (as per documentation) https://developer.paypal.com/webapps/developer/docs/api/#agreement-object

    However this data is not coming back neither for Billing Agreements created with Credit Cards nor for the Billing Agreements created with PayPal (and it should based on the documentation) https://developer.paypal.com/webapps/developer/docs/api/#execute-an-agreement

    This is a really big issue as there's no way of getting user's name/email/address via API when executing Billing Agreement via PayPal (unless these are collected separately, which defeats the purpose of PayPal checkout)

    opened by rovenko 57
  • Exception: Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/payment.

    Exception: Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/payment.

    This is occuring on the rest-api-sdk-php-master/sample/payments/CreatePaymentUsingSavedCard (but it seems to occur every 3 or so, HTTP requests)

    string '{"name":"INTERNAL_SERVICE_ERROR","message":"An internal service error has occurred","information_link":"https://developer.paypal.com/webapps/developer/docs/api/#INTERNAL_SERVICE_ERROR","debug_id":"992bce711a5e0"}' (length=212)
    

    The same issue, is occurring with my live code; which I have producing the same data as the sample (only difference is the CreditCard Token, and ApiContext; different ClientID and ClientSecret).

    Exception: Got Http response code 500 when accessing https://api.sandbox.paypal.com/v1/payments/payment. [debug_id 9d2922a5f4c09] An internal service error has occurred
    

    Log File

    PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/oauth2/token
    PayPal\Core\PPHttpConnection: Payload grant_type=client_credentials
    PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.4.7;bit=32;os=Windows_NT_6.1;machine=i586;openssl=0.9.8x;curl=7.24.0)
    PayPal\Core\PPHttpConnection: Adding header Authorization: Basic QVZNYV9CQ0RJSl9QaXdUQUY1U1JDX3VHUXYzeFh4eTZ5N1lDLXc1TVVrVWJUX2tjNjZQYi1Ld1dwVGpfOkVBR3NGUkFVejNlVGluZ0R5bXoxQW9tcG9KY0lxLVhmR2t1cElHaThiWG9HRHpvNC03SmdDS0w4MXhFQg==
    PayPal\Core\PPHttpConnection: Adding header Accept: */*
    PayPal\Core\PPHttpConnection: Invalid or no certificate authority found - Retrying using bundled CA certs file
    PayPal\Core\PPHttpConnection: Connecting to https://api.sandbox.paypal.com/v1/payments/payment
    PayPal\Core\PPHttpConnection: Payload {"intent":"sale","payer":{"payment_method":"credit_card","funding_instruments":[{"credit_card_token":{"credit_card_id":"CARD-8Y8073040T621494HKQHIONI"}}]},"transactions":[{"amount":{"currency":"USD","total":"17.50","details":{"tax":"2.28","shipping":"0.00","subtotal":"15.22"}},"item_list":{"items":[{"name":"Granola bars","currency":"USD","quantity":5,"price":"1.74"},{"name":"Ground Coffee 40 oz","currency":"USD","quantity":1,"price":"6.52"}]},"description":"Justink - ref #1409091717360 - Client ProDev"}]}
    PayPal\Core\PPHttpConnection: Adding header Content-Type: application/json
    PayPal\Core\PPHttpConnection: Adding header User-Agent: PayPalSDK/rest-sdk-php 0.6.0 (lang=PHP;v=5.4.7;bit=32;os=Windows_NT_6.1;machine=i586;openssl=0.9.8x;curl=7.24.0)
    PayPal\Core\PPHttpConnection: Adding header Authorization: Bearer A015yeAMx.Dy-lDXpBcjV0mD4RB9QwbuK1-qcJlTVtETH.Q
    PayPal\Core\PPHttpConnection: Adding header PayPal-Request-Id: 2130706433404141023985457428
    PayPal\Core\PPHttpConnection: Invalid or no certificate authority found - Retrying using bundled CA certs file
    

    I'm not exactly sure; what I'm to meant to do, to fix this issue, from what I can see my transactions object; is calculating up to the correct total, and subtotal.

    Also; using the same transactions object, I am able to connect to the PayPal Create Payment; Shopping Gateway, but Authorizing a Payment, with a Stored Credit Card seems to return HTTP 500.

    opened by killrawr 53
  • option to hide the shipping address

    option to hide the shipping address

    this seems to be missing, the classic api has a option for this (NOSHIPPING). Or am i missing something? To be clear: I am talking about an option to hide the shipping address during checkout on the paypal website. Anyhow there seems to be no possibility to set any of the options listed here: https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/SetExpressCheckout_API_Operation_NVP/ ?

    opened by Goltergaul 51
  • Webhooks

    Webhooks

    Hi, I implemented a WebHook listner as it is shown here:

    https://paypal.github.io/PayPal-PHP-SDK/sample/doc/notifications/ValidateWebhookEvent.html

    Dont that Listner need to retuern anything so that the PayPal server knows that the message has been delivered?

    When I send a WebHook event in the Simulator its state is shown as pending.

    ~ Marc

    question 
    opened by daslicht 45
  • Webhook verification from simulator always fails

    Webhook verification from simulator always fails

    Required Information

    • PHP Version: PHP 5.5.19
    • PayPal-PHP-SDK Version: 1.10.0
    • Debug ID(s): d6cbd6047e486

    Issue Description

    I am using a webhook for payout batch event notifications. I followed the example webhook validation as described in the docs. I always receive { "verification_status": "FAILURE"} as the response. I am in sandbox mode and firing the notification from the webhook simulator in the developer dashboard.

    Here is an example of my post data for the verification request:

    {
       "auth_algo":"SHA256withRSA",
       "transmission_id":"505fcad0-acfc-11e6-8e5f-13662a490b19",
       "cert_url":"https://api.paypal.com/v1/notifications/certs/CERT-360caa42-fca2a594-df8cd2d5",
       "webhook_id":"2A9741408B151863U",
     "transmission_sig":"ks91bo8HXCMsQBrXKOyOrs46KJkTVZRA7Az2oArXKNNaSxnMHENKIBUv4yOolVplwwFC1+u1pF1fIqRysqFgpgnQ8i8huROBJHiKaN9BeBdm1qnQiXyF7CSmHJ4MDVAQPvB1zHncbnJ5lIbzOhFm9TRLp7CaFk8IXNvCR6FTO5jqwfhpzTmf5k1MRbneexbnjmipQ9P3IDmKpAGLxweN/THixXgmC2GMdIIfVHCXZ8bvhcKPeMJ/0J8DQxlwpOteRbEYY25Kkpaej1ZhzAZ9/JjfxEZnARcax0i/O5ht8GOGPBhOUYKB19u1ZHxjoWEDUrrE1GDJOklNUpmqIPRug==",
       "transmission_time":"2016-11-17T19:30:36Z",
       "webhook_event":{
          "id":"WH-9J627718KS478452F-0TT97515BN811434B",
          "event_version":"1.0",
          "create_time":"2015-09-14T13:18:15Z",
          "resource_type":"payouts",
          "event_type":"PAYMENT.PAYOUTSBATCH.PROCESSING",
          "summary":"Payouts batch is getting processed.",
          "resource":{
             "batch_header":{
                "payout_batch_id":"X24X9BJL2UK52",
                "batch_status":"PROCESSING",
                "time_created":"2015-09-14T13:18:13Z",
                "sender_batch_header":{
                   "sender_batch_id":"ISO-22"
                },
                "amount":{
                   "currency":"USD",
                   "value":"12.43"
                },
                "fees":{
                   "currency":"USD",
                   "value":"0.5"
                },
                "payments":2
             },
             "links":[
                {
                   "href":"https://api.paypal.com/v1/payments/payouts/X24X9BJL2UK52",
                   "rel":"self",
                   "method":"GET"
                }
             ]
          },
          "links":[
             {
                "href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-9J627718KS478452F-0TT97515BN811434B",
                "rel":"self",
                "method":"GET"
             },
             {
                "href":"https://api.paypal.com/v1/notifications/webhooks-events/WH-9J627718KS478452F-0TT97515BN811434B/resend",
                "rel":"resend",
                "method":"POST"
             }
          ]
       }
    }
    

    CURL_HEADER_OUT:

    POST /v1/notifications/verify-webhook-signature HTTP/1.1
    Host: api.sandbox.paypal.com
    Accept: */*
    Content-Type: application/json
    User-Agent: PayPalSDK/PayPal-PHP-SDK 1.10.0
    Authorization: Bearer <my access token>
    PayPal-Request-Id: 288679526856147939137562357
    Content-Length: 1535
    

    The response:

     HTTP/1.1 200 OK
    Date: Thu, 17 Nov 2016 19:30:42 GMT
    Server: Apache
    PROXY_SERVER_INFO: host=slcsbplatformapiserv3002.slc.paypal.com;threadId=541
    Paypal-Debug-Id: d6cbd6047e486
    CORRELATION-ID: d6cbd6047e486
    Content-Language: *
    Paypal-Debug-Id: d6cbd6047e486
    Set-Cookie: X-PP-SILOVER=name%3DSANDBOX3.API.1%26silo_version%3D1880%26app%3Dplatformapiserv%26TIME%3D1644506712%26HTTP_X_PP_AZ_LOCATOR%3D; Expires=Thu, 17 Nov 2016 20:00:42 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
    Set-Cookie: X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
    Vary: Authorization
    Content-Length: 33
    Connection: close
    Content-Type: application/json
    
    {"verification_status":"FAILURE"}
    
    question 
    opened by TJBIII 38
  • No order summary when using Plans

    No order summary when using Plans

    If i want order summery in the regular payment,i do the following:

    $item = new Item();
    $item->setQuantity('1');
    $item->setName('benny');
    $item->setPrice('7.41');
    $item->setCurrency('USD');
    $item->setSku('blah');
    // //var_dump($item);
    
    $items = new ItemList();
    $items->addItem($item);
    
    $transaction->setItemList($items);
    

    How do i do the same with $agreement? Because the order summery stays blank (only description is available) Here is a json object of the $agreement:

    {
      "name": "Base Agreement",
      "description": "Basic Agreement",
      "start_date": "2014-11-03T9:45:04Z",
      "plan": {
        "id": "P-4NV80650SU281405UOB6HAYY",
        "state": "ACTIVE",
        "name": "Mister Survey Basic ",
        "description": "mister survey basic plan monthly payment",
        "type": "FIXED",
        "payment_definitions": [
          {
            "id": "PD-1WU277608S2163356OB6HAYY",
            "name": "Regular Payments",
            "type": "REGULAR",
            "frequency": "Month",
            "amount": {
              "currency": "USD",
              "value": "100"
            },
            "cycles": "12",
            "charge_models": [
              {
                "id": "CHM-29N814267C6503944OB6HAYY",
                "type": "TAX",
                "amount": {
                  "currency": "USD",
                  "value": "0"
                }
              }
            ],
            "frequency_interval": "1"
          }
        ],
        "merchant_preferences": {
          "setup_fee": {
            "currency": "USD",
            "value": "0"
          },
          "max_fail_attempts": "0",
          "return_url": "http:\/\/mistersurveylocal.com:8080\/#\/pricing?success=true",
          "cancel_url": "http:\/\/mistersurveylocal.com:8080\/#\/pricing?success=false",
          "auto_bill_amount": "YES",
          "initial_fail_amount_action": "CONTINUE"
        }
      },
      "payer": {
        "payment_method": "paypal"
      },
      "shipping_address": {
        "line1": "111 First Street",
        "city": "Saratoga",
        "state": "CA",
        "postal_code": "95070",
        "country_code": "US"
      },
      "links": [
        {
          "href": "https:\/\/www.sandbox.paypal.com\/cgi-bin\/webscr?cmd=_express-checkout&token=EC-57U11816KP901294U",
          "rel": "approval_url",
          "method": "REDIRECT"
        },
        {
          "href": "https:\/\/api.sandbox.paypal.com\/v1\/payments\/billing-agreements\/EC-57U11816KP901294U\/agreement-execute",
          "rel": "execute",
          "method": "POST"
        }
      ]
    }
    

    This is what i want in review page for recurring payments: (this is not my website):

    billing

    opened by thedarkman123 38
  • Please help me what can I do next...

    Please help me what can I do next...

    Hello, How are you? I tried to create monthly (yearly) subscription using PayPal-PHP-SDK I used codebase like below:

    {
            $amount = 100;
    
            // Set billing plan definitions
            $paymentDefinition = new PaymentDefinition();
            $paymentDefinition->setName('Regular Payments')
              ->setType('REGULAR')
              ->setFrequency('Month')
              ->setFrequencyInterval('1')
              ->setCycles('0')
              ->setAmount(new Currency(array('value' => $amount, 'currency' => 'USD')));
    
            // Set merchant preferences
            $merchantPreferences = new MerchantPreferences();
            $merchantPreferences->setReturnUrl('http://mysite.com/subscribe/paypal_redirect')
              ->setCancelUrl('http://mysite.com/subscribe/paypal_return')
              ->setAutoBillAmount('yes')
              ->setInitialFailAmountAction('CONTINUE')
              ->setMaxFailAttempts('0');
    
               // Create a new billing plan
            $plan = new Plan();
            $plan->setName($plan_name)
              ->setDescription($plan_description)
              ->setType('infinite');
            $plan->setPaymentDefinitions(array($paymentDefinition));
            $plan->setMerchantPreferences($merchantPreferences);
    
            //create the plan
            try {
                $createdPlan = $plan->create($this->apiContext);
    
                try {
                    $patch = new Patch();
                    $value = new PayPalModel('{"state":"ACTIVE"}');
                    $patch->setOp('replace')
                      ->setPath('/')
                      ->setValue($value);
                    $patchRequest = new PatchRequest();
                    $patchRequest->addPatch($patch);
                    $createdPlan->update($patchRequest, $this->apiContext);
                    $plan = Plan::get($createdPlan->getId(), $this->apiContext);
    
                    // Output plan id
                    **echo 'Plan ID:' . $plan->getId();**
                } catch (PayPal\Exception\PayPalConnectionException $ex) {
                    echo $ex->getCode();
                    echo $ex->getData();
                    die($ex);
                } catch (Exception $ex) {
                    die($ex);
                }
            } catch (PayPal\Exception\PayPalConnectionException $ex) {
                echo $ex->getCode();
                echo $ex->getData();
                die($ex);
            } catch (Exception $ex) {
                die($ex);
            }
    
        }
    

    I successfully got PlanID (please see echo 'Plan ID:' . $plan->getId();) but not sure what can I do next? It doesn't redirect me to PayPal site. Please help me what can I do next, I am on very busy situation. Regards

    opened by topdev423 33
  • DPRP DISABLED

    DPRP DISABLED

    internal tracking PPLMER-26632

    Issue Description

    I am getting error in billing recurring profile in paypal using credit card with sandbox account Billing agreement plan created successfully but for billing agreement i get following response.

    How can i enable DPRP ?

    { "name": "DPRP_DISABLED", "message": "DPRP is disabled for this merchant.", "information_link": "https://developer.paypal.com/webapps/developer/docs/api/#DPRP_DISABLED", "debug_id": "b2696e4c2cc91" }

    opened by dhavalbera9898 28
  • Paypal REST API REQUIRED_SCOPE_MISSING

    Paypal REST API REQUIRED_SCOPE_MISSING

    I am having a big issue with my Dashboard. I have no Apps (was 3), no Sandbox credentials (was 6 accounts) and almost every field on my Dashboard says:

    "Weā€™re sorry, but something went wrong while getting your credentials. Please try again"

    Now, all of a sudden, none of my Login with Paypal or Ordering using the REST API work from my server.

    The issue started when I was troubleshooting an error from the Paypal REST API Error REQUIRED_SCOPE_MISSING.

    After redirecting any test user to the authorization approval page, I get the following error when attempting to Execute on the returned payment_id.

    stdClass Object ( [name] => REQUIRED_SCOPE_MISSING [message] => Access token is missing required scope. [information_link] => https://developer.paypal.com/webapps/developer/docs/api/#REQUIRED_SCOPE_MISSING [debug_id] => 4706a684636cd )

    I use scope: 'profile openid email address phone https://uri.paypal.com/services/expresscheckout'

    Login URL: https://www.sandbox.paypal.com/webapps/auth/protocol/openidconnect/v1/authorize?client_id=my_client_id&response_type=code&scope=openid%20profile%20email%20address%20phone%20https://uri.paypal.com/services/expresscheckout&redirect_uri=https://www.perfectplow.com/src/paypal.php

    I only call the API with one set of credentials and my Sandbox App permissions are set to allow everything, even unverified user login, but the issue persists.

    The page referenced in the REQUIRED_SCOPE_MISSING Error does not contain a single mention of that particular error, or even a single mention of the word scope so I could figure it out. In fact, I cannot find a full list of scopes that I might try anywhere in the Dev Docs.

    Somebody on Stack Overflow suggested creating a new App, but that did not resolve the REQUIRED_SCOPE_MISSING issue, so I deleted that single Sandbox App by name, and now my entire Paypal account is completely empty.

    Can somebody at Paypal see if these errors are related or rooted on your side ([email protected])? What Scopes are required for Execute but not Capture a successfully authorized payment?

    Kind Regards, Jordan

    Required Information

    • PHP Version: 5
    • PayPal-PHP-SDK Version: REST
    • Debug ID(s): 4706a684636cd

    Issue Description

    Please include as many details (logs, steps to reproduce) as you can to help us reproduce this issue faster.

    opened by JRedded 27
  • Managed Accounts API / V1

    Managed Accounts API / V1

    General information

    Hi There šŸ‘‹

    We have this request to see if the library supports this type of interface. We know it is under development but we would need to integrate it in our project we are writing understanding how to populate the tables and the infrastructure of the system.

    The example of bee management We found it in THIS PAGE and we did not find any examples in the guide provided.

    We wanted to know if the requests are supported by sdk paypal. If not, we need to develop one in PHP based on our system. šŸ±ā€šŸš€

    opened by MwSpaceLLC 0
  • Fix typos

    Fix typos

    Hi,

    This huge PR will fix :

    • 2 typos in lib/PayPal/Api/Capture.php
    • 2 typos in lib/PayPal/Api/OpenIdUserinfo.php
    • 2 typos in lib/PayPal/Api/Order.php
    • 1 typo in lib/PayPal/Api/Payout.php
    • 2 typos in lib/PayPal/Api/RefundDetail.php
    • 1 typo in lib/PayPal/Exception/PayPalConnectionException.php
    • 1 typo in sample/doc/lipp/GetUserInfo.html
    • 1 typo in sample/doc/payment-experience/UpdateWebProfile.html
    • 1 typo in sample/lipp/GetUserInfo.php
    • 1 typo in sample/payment-experience/CreateWebProfile.php
    • 1 typo in sample/payment-experience/UpdateWebProfile.php

    Cheers! :robot:

    opened by pgrimaud 0
  • What is the solution for recurring payments discounts?

    What is the solution for recurring payments discounts?

    What is the solution for recurring payments discounts? Recurring payments don't support multiple items.

    Originally posted by @DannyZB in https://github.com/paypal/PayPal-PHP-SDK/issues/55#issuecomment-167781467

    Trying to use Smart Buttons with the Rest API to generate tokens etc.

    As multiple products aren't allowed in a subscriptions, how do we give the users a discount.

    1. We can't add a negative amount product.
    2. No discount/coupon parameter available.

    Could you please shed some light on this.

    Will we need to create a new pricing plan for every possible coupon that we provide to users? That is the only solution I can think of.

    ref : Forum PayPal Billing API

    Thank you

    opened by imemohit 0
  • 100% discount

    100% discount

    General information

    • SDK/Library version:
    • Environment:
    • PayPal-Debug-ID values:
    • Language, language version, and OS:

    Issue description

    Hi, I'm working on 100% discount code, but I can't use it with PayPal. I added a line item Item and set negative to discount price, but when set 0 to Total, I got Amount cannot be zero

    opened by wilokecom 2
  • Unable to test Live i.e Unable to generate access_token to test live

    Unable to test Live i.e Unable to generate access_token to test live

    Hello! I'am new to paypal REST api.

    Recently i have created paypal business account.

    I have tested in sandbox it worked.

    I followed this

    https://developer.paypal.com/docs/api/get-an-access-token-curl/

    I generated access_token using sandbox

    curl -v https://api.sandbox.paypal.com/v1/oauth2/token \ -H "Accept: application/json" \ -H "Accept-Language: en_US" \ -u "client_id:secret" \ -d "grant_type=client_credentials"

    After generating access_token

    I have accessed my sandbox invoices using this method.

    curl -v -X GET https://api.sandbox.paypal.com/v2/invoicing/invoices/INV2-FKAK-R6BD-YR3X-CE3R \ -H "Content-Type: application/json" \ -H "Authorization: Bearer A21AAEK9ed_tfoxktk-NqiTEBf7BxmFR-E2_87uyhBl13JwX3YCSvEqfi1AAL0WplTue74uZmCM-VosvwdQ"

    It worked successfully.

    But when i tried to test live it is not working i have used the below method.

    ``curl -v https://api.paypal.com/v1/oauth2/token
    -H "Accept: application/json"
    -H "Accept-Language: en_US"
    -u "client_id:secret"
    -d "grant_type=client_credentials"`

    But i got the error

    {"error":"invalid_client","error_description":"Client Authentication failed"}

    My question is we need to verify the business account in order to test live curl command.....?

    I mean i just want to test invoices from my paypal account using curl account i.e live business account in linux terminal.

    I have viewed this docs.

    https://developer.paypal.com/docs/api/goingLive/

    for going live we need to verify our business account.......?

    Another thing is i just want to get the invoices to view by generated access_token like sandbox in the terminal itself.

    For this should i deploy the created app some where like website to get access to invoices using curl command......?

    Some people told that you won't need to deploy any app to test the live commands. but account verification is only.

    Please answer my doubts.

    Thanks!

    opened by vijaykumarcme 0
  • Paid success, but the total is always cost $85

    Paid success, but the total is always cost $85

    General information

    • SDK/Library version: 1.14.0
    • Environment: Both Sandbox and Production
    • Language, language version, and OS: PHP 7.2 on Ubuntu 16.10

    Issue description

    I have set the total to $1, but after paid, it always costs $85 ("shipping":"5","tax":"10","subtotal":"70" ), here's the codes:

    $product = 'Hello, World!';
    $description = 'Hello, World!';
    $currency = 'USD';
    $price = 1;
    $shipping = 0;
    $tax = 0;
    $paypal = $this->paypal;
    $subtotal = $price * 1;
    $total = $subtotal + $shipping + $tax;
    
    $payer = new Payer();
    $payer->setPaymentMethod( 'paypal' );
    
    $details = new Details();
    $details->setShipping( $shipping )
    		->setSubtotal( $subtotal )
    		->setTax( $tax );
    
    $amount = new Amount();
    $amount->setCurrency( $currency )
    	        ->setTotal( $total )
    	        ->setDetails( $details );
    
    $transaction = new Transaction();
    $transaction->setAmount( $amount )
    		      ->setDescription( $description )
    		      ->setInvoiceNumber( uniqid() );
    
    $redirectUrls = new RedirectUrls();
    $redirectUrls->setReturnUrl(  'https://domain.com/payment-result'  )
    			 ->setCancelUrl(  'https://domain.com/payment-cancelled'  );
    
    $payment = new Payment();
    $payment->setIntent( 'sale' )
    		->setPayer( $payer )
    		->setRedirectUrls( $redirectUrls )
    		->setTransactions( [$transaction] );
    
    $request = clone $payment;
    
    try {
        $payment->create( $apiContext );
    } catch (PayPalConnectionException $e) {
       die( $e->getData() );
    }
    
    $approvalUrl = $payment->getApprovalLink();
    add_header( location: $approvalUrl );
    
    return $payment;
    

    And this is log

    [03-04-2020 08:55:54] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.sandbox.paypal.com/v1/payments/payment
    [03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers 	: POST /v1/payments/payment HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, Content-Length: 361, , 
    [03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Request Data		: {"intent":"sale","payer":{"payment_method":"paypal"},"redirect_urls":{"return_url":"https://demo.lovage.io/epp/payment-result","cancel_url":"https://demo.lovage.io/epp/payment-cancelled"},"transactions":[{"amount":{"currency":"USD","total":"1","details":{"shipping":"0","subtotal":"1","tax":"0"}},"description":"Hello world!","invoice_number":"5e86fa1aa46e7"}]}
    --------------------------------------------------------------------------------------------------------------------------------
    
    [03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : INFO: Response Status 	: 201
    [03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers	: Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Language: *, Content-Length: 765, Content-Type: application/json, Date: Fri, 03 Apr 2020 08:55:55 GMT, Paypal-Debug-Id: 3531a093df75a, 
    [03-04-2020 08:55:55] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data 	: {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"created","payer":{"payment_method":"paypal"},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00","tax":"0.00","shipping":"0.00"}},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","related_resources":[]}],"create_time":"2020-04-03T08:55:54Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-44U11063WJ8096549","rel":"approval_url","method":"REDIRECT"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute","rel":"execute","method":"POST"}]}
    
    ================================================================================================================================
    
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: GET https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers 	: GET /v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, , 
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: No Request Payload
    --------------------------------------------------------------------------------------------------------------------------------
    
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: Response Status 	: 200
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers	: Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Length: 1585, Content-Type: application/json;charset=UTF-8, Date: Fri, 03 Apr 2020 08:56:36 GMT, Paypal-Debug-Id: 3feac4379943e, 
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data 	: {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"created","cart":"44U11063WJ8096549","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"[email protected]","first_name":"test","last_name":"buyer","payer_id":"FYADYGXGPWBGQ","shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"},"country_code":"C2"}},"transactions":[{"amount":{"total":"1.00","currency":"USD","details":{"subtotal":"1.00","tax":"0.00","shipping":"0.00"}},"payee":{"merchant_id":"KX6UB59E846NC","email":"[email protected]"},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","item_list":{"shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"}},"related_resources":[]}],"redirect_urls":{"return_url":"https://demo.lovage.io/epp/payment-result?paymentId=PAYID-L2DPUGY3T8910505S347164J","cancel_url":"https://demo.lovage.io/epp/payment-cancelled"},"create_time":"2020-04-03T08:55:54Z","update_time":"2020-04-03T08:56:36Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute","rel":"execute","method":"POST"},{"href":"https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-44U11063WJ8096549","rel":"approval_url","method":"REDIRECT"}]}
    
    ================================================================================================================================
    
    [03-04-2020 08:56:36] PayPal\Core\PayPalHttpConnection : INFO: POST https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute
    [03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Request Headers 	: POST /v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J/execute HTTP/1.1, Host: api.sandbox.paypal.com, Accept: */*, Content-Type: application/json, User-Agent: PayPalSDK/PayPal-PHP-SDK 1.14.0 (platform-ver=7.3.14-1~deb10u1; bit=64; os=Linux_4.10.2-041002-lowlatency; machine=x86_64; crypto-lib-ver=1.1.1d; curl=7.64.0), Authorization: Bearer A21AAFio3Upr9iBH7e-VWazpFCpeYubfFHqbQEbp7QEFfGe354A02bdv3wlBlZOGdXUeSeke5XrRVTrOSPl0xpcFsuqayPzng, Content-Length: 142, , 
    [03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Request Data		: {"payer_id":"FYADYGXGPWBGQ","transactions":[{"amount":{"currency":"USD","total":"85","details":{"shipping":"5","tax":"10","subtotal":"70"}}}]}
    --------------------------------------------------------------------------------------------------------------------------------
    
    [03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : INFO: Response Status 	: 200
    [03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Response Headers	: Cache-Control: max-age=0, no-cache, no-store, must-revalidate, Content-Length: 2094, Content-Type: application/json;charset=UTF-8, Date: Fri, 03 Apr 2020 08:56:40 GMT, Paypal-Debug-Id: 6e5ebc5f1a79b, 
    [03-04-2020 08:56:40] PayPal\Core\PayPalHttpConnection : DEBUG: Response Data 	: {"id":"PAYID-L2DPUGY3T8910505S347164J","intent":"sale","state":"approved","cart":"44U11063WJ8096549","payer":{"payment_method":"paypal","status":"VERIFIED","payer_info":{"email":"[email protected]","first_name":"test","last_name":"buyer","payer_id":"FYADYGXGPWBGQ","shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"},"country_code":"C2"}},"transactions":[{"amount":{"total":"85.00","currency":"USD","details":{"subtotal":"70.00","tax":"10.00","shipping":"5.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"payee":{"merchant_id":"KX6UB59E846NC","email":"[email protected]"},"description":"Hello world!","invoice_number":"5e86fa1aa46e7","item_list":{"shipping_address":{"recipient_name":"buyer test","line1":"NO 1 Nan Jin Road","city":"Shanghai","state":"Shanghai","postal_code":"200000","country_code":"C2"}},"related_resources":[{"sale":{"id":"7LV16321SK655952D","state":"pending","amount":{"total":"85.00","currency":"USD","details":{"subtotal":"70.00","tax":"10.00","shipping":"5.00","insurance":"0.00","handling_fee":"0.00","shipping_discount":"0.00"}},"payment_mode":"INSTANT_TRANSFER","reason_code":"PAYMENT_REVIEW","protection_eligibility":"INELIGIBLE","transaction_fee":{"value":"3.19","currency":"USD"},"parent_payment":"PAYID-L2DPUGY3T8910505S347164J","create_time":"2020-04-03T08:56:39Z","update_time":"2020-04-03T08:56:39Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/sale/7LV16321SK655952D","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/payments/sale/7LV16321SK655952D/refund","rel":"refund","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"parent_payment","method":"GET"}]}}]}],"failed_transactions":[],"create_time":"2020-04-03T08:55:54Z","update_time":"2020-04-03T08:56:39Z","links":[{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-L2DPUGY3T8910505S347164J","rel":"self","method":"GET"}]}
    

    I have found everywhere, but not sure where the shipping fee, tax is come from.

    opened by 0xWubo 0
Releases(1.14.0)
Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs

Shopware PHP SDK is a simple SDK implementation of Shopware 6 APIs. It helps to access the API in an object-oriented way.

Thuong Le 77 Dec 19, 2022
Zoho CRM API SDK is a wrapper to Zoho CRM APIs. By using this sdk, user can build the application with ease

Archival Notice: This SDK is archived. You can continue to use it, but no new features or support requests will be accepted. For the new version, refe

null 81 Nov 4, 2022
A simple way of authenticating your RESTful APIs with API keys using Laravel

ApiGuard This package is no longer maintained This package is no longer maintained as Laravel already has a similar feature built-in since Laravel 5.8

Chris Bautista 691 Nov 29, 2022
PHP library/SDK for Crypto APIs 2.0 using Guzzle version 7

cryptoapis/sdk-guzzle7 Crypto APIs 2.0 is a complex and innovative infrastructure layer that radically simplifies the development of any Blockchain an

Crypto APIs 3 Oct 21, 2022
Simple and effective multi-format Web API Server to host your PHP API as Pragmatic REST and / or RESTful API

Luracast Restler ![Gitter](https://badges.gitter.im/Join Chat.svg) Version 3.0 Release Candidate 5 Restler is a simple and effective multi-format Web

Luracast 1.4k Dec 14, 2022
A RESTful API package for the Laravel and Lumen frameworks.

The Dingo API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own API. While the goal of

null 9.3k Jan 7, 2023
A simple example of how to create a RESTful API in Laravel Framework 8.36.1.

FirstLaravel A simple example of how to create a RESTful API in Laravel Framework 8.36.1. I used Database sqlite because I wanted to deploy this proje

Max Base 4 Apr 16, 2021
A RESTful and extendable Backend as a Service that provides instant backend to develop sites and apps faster, with dead-simple integration for JavaScript, iOS, Android and more.

Welcome to hook ![Gitter](https://badges.gitter.im/Join Chat.svg) hook is a RESTful, extendable Backend as a Service that provides instant backend to

doubleleft 762 Dec 30, 2022
My first laravel restful api project

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Amirhosein Mohammadian 2 Oct 13, 2021
Best resources restful api for developers

Best resources restful api for developers (with JSON:API standar specification design).

Noval 2 Jan 18, 2022
Best resources restful api for developers (with JSON:API standar specification design)

List API Best resources restful api for developers (with JSON:API standar specification design). API Resource Endpoint Name Resource Description Al Qu

Noval 2 Jan 18, 2022
Fully documented & tested Laravel 9 RESTful books API scraped from Gramedia.

Laravel Books API Introduction This app provides a list of books in a RESTful API. Source of data obtained from Gramedia by using the web scraping tec

Yusuf T. 44 Dec 23, 2022
A php library for coinex exchange apis .

Coinex API PHP Coinex digital coin exchange API for PHP Requirements PHP>=7.1 CURL PHP module Install composer require roozbeh/coinex_php Acquire acce

Roozbeh Baabakaan 3 Nov 12, 2022
Pure PHP APIs with PostgreSQL database, with HTML, CSS & JS simple frontend

The root of the project is html/index.html The folder needs to be put in htdocs folder to run correctly // this link should open the main page if the

ZaydSK 3 Jul 22, 2022
The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructure and leverage the power of 1Password Secrets Automation

1Password Connect PHP SDK The 1Password Connect PHP SDK provides your PHP applications access to the 1Password Connect API hosted on your infrastructu

Michelangelo van Dam 12 Dec 26, 2022
Facebook SDK for PHP (v6) - allows you to access the Facebook Platform from your PHP app

Facebook SDK for PHP (v6) This repository contains the open source PHP SDK that allows you to access the Facebook Platform from your PHP app. Installa

null 0 Aug 10, 2022
Create REST and GraphQL APIs, scaffold Jamstack webapps, stream changes in real-time.

API Platform is a next-generation web framework designed to easily create API-first projects without compromising extensibility and flexibility: Desig

API Platform 7.7k Jan 7, 2023
Behat extension for those who want to write acceptances tests for apis

Behapi Behat extension to help write describe features related to HTTP APIs. PHP 7.3, Behat 3.7 and a discoverable php-http client are required to mak

Baptiste ClaviƩ 32 Nov 25, 2022
Laravel cryptocurrency trading APIs.

Lypto API Laravel cryptocurrency trading APIs. Installation Requirements Minimum Laravel version 7.0 Use the following command to install: composer re

Md Obydullah 4 Jan 27, 2022