(Testing)
Use the Testing API to generate and retrieve test data to verify a subset of flows in non-production environments.
- CreateAccount - Create a test account
- TestingAccountPhoneGet - Get a random phone number
- GetCreditCard - Retrieve a tokenized test credit card
Create a Bolt shopper account for testing purposes.
package main
import(
"context"
boltgo "github.com/BoltApp/bolt-go"
"github.com/BoltApp/bolt-go/models/components"
"github.com/BoltApp/bolt-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := boltgo.New()
res, err := s.Testing.CreateAccount(ctx, operations.TestingAccountCreateSecurity{
APIKey: "<YOUR_API_KEY_HERE>",
}, "<value>", components.AccountTestCreationData{
EmailState: components.EmailStateUnverified,
PhoneState: components.PhoneStateVerified,
IsMigrated: boltgo.Bool(true),
HasAddress: boltgo.Bool(true),
HasCreditCard: boltgo.Bool(true),
})
if err != nil {
log.Fatal(err)
}
if res.AccountTestCreationData != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.TestingAccountCreateSecurity | ✔️ | The security requirements to use for the request. |
xPublishableKey |
string | ✔️ | The publicly shareable identifier used to identify your Bolt merchant division. |
accountTestCreationData |
components.AccountTestCreationData | ✔️ | N/A |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TestingAccountCreateResponse, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.TestingAccountCreateResponseBody | 4XX | application/json |
sdkerrors.SDKError | 5XX | */* |
Get a random, fictitious phone number that is not assigned to any existing Bolt account.
package main
import(
"context"
boltgo "github.com/BoltApp/bolt-go"
"github.com/BoltApp/bolt-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := boltgo.New()
res, err := s.Testing.TestingAccountPhoneGet(ctx, operations.TestingAccountPhoneGetSecurity{
APIKey: "<YOUR_API_KEY_HERE>",
}, "<value>")
if err != nil {
log.Fatal(err)
}
if res.AccountTestPhoneData != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
security |
operations.TestingAccountPhoneGetSecurity | ✔️ | The security requirements to use for the request. |
xPublishableKey |
string | ✔️ | The publicly shareable identifier used to identify your Bolt merchant division. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TestingAccountPhoneGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.TestingAccountPhoneGetResponseBody | 4XX | application/json |
sdkerrors.SDKError | 5XX | */* |
Retrieve a test credit card that can be used to process payments in your Bolt testing environment. The response includes the card's Bolt credit card token.
package main
import(
"context"
boltgo "github.com/BoltApp/bolt-go"
"github.com/BoltApp/bolt-go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := boltgo.New()
res, err := s.Testing.GetCreditCard(ctx, operations.TestingCreditCardGetRequestBody{
Type: operations.TypeApprove,
}, operations.TestingCreditCardGetSecurity{
APIKey: "<YOUR_API_KEY_HERE>",
})
if err != nil {
log.Fatal(err)
}
if res.TestCreditCard != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.TestingCreditCardGetRequestBody | ✔️ | The request object to use for the request. |
security |
operations.TestingCreditCardGetSecurity | ✔️ | The security requirements to use for the request. |
opts |
[]operations.Option | ➖ | The options for this request. |
*operations.TestingCreditCardGetResponse, error
Error Type | Status Code | Content Type |
---|---|---|
sdkerrors.TestingCreditCardGetResponseBody | 4XX | application/json |
sdkerrors.SDKError | 5XX | */* |