Bolt API Reference: A comprehensive Bolt API reference for interacting with Accounts, Payments, Orders and more.
- SDK Installation
- SDK Example Usage
- Available Resources and Operations
- Error Handling
- Server Selection
- Authentication
To add a reference to a local instance of the SDK in a .NET project:
dotnet add reference Boltpay/SDK/Boltpay.SDK.csproj
using Boltpay.SDK;
using Boltpay.SDK.Models.Requests;
using Boltpay.SDK.Models.Components;
var sdk = new BoltSDK(security: new Security() {
Oauth = "<YOUR_OAUTH_HERE>",
ApiKey = "<YOUR_API_KEY_HERE>",
});
var res = await sdk.Account.GetDetailsAsync(
xPublishableKey: "<value>",
xMerchantClientId: "<value>"
);
// handle response
- GetDetails - Retrieve account details
- AddAddress - Add an address
- UpdateAddress - Edit an existing address
- DeleteAddress - Delete an existing address
- AddPaymentMethod - Add a payment method
- DeletePaymentMethod - Delete an existing payment method
- Initialize - Initialize a Bolt payment for logged in shoppers
- PerformAction - Finalize a pending payment
- Initialize - Initialize a Bolt payment for guest shoppers
- PerformAction - Finalize a pending guest payment
- OrdersCreate - Create an order that was prepared outside the Bolt ecosystem.
- GetToken - Get OAuth token
- CreateAccount - Create a test account
- TestingAccountPhoneGet - Get a random phone number
- GetCreditCard - Retrieve a tokenized test credit card
Handling errors in this SDK should largely match your expectations. All operations return a response object or thow an exception. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate type.
Error Object | Status Code | Content Type |
---|---|---|
Boltpay.SDK.Models.Errors.Error | 4XX | application/json |
Boltpay.SDK.Models.Errors.FieldError | 4XX | application/json |
Boltpay.SDK.Models.Errors.SDKException | 4xx-5xx | / |
using Boltpay.SDK;
using Boltpay.SDK.Models.Requests;
using Boltpay.SDK.Models.Components;
using System;
using Boltpay.SDK.Models.Errors;
var sdk = new BoltSDK(security: new Security() {
Oauth = "<YOUR_OAUTH_HERE>",
ApiKey = "<YOUR_API_KEY_HERE>",
});
try
{
var res = await sdk.Account.GetDetailsAsync(
xPublishableKey: "<value>",
xMerchantClientId: "<value>"
);
// handle response
}
catch (Exception ex)
{
if (ex is Error)
{
// handle exception
}
else if (ex is FieldError)
{
// handle exception
}
else if (ex is Boltpay.SDK.Models.Errors.SDKException)
{
// handle exception
}
}
You can override the default server globally by passing a server index to the serverIndex: number
optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers:
# | Server | Variables |
---|---|---|
0 | https://{environment}.bolt.com/v3 |
environment (default is api-sandbox ) |
Some of the server options above contain variables. If you want to set the values of those variables, the following options are provided for doing so:
environment: ServerEnvironment
The default server can also be overridden globally by passing a URL to the serverUrl: str
optional parameter when initializing the SDK client instance. For example:
This SDK supports the following security schemes globally:
Name | Type | Scheme |
---|---|---|
Oauth |
oauth2 | OAuth2 token |
ApiKey |
apiKey | API key |
You can set the security parameters through the security
optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
using Boltpay.SDK;
using Boltpay.SDK.Models.Requests;
using Boltpay.SDK.Models.Components;
var sdk = new BoltSDK(security: new Security() {
Oauth = "<YOUR_OAUTH_HERE>",
ApiKey = "<YOUR_API_KEY_HERE>",
});
var res = await sdk.Account.GetDetailsAsync(
xPublishableKey: "<value>",
xMerchantClientId: "<value>"
);
// handle response
Some operations in this SDK require the security scheme to be specified at the request level. For example:
using Boltpay.SDK;
using Boltpay.SDK.Models.Requests;
using Boltpay.SDK.Models.Components;
using System.Collections.Generic;
var sdk = new BoltSDK();
var res = await sdk.Payments.Guest.InitializeAsync(
security: new GuestPaymentsInitializeSecurity() {
ApiKey = "<YOUR_API_KEY_HERE>",
},
xPublishableKey: "<value>",
xMerchantClientId: "<value>",
guestPaymentInitializeRequest: new GuestPaymentInitializeRequest() {
Profile = new ProfileCreationData() {
CreateAccount = true,
FirstName = "Alice",
LastName = "Baker",
Email = "[email protected]",
Phone = "+14155550199",
},
Cart = new Cart() {
OrderReference = "order_100",
OrderDescription = "Order #1234567890",
DisplayId = "215614191",
Shipments = new List<CartShipment>() {
new CartShipment() {
Address = AddressReferenceInput.CreateAddressReferenceId(
new AddressReferenceId() {
DotTag = Boltpay.SDK.Models.Components.AddressReferenceIdTag.Id,
Id = "D4g3h5tBuVYK9",
}
),
Cost = new Amount() {
Currency = Boltpay.SDK.Models.Components.Currency.Usd,
Units = 900,
},
Carrier = "FedEx",
},
},
Discounts = new List<CartDiscount>() {
new CartDiscount() {
Amount = new Amount() {
Currency = Boltpay.SDK.Models.Components.Currency.Usd,
Units = 900,
},
Code = "SUMMER10DISCOUNT",
DetailsUrl = "https://www.example.com/SUMMER-SALE",
},
},
Items = new List<CartItem>() {
new CartItem() {
Name = "Bolt Swag Bag",
Reference = "item_100",
Description = "Large tote with Bolt logo.",
TotalAmount = new Amount() {
Currency = Boltpay.SDK.Models.Components.Currency.Usd,
Units = 900,
},
UnitPrice = 1000,
Quantity = 1,
ImageUrl = "https://www.example.com/products/123456/images/1.png",
},
},
Total = new Amount() {
Currency = Boltpay.SDK.Models.Components.Currency.Usd,
Units = 900,
},
Tax = new Amount() {
Currency = Boltpay.SDK.Models.Components.Currency.Usd,
Units = 900,
},
},
PaymentMethod = PaymentMethodInput.CreatePaymentMethodAffirm(
new PaymentMethodAffirm() {
DotTag = Boltpay.SDK.Models.Components.PaymentMethodAffirmTag.Affirm,
ReturnUrl = "www.example.com/handle_affirm_success",
}
),
}
);
// handle response
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.