Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- "1.14"
- "1.18"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- id: setup-go
uses: actions/setup-go@v1
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- id: build-and-test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
- "1.14"
- "1.18"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- id: setup-go
uses: actions/setup-go@v1
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- id: build-and-test
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
go:
- "1.14"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v5
- id: setup-go
uses: actions/setup-go@v1
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go }}
- id: build-and-test
Expand Down
3 changes: 3 additions & 0 deletions abc/checkout_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
payments "github.com/checkout/checkout-sdk-go/payments/abc"
"github.com/checkout/checkout-sdk-go/payments/hosted"
"github.com/checkout/checkout-sdk-go/payments/links"
"github.com/checkout/checkout-sdk-go/payments/setups"
"github.com/checkout/checkout-sdk-go/reconciliation"
"github.com/checkout/checkout-sdk-go/sources"
"github.com/checkout/checkout-sdk-go/tokens"
Expand All @@ -27,6 +28,7 @@ type Api struct {
Instruments *abc.Client
Links *links.Client
Payments *payments.Client
PaymentSetups *setups.Client
Reconciliation *reconciliation.Client
Sources *sources.Client
Tokens *tokens.Client
Expand All @@ -48,6 +50,7 @@ func CheckoutApi(configuration *configuration.Configuration) *Api {
api.Instruments = abc.NewClient(configuration, apiClient)
api.Links = links.NewClient(configuration, apiClient)
api.Payments = payments.NewClient(configuration, apiClient)
api.PaymentSetups = setups.NewClient(configuration, apiClient)
api.Reconciliation = reconciliation.NewClient(configuration, apiClient)
api.Sources = sources.NewClient(configuration, apiClient)
api.Tokens = tokens.NewClient(configuration, apiClient)
Expand Down
3 changes: 3 additions & 0 deletions nas/checkout_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/checkout/checkout-sdk-go/payments/links"
payments "github.com/checkout/checkout-sdk-go/payments/nas"
"github.com/checkout/checkout-sdk-go/payments/sessions"
"github.com/checkout/checkout-sdk-go/payments/setups"
"github.com/checkout/checkout-sdk-go/reports"
"github.com/checkout/checkout-sdk-go/sessions"
"github.com/checkout/checkout-sdk-go/tokens"
Expand Down Expand Up @@ -48,6 +49,7 @@ type Api struct {
Issuing *issuing.Client
Contexts *contexts.Client
PaymentSessions *payment_sessions.Client
PaymentSetups *setups.Client
Forward *forward.Client

Ideal *ideal.Client
Expand Down Expand Up @@ -78,6 +80,7 @@ func CheckoutApi(configuration *configuration.Configuration) *Api {
api.Issuing = issuing.NewClient(configuration, apiClient)
api.Contexts = contexts.NewClient(configuration, apiClient)
api.PaymentSessions = payment_sessions.NewClient(configuration, apiClient)
api.PaymentSetups = setups.NewClient(configuration, apiClient)
api.Forward = forward.NewClient(configuration, apiClient)

api.Ideal = ideal.NewClient(configuration, apiClient)
Expand Down
32 changes: 16 additions & 16 deletions payments/payments.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,31 +337,31 @@ type (
}

Ticket struct {
Number string `json:"number,omitempty"`
IssueDate string `json:"issue_date,omitempty"`
IssuingCarrierCode string `json:"issuing_carrier_code,omitempty"`
TravelPackageIndicator string `json:"travel_package_indicator,omitempty"`
TravelAgencyName string `json:"travel_agency_name,omitempty"`
TravelAgencyCode string `json:"travel_agency_code,omitempty"`
Number string `json:"number,omitempty"`
IssueDate *time.Time `json:"issue_date,omitempty"`
IssuingCarrierCode string `json:"issuing_carrier_code,omitempty"`
TravelPackageIndicator string `json:"travel_package_indicator,omitempty"`
TravelAgencyName string `json:"travel_agency_name,omitempty"`
TravelAgencyCode string `json:"travel_agency_code,omitempty"`
}

Passenger struct {
FirstName string `json:"first_name,omitempty"`
LastName string `json:"last_name,omitempty"`
DateOfBirth string `json:"date_of_birth,omitempty"`
DateOfBirth *time.Time `json:"date_of_birth,omitempty"`
Address *common.Address `json:"address,omitempty"`
}

FlightLegDetails struct {
FlightNumber string `json:"flight_number,omitempty"`
CarrierCode string `json:"carrier_code,omitempty"`
ClassOfTraveling string `json:"class_of_traveling,omitempty"`
DepartureAirport string `json:"departure_airport,omitempty"`
DepartureDate string `json:"departure_date,omitempty"`
DepartureTime string `json:"departure_time,omitempty"`
ArrivalAirport string `json:"arrival_airport,omitempty"`
StopoverCode string `json:"stopover_code,omitempty"`
FareBasisCode string `json:"fare_basis_code,omitempty"`
FlightNumber string `json:"flight_number,omitempty"`
CarrierCode string `json:"carrier_code,omitempty"`
ClassOfTraveling string `json:"class_of_traveling,omitempty"`
DepartureAirport string `json:"departure_airport,omitempty"`
DepartureDate *time.Time `json:"departure_date,omitempty"`
DepartureTime string `json:"departure_time,omitempty"`
ArrivalAirport string `json:"arrival_airport,omitempty"`
StopoverCode string `json:"stopover_code,omitempty"`
FareBasisCode string `json:"fare_basis_code,omitempty"`
}

ShippingInfo struct {
Expand Down
106 changes: 106 additions & 0 deletions payments/setups/client.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package setups

import (
"github.com/checkout/checkout-sdk-go/client"
"github.com/checkout/checkout-sdk-go/common"
"github.com/checkout/checkout-sdk-go/configuration"
)

type Client struct {
configuration *configuration.Configuration
apiClient client.HttpClient
}

func NewClient(configuration *configuration.Configuration, apiClient client.HttpClient) *Client {
return &Client{
configuration: configuration,
apiClient: apiClient,
}
}

// CreatePaymentSetup creates a Payment Setup.
// Beta
//
// Creates a Payment Setup.
//
// To maximize the amount of information the payment setup can use, we
// recommend that you create a payment setup as early as possible in the
// customer's journey. For example, the first time they land on the basket
// page.
func (c *Client) CreatePaymentSetup(request PaymentSetupRequest) (*PaymentSetupResponse, error) {
auth, err := c.configuration.Credentials.GetAuthorization(configuration.SecretKeyOrOauth)
if err != nil {
return nil, err
}

var response PaymentSetupResponse
err = c.apiClient.Post(common.BuildPath(PaymentSetupsPath), auth, request, &response, nil)
if err != nil {
return nil, err
}

return &response, nil
}

// UpdatePaymentSetup updates a Payment Setup.
// Beta
//
// Updates a Payment Setup.
//
// You should update the payment setup whenever there are significant changes
// in the data relevant to the customer's transaction. For example, when the
// customer makes a change that impacts the total payment amount.
func (c *Client) UpdatePaymentSetup(setupId string, request PaymentSetupRequest) (*PaymentSetupResponse, error) {
auth, err := c.configuration.Credentials.GetAuthorization(configuration.SecretKeyOrOauth)
if err != nil {
return nil, err
}

var response PaymentSetupResponse
err = c.apiClient.Put(common.BuildPath(PaymentSetupsPath, setupId), auth, request, &response, nil)
if err != nil {
return nil, err
}

return &response, nil
}

// GetPaymentSetup retrieves a Payment Setup.
// Beta
//
// Retrieves a Payment Setup.
func (c *Client) GetPaymentSetup(setupId string) (*PaymentSetupResponse, error) {
auth, err := c.configuration.Credentials.GetAuthorization(configuration.SecretKeyOrOauth)
if err != nil {
return nil, err
}

var response PaymentSetupResponse
err = c.apiClient.Get(common.BuildPath(PaymentSetupsPath, setupId), auth, &response)
if err != nil {
return nil, err
}

return &response, nil
}

// ConfirmPaymentSetup confirms a Payment Setup to begin processing the
// payment request with your chosen payment method option.
// Beta
//
// Confirm a Payment Setup to begin processing the payment request with your
// chosen payment method option.
func (c *Client) ConfirmPaymentSetup(setupId string, paymentMethodOptionId string) (*PaymentSetupConfirmResponse, error) {
auth, err := c.configuration.Credentials.GetAuthorization(configuration.SecretKeyOrOauth)
if err != nil {
return nil, err
}

var response PaymentSetupConfirmResponse
err = c.apiClient.Post(common.BuildPath(PaymentSetupsPath, setupId, ConfirmPath, paymentMethodOptionId), auth, nil, &response, nil)
if err != nil {
return nil, err
}

return &response, nil
}
Loading