Bolt API Reference: A comprehensive Bolt API reference for interacting with Accounts, Payments, Orders and more.
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: "<id>"
);
// handle response
Available methods
- 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
- GetToken - Get OAuth token
- OrdersCreate - Create an order that was prepared outside the Bolt ecosystem.
- Initialize - Initialize a Bolt payment for guest shoppers
- PerformAction - Finalize a pending guest payment
- Initialize - Initialize a Bolt payment for logged in shoppers
- PerformAction - Finalize a pending payment
- 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 throw an exception.
By default, an API error will raise a Boltpay.SDK.Models.Errors.SDKException
exception, which has the following properties:
Property | Type | Description |
---|---|---|
Message |
string | The error message |
Request |
HttpRequestMessage | The HTTP request |
Response |
HttpResponseMessage | The HTTP response |
When custom error responses are specified for an operation, the SDK may also throw their associated exceptions. You can refer to respective Errors tables in SDK docs for more details on possible exception types for each operation. For example, the GetDetailsAsync
method throws the following exceptions:
Error Type | 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 | 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: "<id>"
);
// handle response
}
catch (Exception ex)
{
if (ex is Error)
{
// Handle exception data
throw;
}
if (ex is FieldError)
{
// Handle exception data
throw;
}
else if (ex is Boltpay.SDK.Models.Errors.SDKException)
{
// Handle default exception
throw;
}
}
The default server https://{environment}.bolt.com/v3
contains variables and is set to https://api-sandbox.bolt.com/v3
by default. To override default values, the following parameters are available when initializing the SDK client instance:
environment: ServerEnvironment
The default server can also be overridden globally by passing a URL to the serverUrl: string
optional parameter when initializing the SDK client instance. For example:
using Boltpay.SDK;
using Boltpay.SDK.Models.Requests;
using Boltpay.SDK.Models.Components;
var sdk = new BoltSDK(
serverUrl: "https://api-sandbox.bolt.com/v3",
security: new Security() {
Oauth = "<YOUR_OAUTH_HERE>",
ApiKey = "<YOUR_API_KEY_HERE>",
}
);
var res = await sdk.Account.GetDetailsAsync(
xPublishableKey: "<value>",
xMerchantClientId: "<id>"
);
// handle response
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: "<id>"
);
// 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>",
guestPaymentInitializeRequest: new GuestPaymentInitializeRequest() {
Profile = new ProfileCreationData() {
CreateAccount = true,
FirstName = "Alice",
LastName = "Baker",
Email = "alice@example.com",
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.CreatePaymentMethodCreditCardInput(
new PaymentMethodCreditCardInput() {
DotTag = Boltpay.SDK.Models.Components.DotTag.CreditCard,
BillingAddress = AddressReferenceInput.CreateAddressReferenceId(
new AddressReferenceId() {
DotTag = Boltpay.SDK.Models.Components.AddressReferenceIdTag.Id,
Id = "D4g3h5tBuVYK9",
}
),
Network = Boltpay.SDK.Models.Components.CreditCardNetwork.Visa,
Bin = "411111",
Last4 = "1004",
Expiration = "2029-03",
Token = "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
}
),
},
xMerchantClientId: "<id>"
);
// 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.