In this section, we present how to connect PayPal to MindsDB.

PayPal is an online payment system that makes paying for things online and sending and receiving money safe and secure.

Data from PayPal can be utilized within MindsDB to train models and make predictions about your transactions.

Connection

This handler is implemented using PayPal-Python-SDK, the Python SDK for PayPal RESTful APIs.

The required arguments to establish a connection are as follows:

  • mode: The mode of the PayPal API. Can be sandbox or live.
  • client_id: The client ID of the PayPal API.
  • client_secret: The client secret of the PayPal API.

To connect to PayPal using MindsDB, the following CREATE DATABASE statement can be used:

CREATE DATABASE paypal_datasource
WITH ENGINE = 'paypal',
PARAMETERS = {
  "mode": "your-paypal-mode",
  "client_id": "your-paypal-client-id",
  "client_secret": "your-paypal-client-secret"
};

Check out this guide on how to create client credentials for PayPal.

Usage

Now, you can query PayPal as follows:

Payments:

SELECT * FROM paypal_datasource.payments

Invoices:

SELECT * FROM paypal_datasource.invoices

Subscriptions:

SELECT * FROM paypal_datasource.subscriptions

Orders:

SELECT * FROM paypal_datasource.orders

Payouts:

SELECT * FROM paypal_datasource.payouts

You can also run more advanced queries on your data:

Payments:

SELECT intent, cart
FROM paypal_datasource.payments
WHERE state = 'approved'
ORDER BY id
LIMIT 5

Invoices:

SELECT invoice_number, total_amount
FROM paypal_datasource.invoices
WHERE status = 'PAID'
ORDER BY total_amount DESC
LIMIT 5

Subscriptions:

SELECT id, state, name 
FROM paypal_datasource.subscriptions 
WHERE state ="CREATED" 
LIMIT 5

Orders:

SELECT id, state, amount 
FROM paypal_datasource.orders 
WHERE state = 'APPROVED'
ORDER BY total_amount DESC
LIMIT 5

Payouts:

SELECT payout_batch_id, amount_currency, amount_value
FROM paypal_datasource.payouts
ORDER BY amount_value DESC
LIMIT 5

Supported Tables

The following tables are supported by the PayPal handler:

  • payments: payments made.
  • invoices: invoices created.
  • subscriptions: subscriptions created.
  • orders: orders created.
  • payouts: payouts made.