(transactions())
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.
- list - List all shipping labels
- create - Create a shipping label
- get - Retrieve a shipping label
Returns a list of all transaction objects.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.TrackingStatusEnum;
import com.goshippo.shippo_sdk.models.components.TransactionStatusEnum;
import com.goshippo.shippo_sdk.models.operations.ListTransactionsRequest;
import com.goshippo.shippo_sdk.models.operations.ListTransactionsResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
ListTransactionsRequest req = ListTransactionsRequest.builder()
.objectStatus(TransactionStatusEnum.SUCCESS)
.trackingStatus(TrackingStatusEnum.DELIVERED)
.build();
ListTransactionsResponse res = sdk.transactions().list()
.request(req)
.call();
if (res.transactionPaginatedList().isPresent()) {
// handle response
}
}
}
ListTransactionsResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
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.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.components.LabelFileTypeEnum;
import com.goshippo.shippo_sdk.models.components.TransactionCreateRequest;
import com.goshippo.shippo_sdk.models.operations.CreateTransactionRequestBody;
import com.goshippo.shippo_sdk.models.operations.CreateTransactionResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
CreateTransactionResponse res = sdk.transactions().create()
.shippoApiVersion("2018-02-08")
.requestBody(CreateTransactionRequestBody.of(TransactionCreateRequest.builder()
.rate("ec9f0d3adc9441449c85d315f0997fd5")
.async(false)
.labelFileType(LabelFileTypeEnum.PDF4X6)
.metadata("Order ID #12345")
.order("adcfdddf8ec64b84ad22772bce3ea37a")
.build()))
.call();
if (res.transaction().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
Example |
shippoApiVersion |
Optional<String> |
➖ |
Optional string used to pick a non-default API version to use. See our API version guide. |
2018-02-08 |
requestBody |
CreateTransactionRequestBody |
✔️ |
Examples. |
|
CreateTransactionResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |
Returns an existing transaction using an object ID.
package hello.world;
import com.goshippo.shippo_sdk.Shippo;
import com.goshippo.shippo_sdk.models.operations.GetTransactionResponse;
import java.lang.Exception;
public class Application {
public static void main(String[] args) throws Exception {
Shippo sdk = Shippo.builder()
.apiKeyHeader("<YOUR_API_KEY_HERE>")
.shippoApiVersion("2018-02-08")
.build();
GetTransactionResponse res = sdk.transactions().get()
.transactionId("<id>")
.shippoApiVersion("2018-02-08")
.call();
if (res.transaction().isPresent()) {
// handle response
}
}
}
Parameter |
Type |
Required |
Description |
Example |
transactionId |
String |
✔️ |
Object ID of the transaction to update |
|
shippoApiVersion |
Optional<String> |
➖ |
Optional string used to pick a non-default API version to use. See our API version guide. |
2018-02-08 |
GetTransactionResponse
Error Type |
Status Code |
Content Type |
models/errors/SDKError |
4XX, 5XX |
*/* |