Python Paypal API documentation

This project helps you using python 3.8 to use the Python Paypal API.

Installation

You can install using pip

pip install python-paypal-api

Credentials

How to Authenticate

Please check as this example provides all ways to authenticate trough this API.

Paypal Rest API, support Basic and Bearer authentication so lets go from simple to complex. For any test you need have at least a client_id and a client_secret to run it.

client_id string The ID obtained from Paypal
client_secret string The password obtained from Paypal
client_mode enum PRODUCTION or SANDBOX

HTTPBasicAuth

The most simple way is to use the auth as a combination of client_id and client_secret, requests will create an HTTPBasicAuth that will allow you to get access to Paypal Rest API:

Pass Credentials As Tuple

credentials tuple

credentials = ("your-client-id", "your-client-secret", "SANDBOX")

### Example python

from python_paypal_api.api import Identity
from python_paypal_api.base import PaypalApiException

my_credentials = ("your-client-id", "your-client-secret", "SANDBOX")

try:

    result = Identity(credentials=my_credentials).get_userinfo()
    payload = result.payload
    print(payload)

except PaypalApiException as error:

    print(error)

OAuth 2.0 Bearer

Bearer Tokens are the predominant type of access token used with OAuth 2.0. A Bearer Token is an opaque string, not intended to have any meaning to clients using it. This way will call the paypal oauth2 api and request for a token that could be used for all the api calls until get expired. There is 3 ways to achieve that: from environ, from code and from config.

Pass Credentials From Environ
client_id os._Environ >> str required
client_secret os._Environ >> str required
client_mode os._Environ >> str
import os
os.environ["client_id"] = "your-client-id"
os.environ["client_secret"] = "your-client-secret"
os.environ["client_mode"] = "your-client-mode"

### Example python

import os
from python_paypal_api.api import Identity
from python_paypal_api.base import PaypalApiException


os.environ["client_id"] = "your-client-id"
os.environ["client_secret"] = "your-client-secret"
os.environ["client_mode"] = "your-client-mode"

try:
    result = Identity().get_userinfo()
    payload = result.payload
    print(payload)
except PaypalApiException as error:
    print(error)
Pass Credentials From Code

credentials dict

credentials = dict(
    client_id="your-client-id",
    client_secret="your-client-secret",
    client_mode="SANDBOX"
)

### Example python

from python_paypal_api.api import Products
from python_paypal_api.base import PaypalApiException

my_credentials = dict(
    client_id="your-client-id",
    client_secret="your-client-secret",
    client_mode="SANDBOX"
)

try:
    result = Products(credentials=my_credentials, debug=True).list_products()
    payload = result.payload
    print(payload)
except PaypalApiException as error:
    print(error)
Pass Credentials From Config

An example config file is provided in this repository, it supports multiple accounts. The confuse will search the system for a config file named config.yaml in the following search paths.

  • macOS: ~/.config/python-paypal-api and ~/Library/Application Support/python-paypal-api

  • Other Unix: ~/.config/python-paypal-api and /etc/python-paypal-api

  • Windows: %APPDATA%\python-paypal-api where the APPDATA environment variable falls back to %HOME%\AppData\Roaming if undefined

Content example of a config.yaml file.

version: '1.0'

configuration:

    production:
        client_id: 'your-client-id'
        client_secret: 'your-client-secret'
        client_mode: 'PRODUCTION'

    default:
        client_id: 'your-client-id-sandbox'
        client_secret: 'your-client-secret-sandbox'

credentials str

credentials = "production"

### Example python

from python_paypal_api.api import Identity
from python_paypal_api.base import PaypalApiException

