Payment Transactions Integration Guide

DOCS

Last updated: Sept 23rd, 9:22pm

Merchants can use the Payment Transactions API to handle post-payment actions.

Overview

A merchant can call this API to cancel a transaction that a customer has not accepted.

You can:

  • Cancel a sale or authorized payment transaction.
  • Void a refund transaction.

You cancel a transaction by the PayPal-Request-Id for the transaction.

If the cancellation contains an unknown transaction type, a validation error occurs.

Integration steps

To use the Payment Transactions REST API, complete these integration steps:

1. Required Set up your development environment.
2. Required Cancel transaction.

Set up your development environment

Before you can integrate Payment Transactions, you must set up your development environment. After you get a token that lets you access protected REST API resources, you create sandbox accounts to test your web and mobile apps. For details, see Get started.

Then, return to this page to integrate Payment Transactions.

Cancel transaction

As a merchant, you can cancel an authorization, refund, or payment transaction when you do not hear anything from PayPal for customer transactions, such as an authorized payment for a sale or an order or a refund. In the request, pass the PayPal-Request-Id header.

The API cancels and refunds a authorized payment or voids a refund.

This sample request cancels an authorized payment transaction with the Paypal-Request-Id value of 1212:

    1curl -v -X POST https://api-m.sandbox.paypal.com/v1/payments/cancel-payment \
    2 -H "Content-Type: application/json" \
    3 -H "Authorization: Bearer <Access-Token>" \
    4 -d '{
    5 "request_id": "1212",
    6 "payment_type": "AUTHORIZATION"
    7}'

    The response shows details for the cancelled or voided transaction and includes a link that enables you to view more details about the transaction:

      1{
      2 "request_id": "1212",
      3 "transaction_type": "AUTHORIZATION",
      4 "authorization":
      5 {
      6 "id": "8HS992789X1370624",
      7 "create_time": "2015-05-06T09:12:13Z",
      8 "update_time": "2015-05-06T09:13:57Z",
      9 "amount":
      10 {
      11 "total": "20.00",
      12 "currency": "USD",
      13 "details":
      14 {
      15 "subtotal": "17.50",
      16 "tax": "1.30",
      17 "shipping": "1.20"
      18 }
      19 },
      20 "state": "voided"
      21 },
      22 "links": [{
      23 "href": "https://api-m.sandbox.paypal.com/v1/payments/authorization/8HS992789X1370624",
      24 "rel": "self",
      25 "method": "GET"
      26 }]
      27}

      Next