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
- PHP
$result = $gateway->transaction()->sale([
'amount' => '100.00',
'paymentMethodNonce' => nonceFromTheClient,
'purchaseOrderNumber' => '12345',
'taxAmount' => '5.00',
'shippingAmount' => '1.00',
'discountAmount' => '0.00',
'shipsFromPostalCode' => '60654',
'shipping' => [
'firstName' => 'Clinton',
'lastName' => 'Ecker',
'streetAddress' => '1234 Main Street',
'extendedAddress' => 'Unit 222',
'locality' => 'Chicago',
'region' => 'IL',
'postalCode' => '60654',
'countryCodeAlpha3' => 'USA'
],
'lineItems' => [
[
'name' => 'Product',
'kind' => BraintreeTransactionLineItem::DEBIT,
'quantity' => '10.0000',
'unitAmount' => '9.5000',
'totalAmount' => '95.00',
'productCode' => '54321',
'upcCode' => '12345678012',
// new field
'upcType' => BraintreeTransactionLineItem::UPC_A,
// new field
'imageUrl' => 'https://example.com/product1.jpeg' // new field
]
]
);
2. Create tracking for transaction after submitting for settlement:
- PHP
<?php
function sampleIntegration() {
// Send the package tracking request for the transaction
$packageResult = Braintree\Transaction::packageTracking(
$transactionId,
// Create a Package Tracking request with optional line items
[
'carrier' => "UPS",
'trackingNumber' => "tracking_number_1",
'notifyPayer' => true,
'lineItems' => [
// Optionally create line items
[
'quantity' => '1',
'name' => 'Product Name',
'productCode' => "ABC 01",
'description' => "Product Description",
'upcCode' => '12345678012', // new field
'upcType' => BraintreeTransactionLineItem::UPC_A, // new field
'imageUrl' => 'https://example.com/product1.jpeg' // new field
],
[
'quantity' => '1',
'name' => 'Product Name',
'productCode' => "ABC 02",
'description' => "Product Description"
]
]
]
);
$id = $packageResult->transaction->packages[0]->id;
$carrier = $packageResult->transaction->packages[0]->carrier;
$trackingNumber = $packageResult->transaction->packages[0]->trackingNumber;
// The PayPal tracker ID will not be immediately available in response to
// package_tracking(). But should be there when merchant does a findTransaction
// request at a later stage.
}
?>
3. Retrieve transactions with package trackers:
- PHP
<?php
function retrievePackageTracker() {
// Get more details of the individual packages like so, replace 0 with the element #:
$transaction = Braintree\Transaction::find($transactionId);
$id = $transaction->packages[0]->id;
$carrier = $transaction->packages[0]->carrier;
$trackingNumber = $transaction->packages[0]->trackingNumber;
$paypalTrackerId = $transaction->packages[0]->paypalTrackerId;
// The PayPal tracker ID will not be immediately available in response to
// package_tracking(). But should be there when merchant does a findTransaction
// request at a later stage.
}
?>