try:
    result = Identity(credentials="production", debug=True).get_userinfo(
    payload = result.payload
    print(payload)
except PaypalApiException as error:
    print(error)

View full possibilities From Config File

Warning

If you are using HTTPBasicAuth this do not applies as every call will be based on client_id and client_secret combination. No token is involved.

Storing Credentials

If you use OAuth 2.0 Bearer to avoid calls to the oauth paypal authentication api to obtain the token for Bearer authentication, there is 2 ways to deal with that:

Cache

The python paypal api will use the cachetools package to store the token in a LRU cache. This provides you a way that the token is stored in cache however it will be alive since the python script is executing and includes all possible calls to the api. When the script is ended the cache is flushed and other script will not be able to obtain a cached token one and will call the api to obtain a current or new one.

File

If you provide a store_credentials bool in the client, True or False (default) The python paypal api will store the token in a file linked as an md5 of the client_id. All next calls will find the file first, check if the token is not expired and use it. If the token is expired will recreate a new file with the new token and the actual expiring time. For security reasons the token file could be encrypted or not, using safe bool in the client, True or False (default). If safe=True, will use cryptography package to generate a Fernet key and encrypt the content. The .key file and the .token file will be stored in the confuse config folder config = confuse.Configuration('python-paypal-api') View more details about confuse in the From Config File help.

Simple

Pass the keywords parameters to the client as bool:

Identity(store_credentials=True).get_userinfo() # Mode Store Safe No
Identity(store_credentials=True, safe=True).get_userinfo() # Mode Store Safe Yes
Complex

You could also pass the configuration as a dict. In that way you could overwrite the default storing folders for both token and key. Be aware that the folders need to exist and changing the configuration without moving the files will create a new token with a new key. Please check full examples to see the way you can use and choose it wisely.

safe bool Whether if the token will be encrypted or not. True or False
token_path string The absolut path to the folder wish to store the token
key_path_name string The absolut path to the file where you wish to store the key.
key_value string Fernet key must be 32 url-safe base64-encoded bytes. Use key_value will invalidate a key_path_name.

This examples store an encrypted token in the folder store_encrypted and a key named sandbox_secret.key in the folder store_key.

config = \
{
    "safe": True,
    "token_path": "/Users/your-user/Desktop/store_encrypted",
    "key_path_name": "/Users/your-user/Desktop/store_key/sandbox_secret.key",
}

Identity(store_credentials=config, safe=True).get_userinfo() # Mode Store Safe Yes

You could also use your own key and not store it, so in that way you will not use a key_path_name and you should use a key_value.

config = \
{
    "safe": True,
    "token_path": "/Users/your-user/Desktop/store_encrypted",
    "key_value": "4BekoTZNO5aK4HOtIwkGYbq0IegqE5Y6w0bUoqVJqzk=",
}

Identity(store_credentials=config, safe=True).get_userinfo() # Mode Store Safe Yes

Warning

Take care about that the token filename is inmutable and if you use diferent configuration could result in overwriting the token with a new key if you change it.

Current resources

Create and manage your site’s payment functions using PayPal API collections.

Add Tracking API

Add Tracking API

Merchants can use the PayPal Add Tracking API to manage tracking information. Merchants can add tracking numbers and associated information to PayPal. After adding these details to PayPal, merchants can:

  • Update tracking details.

  • Show tracking details.

  • Cancel tracking numbers.

For more information, see the Add Tracking API Overview and Add Tracking API Integration Guide.

class python_paypal_api.api.Tracking(*args, **kwargs)

Use the /trackers resource to create and manage tracking information for PayPal transactions.

put_tracking(self, id: str, **kwargs) ApiResponse

PUT /v1/shipping/trackers/{id}

Updates or cancels the tracking information for a PayPal transaction, by ID. To cancel tracking information, call this method and set the status to CANCELLED. For more information, see Update or cancel tracking information.

**args:

id string required
The ID of the tracker in the transaction_id-tracking_number format.

**kwargs: Request body

status enum required
The status of the item shipment. For allowed values, see Shipping Statuses.
The possible values are:
  • CANCELLED. The shipment was cancelled and the tracking number no longer applies.

  • DELIVERED. The item was already delivered when the tracking number was uploaded.

  • LOCAL_PICKUP. Either the buyer physically picked up the item or the seller delivered the item in person without involving any couriers or postal companies.

  • ON_HOLD. The item is on hold. Its shipment was temporarily stopped due to bad weather, a strike, customs, or another reason.

  • SHIPPED. The item was shipped and is on the way.

  • SHIPMENT_CREATED. The shipment was created.

  • DROPPED_OFF. The shipment was dropped off.

  • IN_TRANSIT. The shipment is in transit on its way to the buyer.

  • RETURNED. The shipment was returned.

  • LABEL_PRINTED. The label was printed for the shipment.

  • ERROR. An error occurred with the shipment.

  • UNCONFIRMED. The shipment is unconfirmed.

  • PICKUP_FAILED. Pick-up failed for the shipment.

  • DELIVERY_DELAYED. The delivery was delayed for the shipment.

  • DELIVERY_SCHEDULED. The delivery was scheduled for the shipment.

  • DELIVERY_FAILED. The delivery failed for the shipment.

  • INRETURN. The shipment is being returned.

  • IN_PROCESS. The shipment is in process.

  • NEW. The shipment is new.

  • VOID. If the shipment is cancelled for any reason, its state is void.

  • PROCESSED. The shipment was processed.

  • NOT_SHIPPED. The shipment was not shipped.

transaction_id string required
The PayPal transaction ID.
carrier enum required
The carrier for the shipment. Some carriers have a global version as well as local subsidiaries. The subsidiaries are repeated over many countries and might also have an entry in the global list. Choose the carrier for your country. If the carrier is not available for your country, choose the global version of the carrier. If your carrier name is not in the list, set carrier_other_name to OTHER. For allowed values, see Carriers.
The possible values are:
  • ACOMMERCE. aCommerce

  • PHL_2GO. 2GO Philippines

  • AU_DHL_EXPRESS. DHL Express Australia.

  • BEL_DHL. DHL Belgium.

  • DE_DHL_DEUTSHCE_POST_INTL_SHIPMENTS. Deutsche Post DHL Post International Germany

  • IE_AN_POST_REGISTERED. Post Registered Ireland

  • AU_AU_POST. Australian Postal Corporation

  • SPEEDEXCOURIER. Speedex Courier.

  • UK_ROYALMAIL_SPECIAL. Royal Mail Special Delivery UK

  • FR_COLIS. Colis France.

  • VNPOST_EMS. Post EMS Vietnam.

  • NL_FEDEX. Federal Express Netherlands

  • CN_EMS. EMS China.

  • IT_POSTE_ITALIANE. Poste Italiane.

  • HK_DHL_ECOMMERCE. DHL eCommerce Hong Kong.

  • ARAMEX. Aramex.

  • AU_OTHER. Other - Australia.

  • TW_CHUNGHWA_POST. Chunghwa POST Taiwan

  • DPEX. DPEX Worldwide

  • POST_SERBIA. Pošta Srbije

  • PL_POCZTEX. Pocztex

  • CNEXPS. CN Express China.

  • DIRECTLOG. Directlog.

  • ES_CORREOS_DE_ESPANA. Correos de Espana

  • BE_KIALA. Kiala Point Belgium

  • ALPHAFAST. Alphafast.

  • UKR_POSHTA. Ukrposhta - Ukraine’s National Post

  • CN_FEDEX. Federal Express China

  • BUYLOGIC. Buylogic

  • IT_DHL_ECOMMERCE. DHL eCommerce Italy.

  • NINJAVAN_MY. Ninjavan Malaysia.

  • JPN_YAMATO. Yamato Japan.

  • POSTNORD_LOGISTICS. Post Nord Logistics.

  • US_DHL_GLOBALFORWARDING. DHL Global Forwarding US.

  • IT_SGT. SGT Corriere Espresso Italy.

  • NINJAVAN_PHILIPPINES. Ninja Van Philippines.

  • EKART. Ekart.

  • IDN_WAHANA. Wahana Indonesia.

  • FR_GLS. General Logistics Systems (GLS) France

  • IDN_POS_INT. Pos Indonesia International.

  • DE_HERMES. Hermes Germany.

  • PRT_CHRONOPOST. Chronopost Portugal.

  • MYS_MYS_POST. Pos Malaysia

  • WEBINTERPRET. WebInterpret.

  • BG_BULGARIAN_POST. Bulgarian Post

  • NL_TPG. TPG Post Netherlands

  • CA_CANPAR. Canpar Courier Canada

  • MYS_AIRPAK. Airpak Malaysia.

  • MEX_SENDA. Senda Mexico.

  • LANDMARK_GLOBAL. Landmark Global.

  • UK_NIGHTLINE. Nightline UK.

  • JP_UPS. United Parcel Service Japan

  • UK_DHL. DHL UK.

  • SG_SG_POST. Singapore Post.

  • PHL_AIRSPEED. Airspeed Philippines.

  • DHL. DHL Express.

  • KR_KOREA_POST. Korea Post

  • JP_KURO_NEKO_YAMATO_UNYUU. Kuro Neko Yamato Unyuu Japan

  • IE_AN_POST_SWIFTPOST. Swift Post Ireland

  • CUCKOOEXPRESS. Cuckoo Express.

  • FR_OTHER. Other - France.

  • FASTRAK_TH. Fastrak Thailand.

  • AU_DHL_ECOMMERCE. DHL eCommerce Australia.

  • DE_UPS. United Parcel Service Germany

  • ESHOPWORLD. EShopWorld.

  • INTERNATIONAL_BRIDGE. International Bridge.

  • FR_COLIPOSTE. Coliposte France

  • AU_AUSTRIAN_POST. Austrian Post.

  • IND_DELHIVERY. Delhivery India

  • DE_TNT. TNT Germany.

  • GLOBAL_DHL. DHL Global.

  • US_DHL_PARCEL. DHL Parcel US.

  • NL_UPS. United Parcel Service Netherlands

  • GB_APC. APC Overnight UK

  • IDN_TIKI. Tiki Indonesia.

  • HERMES. Hermes.

  • ESP_NACEX. Nacex Spain

  • NL_TNT. TNT Netherlands.

  • DE_FEDEX. Federal Express Germany

  • OTHER. Other.

  • BONDSCOURIERS. Bonds Couriers.

  • IT_DHL_GLOBALFORWARDING. DHL Global Forwarding Italy.

  • IDN_LION_PARCEL. Lion Parcel Indonesia.

  • UK_YODEL. Yodel UK

  • IT_DHL_EXPRESS. DHL Express Italy.

  • PL_DHL_GLOBALFORWARDING. DHL Global Forwarding Poland

  • DPD_POLAND. DPD Poland.

  • AU_AUSTRALIA_POST_EXPRESS_POST_PLATINUM. Australia Post Express Post Platinum

  • ES_TNT. TNT Spain.

  • CN_DHL_EXPRESS. DHL Express Canada.

  • DE_DPD. DPD Germany.

  • DE_DPD_DELISTRACK. DPD Delistrack Germany

  • CN_DHL_ECOMMERCE. DHL eCommerce China.

  • JP_TNT. TNT Japan.

  • PRT_CTT. CTT Expresso Portugal

  • UK_INTERLINK_EXPRESS. Interlink Express UK.

  • NLD_POSTNL. PostNL Netherlands

  • CA_DHL_ECOMMERCE. DHL eCommerce Canada.

  • SWIFTAIR. Swift Air.

  • NOR_POSTEN. Posten Norge

  • MEX_REDPACK. Redpack Mexico.

  • PL_MASTERLINK. Masterlink Poland

  • PL_TNT. TNT Express Poland

  • NIM_EXPRESS. Nim Express

  • PL_UPS. United Parcel Service Poland

  • UKR_NOVA. Nova Poshta

  • QUANTIUM. Quantium.

  • SENDLE. Sendle.

  • SG_PARCELPOST. Parcel Post Singapore.

  • SG_NINJAVAN. Ninjavan Singapore.

  • BQC_EXPRESS. BQC Express.

  • RPD2MAN. RPD2man Deliveries

  • THA_KERRY. Kerry Thailand.

  • MEX_AEROFLASH. Aeroflash Mexico.

  • SPREADEL. Spreadel.

  • ESP_REDUR. Redur Spain

  • JP_JAPANPOST. Japan Post

  • ARE_EMIRATES_POST. Emirates Post Group

  • CN_CHINA_POST_EMS. China Post EMS Express Mail Service

  • UK_DHL_GLOBALFORWARDING. DHL Global Forwarding UK.

  • CN_SF_EXPRESS. SF Express China.

  • UK_FEDEX. Federal Express UK

  • POL_POCZTA. Poczta Poland.

  • YANWEN. Yanwen Express

  • KOR_CJ. CJ Korea.

  • DE_DEUTSCHE_POST_DHL_WITHIN_EUROPE_TRACKNET. Deutsche Post DHL Tracknet Germany

  • IND_XPRESSBEES. XpressBees India.

  • UK_TNT. TNT UK.

  • CJ_KOREA_THAI. CJ Logistics in Thailand

  • CN_OTHER. Other - China.

  • IDN_POS. Indonesia Post.

  • ABC_MAIL. ABC Mail.

  • UK_UPS. United Parcel Service UK

  • CHINA_POST. China Post.

  • PL_DHL_EXPRESS. DHL Express Poland.

  • ESP_SPANISH_SEUR. Spanish Seur Spain

  • SG_ZALORA. Zalora Singapore.

  • MATKAHUOLTO. Matkahuoloto.

  • FR_LAPOSTE. Laposte France.

  • KANGAROO_MY. Kangaroo Express Malaysia.

  • ESP_CORREOS. Sociedad Estatal Correos y Telégrafos

  • NL_KIALA. KIALA Netherlands

  • IND_BLUEDART. Blue Dart Express DHL

  • TUR_PTT. PTT Turkey.

  • CA_CANNOT_PROVIDE_TRACKING. Cannot provide tracking - Canada.

  • JPN_SAGAWA. Sagawa Japan.

  • MYS_SKYNET. Skynet Malaysia.

  • IT_FERCAM. Fercam Italy.

  • UK_AIRBORNE_EXPRESS. Airborne Express UK.

  • CA_OTHER. Other - Canada.

  • DE_DEUTSHCE_POST_DHL_TRACK_TRACE_EXPRESS. Deutsche Post DHL Track Trace Express Germany

  • CORREOS_DE_MEXICO. Mex Post Correos de Mexico

  • FR_DHL_GLOBALFORWARDING. DHL Global Forwarding France.

  • GLOBAL_SKYNET. Skynet Global.

  • AU_DHL_GLOBALFORWARDING. DHL Global Forwarding Australia.

  • DE_DHL_GLOBALFORWARDING. DHL Global Forwarding Germany.

  • SFC_LOGISTICS. SFC Logistics

  • US_GLOBEGISTICS. Globeistics US.

  • CA_DHL_GLOBALFORWARDING. DHL Global Forwarding Canada.

  • OMNIPARCEL. Omni Parcel.

  • PHL_AIR21. Air21 Philippines

  • CBL_LOGISTICA. CBL Logística

  • FR_MONDIAL. Mondial France.

  • DE_DHL_ECOMMERCE. DHL eCommerce Germany.

  • ADICIONAL. Adicional.

  • CH_SWISS_POST_PRIORITY. Swiss Post Priority

  • NL_INTANGIBLE_DIGITAL_SERVICES. Intangible Digital Services

  • DE_ASENDIA. Asendia Germany.

  • NL_ABC_MAIL. ABC Mail Netherlands

  • UK_DELTEC. Deltec UK.

  • ONE_WORLD. One World.

  • AIRBORNE_EXPRESS. Airborne Express.

  • ES_OTHER. Other - Spain.

  • US_DHL_ECOMMERCE. DHL eCommerce US

  • US_ENSENDA. Ensenda US.

  • CPACKET. Cpacket.

  • AXL. AXL Express & Logistics

  • IND_REDEXPRESS. Red Express India.

  • NL_LOCAL_PICKUP. Local PickUp Netherlands

  • UK_ROYALMAIL_AIRSURE. Royal Mail AirSure UK

  • FR_TNT. TNT France.

  • USPS. United States Postal Service (USPS)

  • RINCOS. Rincos.

  • B2CEUROPE. B2C Europe

  • PHL_LBC. LBC Philippines.

  • SG_TAQBIN. TA-Q-BIN Parcel Singapore.

  • GR_ELTA. Elta Greece.

  • WINIT. WinIt.

  • NLD_DHL. DHL Netherlands.

  • FR_GEODIS. Geodis France.

  • DE_DHL_PACKET. DHL Packet Germany.

  • ARG_OCA. OCA Argentia

  • JP_DHL. DHL Japan.

  • RUSSIAN_POST. Russian Post.

  • TW_TAIWAN_POST. Chunghwa Post

  • UPS. United Parcel Service of America, Inc.

  • BE_BPOST. Bpost Belgium

  • JP_SAGAWA_KYUU_BIN. Sagawa Kyuu Bin Japan

  • NATIONWIDE_MY. Nationwide Malaysia.

  • TNT. TNT Portugal.

  • COURIERS_PLEASE. Couriers Please.

  • DMM_NETWORK. DMM Network.

  • TOLL. Toll

  • NONE. None

  • IDN_FIRST_LOGISTICS. First Logistics Indonesia.

  • BH_POSTA. BH POŠTA

  • SENDIT. SendIt.

  • US_DHL_EXPRESS. DHL Express US.

  • FEDEX. FedEx.

  • SWE_POSTNORD. PostNord Sverige

  • PHL_XEND_EXPRESS. Xend Express Philippines.

  • POSTI. Posti.

  • CA_CANADA_POST. Canada Post

  • PL_FEXEX. Fexex Poland

  • CN_EC. EC China.

  • HK_TAQBIN. TA-Q-BIN Parcel Hong Kong.

  • UK_AN_POST. AddressPay UK

  • WISELOADS. Wiseloads.

  • PRT_SEUR. Seur Portugal

  • US_ONTRAC. Ontrac US.

  • THA_THAILAND_POST. Thailand Post.

  • DPE_EXPRESS. DPE Express.

  • UK_DHL_EXPRESS. DHL Express UK.

  • NL_DHL. DHL Netherlands

  • HK_FLYT_EXPRESS. Flyt Express Hong Kong

  • UK_HERMESWORLD. Hermesworld UK.

  • IT_REGISTER_MAIL. Registered Mail Italy.

  • ARG_CORREO. Correo Argentino

  • CA_LOOMIS. Loomis Express Canada

  • DTDC_AU. DTDC Australia.

  • DPD. DPD Global.

  • ASENDIA_HK. Asendia Hong Kong.

  • UK_ROYALMAIL_RECORDED. Royal Mail Recorded UK

  • PL_POCZTA_POLSKA. Poczta Polska

  • EU_IMX. IMX EU

  • IDN_PANDU. Pandu Indonesia.

  • MEX_ESTAFETA. Estafeta Mexico

  • SREKOREA. SRE Korea

  • CYP_CYPRUS_POST. Cyprus Post

  • NZ_COURIER_POST. CourierPost New Zealand

  • CN_EMPS. EMPS China.

  • AU_TNT. TNT Australia.

  • UK_CANNOT_PROVIDE_TRACKING. Cannot provide tracking - UK.

  • ES_DHL. DHL Spain.

  • CONTINENTAL. Continental.

  • IND_DTDC. DTDC India.

  • DE_GLS. General Logistics Systems (GLS) Germany

  • NLD_GLS. General Logistics Systems (GLS) Netherlands

  • UK_DPD. DPD UK.

  • IT_TNT. TNT Italy

  • PL_DHL. DHL Portugal.

  • JP_NITTSU_PELICAN_BIN. Nittsu Pelican Bin Japan

  • THA_DYNAMIC_LOGISTICS. Dynamic Logistics Thailand.

  • IT_POSTE_ITALIA. Poste Italia

  • UK_ROYALMAIL_INTER_SIGNED. Royal Mail International Signed UK

  • HERMES_IT. Hermes Italy.

  • FR_BERT. Bert France

  • IND_PROFESSIONAL_COURIERS. Professional Couriers India.

  • POL_SIODEMKA. Siodemka Poland.

  • IE_AN_POST_SDS_PRIORITY. Post SDS Priority Ireland

  • ADSONE. ADSone Cumulus

  • BRA_CORREIOS. Correios Brazil.

  • UBI_LOGISTICS. UBI Logistics.

  • ES_CORREOS. Sociedad Estatal Correos y Telégrafos

  • NGA_NIPOST. Nigerian Postal Service

  • AUT_AUSTRIAN_POST. Austrian Post.

  • AU_FASTWAY. Fastway Australia.

  • AUS_TOLL. Toll Australia.

  • CA_CANPAR_COURIER. Canpar Courier Canada.

  • SWE_DIRECTLINK. Direct Link Sweden

  • CZE_CESKA. Česká pošta

  • ROYAL_MAIL. Royal Mail.

  • SG_SINGPOST. SingPost Singapore

  • IT_OTHER. Other - Italy.

  • ZA_FASTWAY. Fastway Couriers (South Africa)

  • SEKOLOGISTICS. Seko Logistics.

  • CN_UPS. CN_UPS

  • HUNTER_EXPRESS. Hunter Express.

  • DE_DHL_PARCEL. DHL Parcel Germany.

  • NLD_TRANSMISSION. Transmission Netherlands.

  • CN_TNT. TNT China.

  • DE_DEUTSCHE. Deutsche Post Germany.

  • AIRSURE. Airsure.

  • UK_PARCELFORCE. Parcelforce UK.

  • SWE_DB. DB Schenker Sweden

  • CN_CHINA_POST. China Post

  • PL_GLS. General Logistics Systems Poland

  • EU_BPOST. bpost

  • RELAIS_COLIS. Relais Colis

  • UK_DHL_PARCEL. DHL Parcel UK.

  • AUS_STARTRACK. StarTrack Australia

  • AU_TOLL_IPEC. Toll IPEC Australia

  • CORREOS_CHILE. CorreosChile

  • CH_SWISS_POST_EXPRES. Swiss Post Express

  • MYS_TAQBIN. TA-Q-BIN Parcel Malaysia.

  • JET_SHIP. Jetship.

  • HK_DHL_EXPRESS. DHL Express Hong Kong.

  • IT_SDA. SDA Express Courier

  • DE_DHL_DEUTSCHEPOST. DHL Deutsche Post Germany.

  • HK_DHL_GLOBALFORWARDING. DHL Global Forwarding Hong Kong.

  • PHL_RAF. RAF Philippines.

  • IT_GLS. General Logistics Systems (GLS) Italy

  • PANTOS. Pantos.

  • KOR_ECARGO. Ecargo Korea.

  • AT_AUSTRIAN_POST_EMS. EMS Express Mail Service Austria

  • IT_BRT. BRT Corriere Espresso Italy

  • CHE_SWISS_POST. Swiss Post.

  • FASTWAY_NZ. Fastway New Zealand.

  • IT_EBOOST_SDA. IT_EBOOST_SDA

  • ASENDIA_UK. Asendia UK.

  • RRDONNELLEY. RR Donnelley.

  • US_RL. RL US.

  • GR_GENIKI. Geniki Greece.

  • DE_DHL_EXPRESS. DHL Express Germany.

  • CA_GREYHOUND. Greyhound Canada.

  • UK_COLLECTPLUS. CollectPlus UK

  • NINJAVAN_THAI. Ninjavan Thailand.

  • RABEN_GROUP. Raben Group.

  • CA_DHL_EXPRESS. DHL Express Canada.

  • GLOBAL_TNT. TNT Global.

  • IN_INDIAPOST. India Post

  • ITIS. ITIS International

  • PHL_JAMEXPRESS. JamExpress Philippines.

  • PRT_INT_SEUR. Internationational Seur Portugal

  • ESP_ASM. Parcel Monitor Spain

  • NINJAVAN_ID. Ninjavan Indonesia.

  • JP_FEDEX. Federal Express Japan

  • FR_CHRONOPOST. Chronopost France.

  • FR_SUIVI. Suivi FedEx France

  • FR_TELIWAY. Teliway France.

  • JPN_JAPAN_POST. Japan Post

  • HRV_HRVATSKA. Hrvatska Pošta

  • AT_AUSTRIAN_POST_PAKET_PRIME. Austrian Post Paket Prime

  • DE_OTHER. Other - Germany.

  • HK_HONGKONG_POST. Hong Kong Post.

  • GRC_ACS. ACS Greece.

  • HUN_MAGYAR. Magyar Posta

  • FR_DHL_PARCEL. DHL Parcel France.

  • UK_OTHER. Other - UK.

  • LWE_HK. LWE Hong Kong.

  • EFS. Enterprise Freight Systems (EFS)

  • PL_DHL_PARCEL. DHL Parcel Poland.

  • PARCELFORCE. Parcel Force.

  • AU_AUSTRALIA_POST_EMS. Australia Post EMS

  • US_ASCENDIA. Ascendia US.

  • ROU_POSTA. Poșta Română

  • NZ_NZ_POST. New Zealand Post Limited (NZ)

  • RPX. RPX International.

  • POSTUR_IS. Postur.

  • IE_AN_POST_SDS_EMS. Post SDS EMS Express Mail Service Ireland

  • UK_UK_MAIL. UK Mail

  • UK_FASTWAY. Fastway UK.

  • CORREOS_DE_COSTA_RICA. Correos de Costa Rica

  • MYS_CITYLINK. Citylink Malaysia.

  • PUROLATOR. Purolator.

  • IND_DOTZOT. DotZot India

  • NG_COURIERPLUS. Courier Plus Nigeria

  • HK_FOUR_PX_EXPRESS. 4PX Express Hong Kong

  • ROCKETPARCEL. Rocket Parcel International

  • CN_DHL_GLOBALFORWARDING. DHL Global Forwarding China.

  • EPARCEL_KR. EParcel Korea.

  • INPOST_PACZKOMATY. InPost Paczkomaty.

  • KOR_KOREA_POST. Korea Post.

  • CA_PUROLATOR. Purolator Canada

  • APR_72. APR 72.

  • FR_DHL_EXPRESS. DHL Express France.

  • IDN_JNE. JNE Indonesia.

  • AU_AUSTRALIA_POST_EPARCEL. Australia Post Eparcel

  • GLOBAL_ESTES. Estes Global.

  • LTU_LIETUVOS. Lietuvos paštas Lithuania.

  • THECOURIERGUY. The Courier Guy

  • BE_CHRONOPOST. Chronopost Belgium.

  • VNM_VIETNAM_POST. Vietnam Post.

  • AU_STAR_TRACK_EXPRESS. StarTrack Express Australia

  • RAM. JP RAM Shipping

carrier_name_other string
The name of the carrier for the shipment. Provide this value only if the carrier parameter is OTHER.
last_updated_time string
The date and time when the tracking information was last updated, in Internet date and time format.
Minimum length: 20.
Maximum length: 64.
Pattern: ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$.
links array (contains the link_description object)
An array of request-related HATEOAS links.
notify_buyer boolean
If true, sends an email notification to the buyer of the PayPal transaction. The email contains the tracking information that was uploaded through the API.
postage_payment_id string
The postage payment ID.
quantity integer
The quantity of items shipped.
shipment_date string
The date when the shipment occurred, in Internet date and time format.
Minimum length: 20.
Maximum length: 64.
Pattern: ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$.
tracking_number string
The tracking number for the shipment.
tracking_number_type enum
The type of tracking number.
The possible values are:
  • CARRIER_PROVIDED. A merchant-provided tracking number.

  • E2E_PARTNER_PROVIDED. A marketplace-provided tracking number.

tracking_number_validated boolean
Indicates whether the carrier validated the tracking number.

### Example python

from python_paypal_api.api import Tracking
from python_paypal_api.base import (
    ShipmentStatus,
    Carrier,
    TrackingNumberType,
    PaypalApiException
)
import logging

def py_put_tracking(composed_id: str, dictionary: dict):

    logger.info("---------------------------------")
    logger.info("Tracking > put_tracking(%s)" % str(dictionary))
    logger.info("---------------------------------")

    try:

        result = Tracking(debug=True).put_tracking(
            id=composed_id,
            body=dictionary
        )
        logger.info(result)

    except PaypalApiException as error:
        logger.error(error)


if __name__ == '__main__':
    logger = logging.getLogger("test")

    id_transaction = "9ST00334VA8626***"
    number_tracking = "443844607820"

    path = "{}-{}".format(id_transaction, number_tracking)

    update = \
    {
        "transaction_id": id_transaction,
        "tracking_number": number_tracking,
        "tracking_number_type": TrackingNumberType.CARRIER_PROVIDED.value,
        "status": ShipmentStatus.ON_HOLD.value,
        "carrier": Carrier.FEDEX.value,
        "notify_buyer": True
    }

    py_put_tracking(path, update)

### Response

A successful request returns the HTTP 204 OK status code with no JSON response body.

204 No Content
get_tracking(self, id: str, **kwargs) ApiResponse

GET /v1/shipping/trackers/{id}

Shows tracking information, by tracker ID, for a PayPal transaction.

**args:

id string required
The ID of the tracker in the transaction_id-tracking_number format.

### Example python

from python_paypal_api.api import Tracking
from python_paypal_api.base import (
    ShipmentStatus,
    Carrier,
    TrackingNumberType,
    PaypalApiException
)
import logging

def py_get_tracking(composed_id: str):

    logger.info("---------------------------------")
    logger.info("Tracking > get_tracking(%s)" % str(composed_id))
    logger.info("---------------------------------")

    try:

        result = Tracking(debug=True).get_tracking(
            id=composed_id
        )
        logger.info(result)

    except PaypalApiException as error:
        logger.error(error)

if __name__ == '__main__':
    logger = logging.getLogger("test")

    id_transaction = "9ST00334VA8626***"
    number_tracking = "443844607820"

    path = "{}-{}".format(id_transaction, number_tracking)

    py_get_tracking(path)

### Response JSON

A successful request returns the HTTP 200 OK status code and a JSON response body that shows tracking information.

{
    "transaction_id": "8MC585209K746392H",
    "tracking_number": "443844607820",
    "status": "SHIPPED",
    "carrier": "FEDEX",
    "links": [
        {
        "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/8MC585209K746392H-443844607820",
        "rel": "self"
        },
        {
        "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/8MC585209K746392H-443844607820",
        "rel": "replace",
        "method": "PUT"
        },
        {
        "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers-batch",
        "rel": "create",
        "method": "POST"
        }
    ]
}
post_tracking(self, **kwargs) ApiResponse

POST /v1/shipping/trackers-batch

Adds tracking information, with or without tracking numbers, for multiple PayPal transactions. Accepts up to 20 tracking IDs. For more information, see Add tracking information with tracking numbers and Add tracking information without tracking numbers.

**kwargs:

links array (contains the link_description object)
An array of request-related HATEOAS links.
trackers array (contains the tracker object)

### Example python

from python_paypal_api.api import Tracking
from python_paypal_api.base import (
    ShipmentStatus,
    Carrier,
    TrackingNumberType,
    PaypalApiException
)
import logging

def py_post_tracking(dictionary: dict):

    logging.info("---------------------------------")
    logging.info("Tracking > post_tracking(%s)" % str(dictionary))
    logging.info("---------------------------------")

    try:

        result = Tracking(debug=True).post_tracking(
            body=dictionary
        )
        logging.info(result)

    except PaypalApiException as error:
        logging.error(error)


if __name__ == '__main__':
    logger = logging.getLogger("test")

    id_transaction = "9ST00334VA8626***"
    number_tracking = "443844607820"

    trackers = {
        "trackers": [
            {
                "transaction_id": id_transaction,
                "tracking_number": number_tracking,
                "status": "SHIPPED",
                "carrier": "FEDEX"
            }
        ]
    }

    py_post_tracking(trackers)

### Response JSON

A successful request returns the HTTP 200 OK status code and a JSON response body that shows tracking information.

{
"tracker_identifiers":
    [
        {
            "transaction_id": "8MC585209K746392H",
            "tracking_number": "443844607820",
            "links": [
        {
            "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/8MC585209K746392H-443844607820",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/8MC585209K746392H-443844607820",
            "rel": "replace",
            "method": "PUT"
        }
    ]
},
{
"transaction_id": "53Y56775AE587553X",
"tracking_number": "443844607821",
"links":
    [
        {
            "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/53Y56775AE587553X-443844607821",
            "rel": "self",
            "method": "GET"
        },
        {
            "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers/53Y56775AE587553X-443844607821",
            "rel": "replace",
            "method": "PUT"
        }
    ]
}
],
"errors":
    [
        {
        "name": "RESOURCE_NOT_FOUND",
        "debug_id": "46735c7461f3d",
        "message": "The specified resource does not exist.",
        "details":
        [
            {
                "field": "/trackers/0/transaction_id",
                "value": "8MC585309K746392H",
                "location": "body",
                "issue": "INVALID_TRANSACTION_ID"
            }
        ]
    }
],
"links":
    [
        {
            "href": "https://api-m.sandbox.paypal.com/v1/shipping/trackers-batch",
            "rel": "self",
            "method": "POST"
        }
    ]
}

Transaction Search API

Transaction Search API

Use the Transaction Search API to get the history of transactions for a PayPal account. To use the API on behalf of third parties, you must be part of the PayPal partner network. Reach out to your partner manager for the next steps. To enroll in the partner program, see Partner with PayPal. For more information about the API, see the Transaction Search API Integration Guide.

Note

Note: To use the API on behalf of third parties, you must be part of the PayPal partner network. Reach out to your partner manager for the next steps. To enroll in the partner program, see Partner with PayPal.

class python_paypal_api.api.Transactions(*args, **kwargs)

Use the /transactions resource to list transactions.

get_list_transactions(self, **kwargs) ApiResponse

GET /v1/reporting/transactions

Lists transactions. Specify one or more query parameters to filter the transaction that appear in the response.

Note

  • If you specify one or more optional query parameters, the ending_balance response field is empty.

  • It takes a maximum of three hours for executed transactions to appear in the list transactions call.

  • This call lists transaction for the previous three years.

**kwargs:

payment_instrument_type string
Filters the transactions in the response by a payment instrument type. Value is either:
  • CREDITCARD. Returns a direct credit card transaction with a corresponding value.

  • DEBITCARD. Returns a debit card transaction with a corresponding value.

If you omit this parameter, the API does not apply this filter.
end_date string required
Filters the transactions in the response by an end date and time, in Internet date and time format. Seconds are required. Fractional seconds are optional. The maximum supported range is 31 days.
Minimum length: 20.
Maximum length: 64.
Pattern: ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$.
start_date string required
Filters the transactions in the response by a start date and time, in Internet date and time format. Seconds are required. Fractional seconds are optional.
Minimum length: 20.
Maximum length: 64.
Pattern: ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$.
balance_affecting_records_only string
Indicates whether the response includes only balance-impacting transactions or all transactions.
Value is either:
  • Y. The default. The response includes only balance transactions.

  • N. The response includes all transactions.

fields string
Indicates which fields appear in the response. Value is a single field or a comma-separated list of fields. The transaction_info value returns only the transaction details in the response. To include all fields in the response, specify fields=all. Valid fields are:
  • transaction_info. The transaction information. Includes the ID of the PayPal account of the payee, the PayPal-generated transaction ID, the PayPal-generated base ID, the PayPal reference ID type, the transaction event code, the date and time when the transaction was initiated and was last updated, the transaction amounts including the PayPal fee, any discounts, insurance, the transaction status, and other information about the transaction.

  • payer_info. The payer information. Includes the PayPal customer account ID and the payer’s email address, primary phone number, name, country code, address, and whether the payer is verified or unverified.

  • shipping_info. The shipping information. Includes the recipient’s name, the shipping method for this order, the shipping address for this order, and the secondary address associated with this order.

  • auction_info. The auction information. Includes the name of the auction site, the auction site URL, the ID of the customer who makes the purchase in the auction, and the date and time when the auction closes.

  • cart_info. The cart information. Includes an array of item details, whether the item amount or the shipping amount already includes tax, and the ID of the invoice for PayPal-generated invoices.

  • incentive_info. An array of incentive detail objects. Each object includes the incentive, such as a special offer or coupon, the incentive amount, and the incentive program code that identifies a merchant loyalty or incentive program.

  • store_info. The store information. Includes the ID of the merchant store and the terminal ID for the checkout stand in the merchant store.

page integer
The zero-relative start index of the entire list of items that are returned in the response. So, the combination of page=1 and page_size=20 returns the first 20 items.
Minimum value: 1.
Maximum value: 2147483647.
page_size integer
The number of items to return in the response. So, the combination of page=1 and page_size=20 returns the first 20 items. The combination of page=2 and page_size=20 returns the next 20 items.
Minimum value: 1.
Maximum value: 500.
store_id string
Filters the transactions in the response by a store ID.
terminal_id string
Filters the transactions in the response by a terminal ID.
transaction_amount string
Filters the transactions in the response by a gross transaction amount range. Specify the range as <start-range> TO <end-range>, where <start-range> is the lower limit of the gross PayPal transaction amount and <end-range> is the upper limit of the gross transaction amount. Specify the amounts in lower denominations. For example, to search for transactions from $5.00 to $10.05, specify [500 TO 1005].

Note

The values must be URL encoded.

transaction_currency string
Filters the transactions in the response by a three-character ISO-4217 currency code for the PayPal transaction currency.
transaction_id string
Filters the transactions in the response by a PayPal transaction ID. A valid transaction ID is 17 characters long, except for an order ID, which is 19 characters long.

Note

A transaction ID is not unique in the reporting system. The response can list two transactions with the same ID. One transaction can be balance affecting while the other is non-balance affecting.

Minimum length: 17.
Maximum length: 19.
transaction_status string
Filters the transactions in the response by a PayPal transaction status code. Value is:

Status code

Description

D

PayPal or merchant rules denied the transaction.

P

The transaction is pending. The transaction was created but waits for another payment process to complete, such as an ACH transaction, before the status changes to S.

S

The transaction successfully completed without a denial and after any pending statuses.

V

A successful transaction was reversed and funds were refunded to the original sender.

transaction_type string
Filters the transactions in the response by a PayPal transaction event code. See Transaction event codes.
Returns:

ApiResponse

### Example python

from python_paypal_api.api import Transactions
from python_paypal_api.base import PaypalApiException
import logging
from datetime import datetime, timezone

def py_get_list_transactions(**kwargs):

    logger.info("---------------------------------")
    logger.info("Transactions > py_get_list_transactions({})".format(kwargs))
    logger.info("---------------------------------")

    try:

        result = Transactions(debug=True).get_list_transactions(
            **kwargs
        )
        logger.info(result)

    except PaypalApiException as error:
        logger.error(error)


if __name__ == '__main__':

    logger = logging.getLogger("test")
    date_start = datetime(2023, 2, 1, 0, 0, 0, 0, timezone.utc).isoformat()
    date_end = datetime(2023, 3, 1, 0, 0, 0, 0, timezone.utc).isoformat()

    py_get_list_transactions(
        page_size=1,
        start_date=date_start,
        end_date=date_end
    )

### Response JSON

A successful request returns the HTTP 200 OK status code and a JSON response body that lists transactions.

{
    'account_number': '2LBUCGLCSB***',
    'end_date': '2023-03-01T00:00:00+0000',
    'last_refreshed_datetime': '2023-03-12T01:59:59+0000',
    'links': [
        {
        'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=19',
        'method': 'GET',
        'rel': 'last'
        },
        {
        'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=2',
        'method': 'GET',
        'rel': 'next'
        },
        {
        'href': 'https://api.sandbox.paypal.com/v1/reporting/transactions?start_date=2023-02-01T00%3A00%3A00%2B00%3A00&end_date=2023-03-01T00%3A00%3A00%2B00%3A00&page_size=1&page=1',
        'method': 'GET',
        'rel': 'self'
        }
    ],
    'page': 1,
    'start_date': '2023-02-01T00:00:00+0000',
    'total_items': 19,
    'total_pages': 19,
    'transaction_details': [
        {
        'transaction_info':
            {
            'available_balance':
                {
                    'currency_code': 'EUR',
                    'value': '165488.69'
                },
                'custom_field': 'S1121674440646-1563665460',
                'ending_balance':
                {
                    'currency_code': 'EUR',
                    'value': '165488.69'
                },
                'paypal_account_id': 'UYZPMCTQDV***',
                'paypal_reference_id': '4G8384171L5786***',
                'paypal_reference_id_type': 'TXN',
                'protection_eligibility': '02',
                'transaction_amount':
                {
                    'currency_code': 'EUR',
                    'value': '-50.00'
                },
                'transaction_event_code': 'T1110',
                'transaction_id': '18670957S08679***',
                'transaction_initiation_date': '2023-02-12T11:52:33+0000',
                'transaction_status': 'P',
                'transaction_updated_date': '2023-02-12T11:52:33+0000'
            }
        }
    ]
}
get_balances(self, **kwargs) ApiResponse

GET /v1/reporting/balances

List all balances. Specify date time to list balances for that time that appear in the response.

Note

  • It takes a maximum of three hours for balances to appear in the list balances call.

  • This call lists balances upto the previous three years.

**kwargs:

as_of_time string
List balances in the response at the date time provided, will return the last refreshed balance in the system when not provided.
Minimum length: 20.
Maximum length: 64.
Pattern: ^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])[T,t]([0-1][0-9]|2[0-3]):[0-5][0-9]:([0-5][0-9]|60)([.][0-9]+)?([Zz]|[+-][0-9]{2}:[0-9]{2})$.
currency_code string
Filters the transactions in the response by a three-character ISO-4217 currency code for the PayPal transaction currency.
Minimum length: 3.
Maximum length: 3.

