Package: airbyte-source-paypal-transaction
Paypal-Transaction source connectorThis is the repository for the Paypal-Transaction source connector, written in Python.
For information about how to use this connector within Airbyte, seethe documentation.Local developmentPrerequisitesPython (~=3.9)Poetry (~=1.7) - installation instructionsherePaypal Client ID and Client SecretIf you are going to use the data generator scripts you need to setup yourPaypal Sandbox and a Buyer user in your sandbox, to simulate the data. YOu cna get that information in theApps & Credentials page.Buyer UsernameBuyer PasswordPayer ID (Account ID)Installing the connectorFrom this connector directory, run:poetryinstall--withdevCreate credentialsIf you are a community contributor, follow the instructions in thedocumentationto generate the necessary credentials. Then create a filesecrets/config.jsonconforming to thesource_paypal_transaction/spec.yamlfile.
Note that any directory namedsecretsis gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
Seesample_files/sample_config.jsonfor a sample config file.You must have created your credentials under thesecrets/folderFor the read command, you can create separate catalogs to test the streams individually. All catalogs are under the folderintegration_tests. Select the one you want to test with the read command.Locally running the connectorpoetry run source-paypal-transaction spec
poetry run source-paypal-transaction check --config secrets/config.json
poetry run source-paypal-transaction discover --config secrets/config.json
#Example with list_payments catalog and the debug flag
poetry run source-paypal-transaction read --config secrets/config.json --catalog integration_tests/configured_catalog_list_payments.json --debugRunning unit testsTo run unit tests locally, from the connector directory run:poetry run pytest unit_testsBuilding the docker imageInstallairbyte-ciRun the following command to build the docker image:Installing the connectorFrom this connector directory, run:poetryinstall--withdevCustomizing our build processWhen contributing on our connector you might need to customize the build process to add a system dependency or set an env var.
You can customize our build process by adding abuild_customization.pymodule to your connector.
This module should contain apre_connector_installandpost_connector_installasync function that will mutate the base image and the connector container respectively.
It will be imported at runtime by our build process and the functions will be called if they exist.Here is an example of abuild_customization.pymodule:from__future__importannotationsfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:# Feel free to check the dagger documentation for more information on the Container object and its methods.# https://dagger-io.readthedocs.io/en/sdk-python-v0.6.4/fromdaggerimportContainerAn image will be available on your host with the tagairbyte/source-paypal-transaction:dev.Running as a docker containerThen run any of the connector commands as follows:docker run --rm airbyte/source-paypal-transaction:dev spec
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-paypal-transaction:dev check --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-paypal-transaction:dev discover --config /secrets/config.json
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integration_tests airbyte/source-paypal-transaction:dev read --config /secrets/config.json --catalog /integration_tests/configured_catalog.jsonRunning our CI test suiteYou can run our full test suite locally usingairbyte-ci:airbyte-ciconnectors--name=source-paypal-transactiontestIf you are testing locally, you can use your local credentials (config.json file) by using--use-local-secretsairbyte-ciconnectors--namesource-paypal-transaction--use-local-secretstestCustomizing acceptance TestsCustomizeacceptance-test-config.ymlfile to configure acceptance tests. SeeConnector Acceptance Testsfor more information.
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.Running Unit tests locallyTo run unit tests locally, form the rootsource_paypal_transactiondirectory run:python-mpytestunit_testTest changes in the sandboxIf you have aPaypal Sandboxyou will be able to use some APIs to create new data and test how data is being created in your destinaiton and choose the best syn strategy that suits better your use case.
Some endpoints will require special permissions on the sandbox to update and change some values.In thebinfolder you will find several data generator scripts:disputes_generator.py:Update dispute: Uses thePATCHmethod of thehttps://api-m.paypal.com/v1/customer/disputes/{dispute_id}endpoint. You need the ID and create a payload to pass it as an argument. See more informationhere.pythondisputes_generator.pyupdateDISPUTE_ID''[{"op":"replace","path":"/reason","value":"The new reason"}]'Update Evidence status: Uses thePOSTmethod of thehttps://api-m.paypal.com/v1/customer/disputes/{dispute_id}/require-evidenceendpoint. You need the ID and select an option to pass it as an argument. See more informationherepythonupdate_dispute.pyrequire-evidenceDISPUTE_IDSELLER_EVIDENCEinvoices.py:Create draft invoice: Uses thePOSTmethod of thehttps://api-m.sandbox.paypal.com/v2/invoicing/invoicesendpoint. It will automatically generate an invoice (no need to pass any parameters). See more informationhere.pythoninvoices.pycreate_draftSend a Draft Invoice: Uses thePOSTmethod of thehttps://api-m.sandbox.paypal.com/v2/invoicing/invoices/{invoice_id}/sendendpoint. You need the Invoice ID, a subject and a note (just to have something to update) and an email as an argument. See more informationherepythoninvoices.pysend_draft--invoice_id"INV2-XXXX-XXXX-XXXX-XXXX"--subject"Your Invoice Subject"--note"Your custom note"--additional_recipientsexample@email.compayments_generator.py:Partially update payment: Uses thePATCHmethod of thehttps://api-m.paypal.com/v1/payments/payment/{payment_id}endpoint. You need the payment ID and a payload with new values. (no need to pass any parameters). See more informationhere.pythonscript_name.pyupdatePAYMENT_ID'[{"op": "replace", "path": "/transactions/0/amount", "value": {"total": "50.00", "currency": "USD"}}]'paypal_transaction_generator.py:Make sure you have thebuyer_username,buyer_passwordandpayer_idin your config file. You can get the sample configuratin in thesample_config.json.Generate transactions: This uses Selenium, so you will be prompted to your account to simulate the complete transaction flow. You can add a number at the end of the command to do more than one transaction. By default the script runs 3 transactions.NOTE: Be midnfu of the number of transactions, as it will be interacting with your machine, and you may not be able to use it while creating the transactionspythonpaypal_transaction_generator.py[NUMBER_OF_DESIRED_TRANSACTIONS]product_catalog.py:Create a product: Uses thePOSTmethod of thehttps://api-m.sandbox.paypal.com/v1/catalogs/productsendpoint. You need to add the description and the category in the command line. For the proper category see more informationhere.pythonproduct_catalog.py--actioncreate--description"YOUR DESCRIPTION"--categoryPAYPAL_CATEGORYUpdate a product: Uses thePATCHmethod of thehttps://developer.paypal.com/docs/api/catalog-products/v1/#products_patchendpoint. You need the product ID, a description and the Category as an argument. See more informationherepythonproduct_catalog.py--actionupdate--product_idPRODUCT_ID--update_payload'[{"op": "replace", "path": "/description", "value": "My Update. Does it changes it?"}]'Dependency ManagementAll of your dependencies should go insetup.py, NOTrequirements.txt. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
We split dependencies between two groups, dependencies that are:required for your connector to work need to go toMAIN_REQUIREMENTSlist.required for the testing need to go toTEST_REQUIREMENTSlistAll of your dependencies should be managed via Poetry.To add a new dependency, run:poetryadd<package-name>Please commit the changes topyproject.tomlandpoetry.lockfiles.Publishing a new version of the connectorYou've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?Make sure your changes are passing our test suite:airbyte-ci connectors --name=source-paypal-transaction testBump the connector version (please followsemantic versioning for connectors):bump thedockerImageTagvalue in inmetadata.yamlbump theversionvalue inpyproject.tomlMake sure themetadata.yamlcontent is up to date.Make sure the connector documentation and its changelog is up to date (docs/integrations/sources/paypal-transaction.md).Create a Pull Request: useour PR naming conventions.Pat yourself on the back for being an awesome contributor.Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.