Skip to main content

PayPal Direct

Last updated: 30-Dec-2021
Rate this article:

Overview

To process PayPal payments, we provide API users with our PayPal Direct checkout flow which can be accessed by simply adding an additional parameter paypal_direct with a value of “Y” to a standard Standard Checkout payment form or link. As long as all of the required parameters are passed, the user will be redirected directly to PayPal to complete their payment.

Example PayPal Direct Form

<form action="https://www.2checkout.com/checkout/purchase" method="post">
  <input name="sid" type="hidden" value="1817037">
  <input name="mode" type="hidden" value="2CO">
  <input name="return_url" type="hidden" value="https://www.example.com/cart/">
  <input name="li_0_name" type="hidden" value="invoice123">
  <input name="li_0_price" type="hidden" value="25.99">
  <input name="card_holder_name" type="hidden" value="Checkout Shopper">
  <input name="street_address" type="hidden" value="123 Test Address">
  <input name="street_address2" type="hidden" value="Suite 200">
  <input name="city" type="hidden" value="Columbus">
  <input name="state" type="hidden" value="OH">
  <input name="zip" type="hidden" value="43228">
  <input name="country" type="hidden" value="USA">
  <input name="email" type="hidden" value="example@2co.com">
  <input name="phone" type="hidden" value="614-921-2450">
  <input name="ship_name" type="hidden" value="Gift Receiver">
  <input name="ship_street_address" type="hidden" value="1234 Address Road">
  <input name="ship_street_address2" type="hidden" value="Apartment 123">
  <input name="ship_city" type="hidden" value="Columbus">
  <input name="ship_state" type="hidden" value="OH">
  <input name="ship_zip" type="hidden" value="43235">
  <input name="ship_country" type="hidden" value="USA">
  <input name="paypal_direct" type="hidden" value="Y">
  <input type="submit" value="Submit Payment">
</form>

If you use this example on your webpage, you need to change “1817037” to your 2Checkout Seller ID and “https://www.example.com/cart/” to your return URL (URL for unsuccessful purchase).

Note: PayPal direct cannot be used with demo sales, either from passing in a demo parameter or setting your account to demo mode.

Return Process

If the sale is successful, the buyer will be returned to your approved URL through the return method that you have defined in your 2Checkout account like any normal 2Checkout sale.

If the user cancels the PayPal payment or the payment fails, they will be brought back to the URL that you define using the `return_url` parameter with the `paypal_direct` parameter appended to the query string indicating whether the payment failed for was canceled. This way you can handle your response to the user appropriately.

Example PayPal Direct failure URL

https://www.example.com/cart?paypal_direct=fail

Example PayPal Direct cancel URL

https://www.example.com/cart?paypal_direct=cancel

Note: PayPal Direct is only available 2Checkout accounts that are using the Payment API.

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo