Skip to content

Latest commit

 

History

History
146 lines (102 loc) · 11.1 KB

File metadata and controls

146 lines (102 loc) · 11.1 KB

Transactions

(Transactions)

Overview

A transaction is the purchase of a shipping label from a shipping provider for a specific service. You can print purchased labels and used them to ship a parcel with a carrier, such as USPS or FedEx.

Available Operations

  • List - List all shipping labels
  • Create - Create a shipping label
  • Get - Retrieve a shipping label

List

Returns a list of all transaction objects.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

ListTransactionsRequest req = new ListTransactionsRequest() {
    ObjectStatus = Shippo.Models.Components.TransactionStatusEnum.Success,
    TrackingStatus = Shippo.Models.Components.TrackingStatusEnum.Delivered,
};

var res = await sdk.Transactions.ListAsync(req);

// handle response

Parameters

Parameter Type Required Description
request ListTransactionsRequest ✔️ The request object to use for the request.

Response

TransactionPaginatedList

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Create

Creates a new transaction object and purchases the shipping label using a rate object that has previously been created.
OR
Creates a new transaction object and purchases the shipping label instantly using shipment details, an existing carrier account, and an existing service level token.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;
using System.Collections.Generic;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.Transactions.CreateAsync(
    requestBody: CreateTransactionRequestBody.CreateTransactionCreateRequest(
        new TransactionCreateRequest() {
            Async = false,
            LabelFileType = Shippo.Models.Components.LabelFileTypeEnum.Pdf4x6,
            Metadata = "Order ID #12345",
            Rate = "ec9f0d3adc9441449c85d315f0997fd5",
            Order = "adcfdddf8ec64b84ad22772bce3ea37a",
        }
    ),
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
RequestBody CreateTransactionRequestBody ✔️ Examples.
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

Transaction

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*

Get

Returns an existing transaction using an object ID.

Example Usage

using Shippo;
using Shippo.Models.Requests;
using Shippo.Models.Components;

var sdk = new ShippoSDK(
    apiKeyHeader: "<YOUR_API_KEY_HERE>",
    shippoApiVersion: "2018-02-08"
);

var res = await sdk.Transactions.GetAsync(
    transactionId: "<id>",
    shippoApiVersion: "2018-02-08"
);

// handle response

Parameters

Parameter Type Required Description Example
TransactionId string ✔️ Object ID of the transaction to update
ShippoApiVersion string Optional string used to pick a non-default API version to use. See our API version guide. 2018-02-08

Response

Transaction

Errors

Error Type Status Code Content Type
Shippo.Models.Errors.SDKException 4XX, 5XX */*