(Payments.LoggedIn)
- Initialize - Initialize a Bolt payment for logged in shoppers
- PerformAction - Perform an irreversible action (e.g. finalize) on a pending payment
- Update - Update an existing payment
Initialize a Bolt payment token that will be used to reference this payment to Bolt when it is updated or finalized for logged in shoppers.
package main
import(
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
"context"
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
"log"
)
func main() {
s := testboltapi.New(
testboltapi.WithSecurity(shared.Security{
APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
}),
)
ctx := context.Background()
res, err := s.Payments.LoggedIn.Initialize(ctx, operations.PaymentsInitializeRequest{
XPublishableKey: "<value>",
PaymentInitializeRequest: shared.PaymentInitializeRequest{
Cart: shared.Cart{
DisplayID: testboltapi.String("215614191"),
OrderDescription: testboltapi.String("Order #1234567890"),
OrderReference: "order_100",
Tax: shared.Amount{
Currency: shared.CurrencyUsd,
Units: 900,
},
Total: shared.Amount{
Currency: shared.CurrencyUsd,
Units: 900,
},
},
PaymentMethod: shared.CreatePaymentMethodExtendedPaymentMethodCreditCard(
shared.PaymentMethodCreditCard{
DotTag: shared.PaymentMethodCreditCardTagCreditCard,
BillingAddress: shared.CreateAddressReferenceSchemasInput(
shared.SchemasInput{
DotTag: shared.SchemasTagExplicit,
Company: testboltapi.String("ACME Corporation"),
CountryCode: shared.SchemasCountryCodeUs,
Email: testboltapi.String("alice@example.com"),
FirstName: "Alice",
LastName: "Baker",
Locality: "San Francisco",
Phone: testboltapi.String("+14155550199"),
PostalCode: "94105",
Region: testboltapi.String("CA"),
StreetAddress1: "535 Mission St, Ste 1401",
StreetAddress2: testboltapi.String("c/o Shipping Department"),
},
),
Bin: "411111",
Expiration: "2029-03",
Last4: "1004",
Network: shared.NetworkVisa,
Token: "a1B2c3D4e5F6G7H8i9J0k1L2m3N4o5P6Q7r8S9t0",
},
),
},
})
if err != nil {
log.Fatal(err)
}
if res.PaymentResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.PaymentsInitializeRequest | ✔️ | The request object to use for the request. |
*operations.PaymentsInitializeResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.Error | 4XX | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Perform an irreversible action on a pending payment, such as finalizing it.
package main
import(
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
"context"
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
"log"
)
func main() {
s := testboltapi.New(
testboltapi.WithSecurity(shared.Security{
APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
}),
)
ctx := context.Background()
res, err := s.Payments.LoggedIn.PerformAction(ctx, operations.PaymentsActionRequest{
XPublishableKey: "<value>",
ID: "iKv7t5bgt1gg",
PaymentActionRequest: shared.PaymentActionRequest{
DotTag: shared.PaymentActionRequestTagFinalize,
},
})
if err != nil {
log.Fatal(err)
}
if res.PaymentResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.PaymentsActionRequest | ✔️ | The request object to use for the request. |
*operations.PaymentsActionResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.Error | 4XX | application/json |
sdkerrors.SDKError | 4xx-5xx | / |
Update a pending payment
package main
import(
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/shared"
testboltapi "github.com/speakeasy-sdks/Test_Bolt_API"
"context"
"github.com/speakeasy-sdks/Test_Bolt_API/pkg/models/operations"
"log"
)
func main() {
s := testboltapi.New(
testboltapi.WithSecurity(shared.Security{
APIKey: testboltapi.String("<YOUR_API_KEY_HERE>"),
}),
)
ctx := context.Background()
res, err := s.Payments.LoggedIn.Update(ctx, operations.PaymentsUpdateRequest{
XPublishableKey: "<value>",
ID: "iKv7t5bgt1gg",
PaymentUpdateRequest: shared.PaymentUpdateRequest{},
})
if err != nil {
log.Fatal(err)
}
if res.PaymentResponse != nil {
// handle response
}
}
Parameter | Type | Required | Description |
---|---|---|---|
ctx |
context.Context | ✔️ | The context to use for the request. |
request |
operations.PaymentsUpdateRequest | ✔️ | The request object to use for the request. |
*operations.PaymentsUpdateResponse, error
Error Object | Status Code | Content Type |
---|---|---|
sdkerrors.Error | 4XX | application/json |
sdkerrors.SDKError | 4xx-5xx | / |