Package Tracking

Server-side configuration

1. Place transaction

  1. .NET
TransactionRequest request = new TransactionRequest
{
    Amount = 100.00M,
    PaymentMethodNonce = nonceFromTheClient,
    PurchaseOrderNumber = "12345",
    TaxAmount = 5.00M,
    ShippingAmount = 1.00M,
    DiscountAmount = 0.00M,
    ShipsFromPostalCode = "60654",
    ShippingAddress = new AddressRequest
    {
        FirstName = "Clinton",
        LastName = "Ecker",
        StreetAddress = "1234 Main Street",
        ExtendedAddress = "Unit 222",
        Locality = "Chicago",
        Region = "IL",
        PostalCode = "60654",
        CountryCodeAlpha3 = "USA"
    },
    LineItems = new TransactionLineItemRequest[]
    {
        new TransactionLineItemRequest
        {
            Name = "Product",
            LineItemKind = TransactionLineItemKind.DEBIT,
            Quantity = 10.0000M,
            UnitAmount = 9.5000M,
            TotalAmount = 95.00M,
            ProductCode = "54321",
            UpcCode = "012345678912",
            // new field
            UpcType = TransactionLineItemKind.UPC_A,
            // new field
            Url = "http://example.com",
            // new field
            ImageUrl = "http://example.com/product1.jpeg" // new field
        }
    }
};
gateway.Transaction.Sale(request);

2. Create tracking for transaction after submitting for settlement:

  1. .NET
public void SampleIntegration()
{
    // Create or retrieve Transaction for which package tracking information needs
    // to be supplemented with transaction.sale() or find()
    Result<transaction> result = gateway.Transaction.Sale(request);

    // Optionally create line items
    var lineItems = new TransactionLineItemRequest[2]
    {
        new TransactionLineItemRequest
        {
            ProductCode = "ABC 01",
            Quantity = 1,
            Name = "Product Name",
            Description = "Product Description",
            UpcCode = "012345678912",
            // new field
            UpcType = TransactionLineItemKind.UPC_A,
            // new field
            Url = "http://example.com",
            // new field
            ImageUrl = "http://example.com/product1.jpeg" // new field
        },
        new TransactionLineItemRequest
        {
            ProductCode = "ABC 02",
            Quantity = 1,
            Name = "Product Name",
            Description = "Product Description"
        },
    };

    // Create a Package tracking request with optional line items
    var package = new PackageTrackingRequest
    {
        Carrier = "UPS",
        TrackingNumber = "tracking_number_1",
        NotifyPayer = false,
        LineItems = lineItems
    };

    // Send the package tracking request with optional line items
    Result<transaction> packageTrackingResult = gateway.Transaction
        .PackageTracking(transaction.Id, package);
    Transaction transactionWithPackageDetails = packageTrackingResult.Target;
    PackageDetails[] packages = transactionWithPackageDetails.Packages;

    string Id = packages[0].Id;
    string TrackingNumber = packages[0].TrackingNumber;
    string Carrier = packages[0].Carrier;

    // The PayPal tracker ID will not be immediately available in response to
    // PackageTracking(). But should be there when merchant does a findTransaction
    // request at a later stage.
}

3. Retrieve transactions with package trackers:

  1. .NET
// Get more details of the individual packages like so,
// replace 0 with the element #:
Transaction transaction = gateway.Transaction.Find(transactionId);
string Id = transaction.Packages[0].Id;
string TrackingNumber = transaction.Packages[0].TrackingNumber;
string Carrier = transaction.Packages[0].Carrier;
string PayPalTrackerId = transaction.Packages[0].PayPalTrackerId;
// The PayPal tracker ID will not be immediately available in response to
// PackageTracking(). But should be there when merchant does a findTransaction
// request at a later stage.