PayPal

Server-Side Implementationanchor

GraphQL
Click here to view the server-side implementation using GraphQL.

Creating transactionsanchor

Once the customer has successfully authenticated with PayPal, include the payment_method_nonce parameter in the Transaction: Sale call on your server.

Using device dataanchor

If the PayPal transaction was initiated from a Vault record and is not a recurring transaction, collect device data from the client and include the collected client device data via the top-level device_data parameter. Doing so will help reduce decline rates.

Below includes an example call with relevant PayPal parameters and device data:

  1. Python
result = gateway.transaction.sale({
    "amount" : request.form["amount"],
    "payment_method_nonce" : request.form["payment_method_nonce"],
    "device_data": request.form["device_data"],
    "order_id" : "Mapped to PayPal Invoice Number",
    "options" : {
        "submit_for_settlement": True,
        "paypal": {
            "custom_field" : "PayPal custom field",
            "description" : "Description for PayPal email receipt",
      },
    },
})
if result.is_success:
    "Success ID: ".format(result.transaction.id)
else:
    format(result.message)

See the recurring transactions section below for more information on recurring transactions.

If you want to create a new payment method in the Vault upon a successful transaction , use the options-store_in_vault_on_success option. If a customer_id is not included, a new customer will be created. If you want to include a PayPal Billing Agreement with the vaulted payment method, use the Checkout with Vault flow.

Currency supportanchor

The customer will be charged in the currency associated with the merchant_account_id passed in the Transaction: Sale call. We support all currencies that PayPal REST APIs support.

For details on accepting foreign currencies with PayPal, see our PayPal account setup guide.

Shipping addressesanchor

If you've collected a shipping address, you will need to pass that along with the Transaction: Sale call. The following fields are required when passing a shipping address for PayPal transactions:

For details on how to add a shipping address when creating a transaction, see the transaction reference full example . PayPal validates the shipping address, so it must follow the PayPal address conventions.

When creating a transaction using a PayPal account stored in the Vault, see the example of using stored addresses as well as the billing_address_id and shipping_address_id parameters.

Seller Protectionanchor

By passing a shipping address, you may also be eligible for PayPal Seller Protection. You can check the status of Seller Protection as follows:

  1. Python
transaction = gateway.transaction.find("the_transaction_id")

transaction.paypal_details.seller_protection_status
# "ELIGIBLE"

Settlementanchor

Unlike most payment types that settle in batches, we capture PayPal funds immediately when you submit each transaction for settlement.

Capturing greater than authorization amountanchor

You can't settle more than the authorized amount unless your industry and processor support settlement adjustment (settling a certain percentage over the authorized amount); contact us for details. If your capture amount exceeds the allowable limit you will receive the respective settlement response code.

Capturing multiple partial amounts against the same authorizationanchor

If you send physical goods to customers in multiple shipments, you can capture the total authorized amount across multiple partial settlements using Transaction: Submit For Partial Settlement.

Recurring transactionsanchor

Use the transaction_source parameter with a value of recurring if the customer is not present when you create a PayPal transaction from their Vault record. Typical examples are a recurring subscription or an automatic top-up charge.

note

You won't need to do this if you're using our recurring billing system – our logic creates subscription transactions with this parameter automatically. If you've built your own recurring logic, though, be sure your transaction sale calls include the recurring parameter.

  1. Python
result = gateway.transaction.sale({
  "amount": "1000.00",
  "payment_method_token": "the_token",
  "transaction_source": "recurring",
  "options" : {
    "submit_for_settlement": True,
  },
})

See also


Next Page: Testing and Go Live