### Example python

from python_paypal_api.api import Transactions
from python_paypal_api.base import PaypalApiException
import logging
from datetime import datetime, timezone

def py_get_balances(**kwargs):

    logger.info("---------------------------------")
    logger.info("Transactions > py_get_balances({})".format(kwargs)))
    logger.info("---------------------------------")

    try:

        result = Transactions(debug=True).get_balances(
            **kwargs
        )
        logger.info(result)

    except PaypalApiException as error:
        logger.error(error)


if __name__ == '__main__':

    logger = logging.getLogger("test")
    date_start = datetime(2023, 2, 1, 0, 0, 0, 0, timezone.utc).isoformat()
    py_get_balances(
        as_of_time=date_start,
        currency_code="USD"
    )

### Response JSON

A successful request returns the HTTP 200 OK status code and a JSON response body that lists balances.

{
    'account_id': '2LBUCGLCSB***',
    'as_of_time': '2023-03-12T01:59:59Z',
    'balances': [
        {
            'available_balance':
            {
                'currency_code': 'USD',
                'value': '1304.05'
            },
            'currency': 'USD',
             'total_balance':
            {
                'currency_code': 'USD',
                 'value': '1304.05'
            },
            'withheld_balance':
            {
                'currency_code': 'USD',
                 'value': '0.00'
            }
        }
    ],
    'last_refresh_time': '2023-03-12T01:59:59Z'
}

Catalog Products API

Catalog Products API

Merchants can use the Catalog Products API to create products, which are goods and services.

class python_paypal_api.api.Products(*args, **kwargs)

Use /products resource to create and manage products.

list_products(self, **kwargs) ApiResponse

GET /v1/catalogs/products

Lists products.

**kwargs:

page integer
A non-zero integer which is the start index of the entire list of items that are returned in the response. So, the combination of page=1 and page_size=20 returns the first 20 items. The combination of page=2 and page_size=20 returns the next 20 items.
Minimum value: 1.
Maximum value: 100000.
page_size integer
The number of items to return in the response.
Minimum value: 1.
Maximum value: 20.
total_required boolean
Indicates whether to show the total items and total pages in the response.
get_product(self, productId: str, **kwargs) ApiResponse

GET /v1/catalogs/products/{product_id}

update_product(self, productId: str, **kwargs) ApiResponse

PATCH /v1/catalogs/products/{product_id}

update_product_helper(self, productId: str, **kwargs) ApiResponse

PATCH /v1/catalogs/products/{product_id}

post_product(self, **kwargs) ApiResponse

POST /v1/catalogs/products

post_product_helper(self, body: str, **kwargs) ApiResponse

POST /v1/catalogs/products

Disclaimer

MIT License

Copyright (c) 2021 denisneuf

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

