PayPal for Partners Demo

REST API with Javascript SDK

Server-side PHP Integration
Readme

Connected: Disbursement



Readme


Important: PayPal for Marketplaces is a limited-release solution at this time. It is available to select partners for approved use cases. For more information, reach out to your PayPal account manager or contact us.

Getting Started

This code sample serves as a reference for PayPal for Marketplaces APIs. You will need your own PayPal Sandbox Partner credentials to run the code sample. Once you have your Partner credentials, refer to the steps below:

Sandbox Buyer Accounts

The following Sandbox Buyer Accounts are provided for convenience. Use these for testing the buyer's flow. DO NOT USE the merchant/seller's account just created in onboarding.

Email Password
jack_potter@buyer.com 123456789
jen_jones@buyer.com qwer1234
jack_chase@buyer.com qwer1234

Code Sample Demonstration


Connected Path:
A marketplace model in which each individual merchant must have a PayPal account.

  1. To run the code sample, first enter your own Partner credentials in paypalConfig.php
    • Update PARTNER_ID with your Partner Payer ID.
    • Update PARTNER_BN_CODE with your PayPal Partner Attribution ID.
    • Update PARTNER_CLIENT_ID with the Partner REST App Client Id and PARTNER_CLIENT_SECRET with the corresponding Client Secret.
    • Update PARTNER_EMAIL with your Partner Account Email.
  2. Verify that you have everything set up correctly by running PhP unit tests:
    • wget https://phar.phpunit.de/phpunit-5.7.phar (To get PHPUnit 5.7)
    • mv phpunit-5.7.phar /usr/local/bin/phpunit
    • chmod a+x /usr/local/bin/phpunit
    • phpunit --version (should return "PHPUnit 5.7.23 by Sebastian Bergmann and contributors.")
    • phpunit Tests/unit_test.php
  3. Click on the "Onboarding" link in the "Connected Path" section of the web page.
    This step will show you the merchant onboarding experience for the Connected Path, with most form field values pre-filled already.
    • Click the "Call Prefill API" button.(Refer to the isu_2.php file for the API calls.)
    • Click the "Enable PayPal" link to start the merchant's onboarding experience.
    • It will open a mini-browser to start the merchant's onboarding experience. (Refer to isu_2.php to understand the script needed for the mini-browser/in-context experience.)
    • Enter values for the blank entries like password, last four digits of SSN etc. For personal information, please use dummy information while running the demo.
    • Once the flow is completed, you will see a success screen in the mini-browser. It will show the email-address of the onboarded seller.
      Please note down this email address. You will need this in the Checkout flow of the Order API request.
      Note: You may onboard a seller with a specific email address by changing the "email_address" parameter in the Onboarding request call.
    • Follow the above processs to onboard one more seller.
  4. Confirm the Seller Sandbox Emails for the Onboarded sellers. And update the seller emails in paypalConfig.php as follows:
    • Update SELLER_1_EMAIL and SELLER_2_EMAIL with emails for two sellers onboarded using Onboarding flow (noted from the previous step).
    • Update SELLER_1_PAYER_ID and SELLER_2_PAYER_ID with the Payer IDs for the seller accounts. You can find the Payer id as the "Merchant account ID" found in Sandbox account business profile page.
    • You can now try an Order call by purchasing items from these two sellers in the Checkout flow explained below.
  5. Click the "Checkout" box in the "Connected Path Overview" section of the web page.
    • Click on the Yellow "PayPal Checkout" button. (Refer the checkout_1.php file for Checkout.js v4 script to render the Checkout button.
      Refer to checkout_2.php for the setting risk transaction context and create order API calls.)
    • It will open a mini-browser with a login screen.
    • Use the sample Sandbox Buyer accounts provided on index.php page or create new buyer Sandbox accounts here.
    • On the Login page, enter Sandbox Buyer credentials and click the "Login" button.
    • On the next page, click "Pay Now" button. (Refer to checkout_3.php for the pay for order API call.)
    • You will now land on the Order Confirmation page of the code sample.
    • Now, the "Disburse" option box will be enabled on the right side of the web page.
  6. Once Checkout is complete, you can run Disburse and/or the Refund flows. Click the 'Disburse' box in the "Connected Path Overview" section of the web page.
    • Once on the page, click the "Call Disburse API" button. (Refer to disburse_2.php for the pay for the get order status and disburse API calls.)
    • A disburse completion page will be displayed after calling the Disburse API.
    • Note: If you see the message "Capture ID is not yet generated", wait a few moments and then refresh the page. The Capture ID for a purchase unit could take a few moments to get generated.
  7. Once you've tried the Disburse flow, the "Refund" flow is available to try next. Click on the "Refund" box in the "Connected Path Overview" section of the web page.
    • Once on the page, click the "Call Refund API" button. (Refer to refund_2.php for the pay for the get order status and refund API calls.)
    • A refund completion page will be displayed after calling the Refund API.
    • Note: If you see the message "Capture ID is not yet generated",wait a few moments and then refresh the page. The Capture ID for a purchase unit could take a few moments to get generated.
  8. You can click the "Return Home" link at any time to go back to the code sample homepage.
*Note: The connected6Data.php has the data needed for the API calls and connected6.php has the functions to call APIs.


Documentation

PayPal for Marketplaces: https://developer.paypal.com/docs/marketplaces/pp4mp/