Package Tracking

Server-side configuration

Important
Your integration may be impacted by upcoming certificate changes. Visit our best practices guide to learn more.

1. Place transaction

  1. Python
result = gateway.transaction.sale({
          "amount": "100.00",
          "payment_method_nonce": nonce_from_the_client,
          "purchase_order_number": "12345",
          "tax_amount": "5.00",
          "shipping_amount": "5.00",
          "discount_amount": "1.00",
          "ships_from_postal_code": "60654",
          "shipping": {
            "first_name": "Clinton",
            "last_name": "Ecker",
            "street_address": "1234 Main Street",
            "extended_address": "Unit 222",
            "locality": "Chicago",
            "region": "IL",
            "postal_code": "60654",
            "country_code_alpha3": "USA"
          },
          "line_items": [
            {
              "name": "Product",
              "kind": braintree.TransactionLineItem.Kind.Debit,
              "quantity": "10.0000",
              "unit_amount": "9.5000",
              "total_amount": "95.00",
              "product_code": "54321",     
              "upc_code": "112345678912", # new field
              "upc_type": braintree.TransactionLineItem.UpcType.UpcA, # new field
              "url": "https://example.com", # new field
              "image_url": "https://example.com", # new field
            }
          ]
        })

2. Create tracking for transaction after submitting for settlement:

  1. Python
# Send the package tracking request for the transaction
        package_result = Braintree::Transaction.package_tracking( 
            transaction.id, 
            { 
                "carrier": "UPS", 
                "notify_payer": True, 
                "tracking_number": "1Z5338FF0107231059", 
                # Line items are optional 
                "line_items": [ 
                    { 
                        "product_code": "ABC 01",                         "name": "Product Name",                         "quantity": "1",                         "description": "Product Description",                         "upc_ode": "112345678912", # new field 
                        "upc_type": braintree.TransactionLineItem.UpcType.UpcA, # new field 
                        "url": "https://example.com", # new field 
                        "image_url": "https://example.com", # new field 
                    },
                    { 
                        "product_code": "ABC 02", 
                        "name": "Another Product Name",
                        "quantity": "2", 
                        "description": "Another Product Description",
                    }
                  ],
                }
            )
            
        packages = package_result.transaction.packages
        carrier = packages[0].carrier
        tracking_number = packages[0].tracking_number

        # Additional note: The PayPal tracker ID will not be immediately available in response to 
        # package_tracking() but should be there when merchant performs Braintree::Transaction.find()
        # request at a later stage.

3. Retrieve transactions with package trackers:

  1. Python
# In order to get more details about an individual package,
        # replace 0 with the corresponding element number (e.g., packages[1]):

        transaction = Braintree::Transaction.find(transaction.id)

        id = transaction.packages[0].id
        tracking_number = transaction.packages[0].tracking_number
        carrier = transaction.packages[0].carrier
        paypal_tracker_id = transaction.packages[0].paypal_tracker_id

If you accept cookies, we’ll use them to improve and customize your experience and enable our partners to show you personalized PayPal ads when you visit other sites. Manage cookies and learn more