New in version 0.1.1: The Products is added replacing Catalog for best naming The Config.yaml is now the default for config credentials

from python_paypal_api.api import Identity, Products
from python_paypal_api.base import PaypalApiException
import logging


def py_list_products(**kwargs):

    logging.info("---------------------------------")
    logging.info("Catalog > list_products()")
    logging.info("---------------------------------")

    credentials = dict(
        client_id="your-client-id",
        client_secret="your-client-secret",
        client_mode="your-mode" # PRODUCTION OR SANDBOX(default)
    )

    try:

        result = Products(credentials=credentials, store_credentials=False, debug=True).list_products(
            **kwargs
        )
        document_dict = result.payload
        logging.info(result)

    except Exception as error:
        logging.info(error)


def py_get_userinfo():

    logging.info("---------------------------------")
    logging.info("Identity > py_get_userinfo")
    logging.info("---------------------------------")

    try:

        # result = Identity(account="production", store_credentials=True, debug=True).get_userinfo(
        result = Identity(debug=True).get_userinfo(
        )
        logging.info(result)

    except PaypalApiException as error:
        logging.error(error)

    except Exception as error:
        logging.info(error)

if __name__ == '__main__':

    logger = logging.getLogger("test")
    
    py_get_userinfo()
    
    py_list_products(
        total_required=True,
        page_size=1,
        page=2
    )