Categorygithub.com/smartpay-co/sdk-go
modulepackage
0.3.0
Repository: https://github.com/smartpay-co/sdk-go.git
Documentation: pkg.go.dev

# README

Contributors Forks Stargazers Issues Go Reference Go Report Card Apache 2.0 License Workflow


Smartpay Go SDK

Smartpay Go SDK offers easy access to Smartpay API from applications written in Go.

Prerequisites

Go v1.18+

Installation

go get github.com/smartpay-co/sdk-go

Usage

Let's give a quick example first about how to create a new checkout session.

package main

import (
	"context"
	"fmt"
	. "github.com/smartpay-co/sdk-go"
)

func main() {
	ctx := context.Background()
	client, _ := NewClientWithResponses("<YOUR_SECRET_KEY>", "<YOUR_PUBLIC_KEY>")

	checkoutPayload := CreateACheckoutSessionJSONRequestBody{
		Currency: CurrencyJPY,
		Amount:   350,
		Items: []Item{
			{Name: "レブロン 18 LOW", Amount: 1000, Currency: CurrencyJPY, Quantity: Ptr(1)},
			{Name: "discount", Amount: 100, Currency: CurrencyJPY, Kind: Ptr(LineItemKindDiscount)},
			{Name: "tax", Amount: 250, Currency: CurrencyJPY, Kind: Ptr(LineItemKindTax)},
		},
		ShippingInfo: ShippingInfo{
			Address:     Address{Country: AddressCountryJP, PostalCode: "123", Locality: "locality", Line1: "line1"},
			FeeAmount:   Ptr(float32(100)),
			FeeCurrency: Ptr(CurrencyJPY),
		},
		CaptureMethod: Ptr(CaptureMethodManual),
		Reference:     Ptr("order_ref_1234567"),
		SuccessUrl:    "https://smartpay.co",
		CancelUrl:     "https://smartpay.co",
	}

	result, err := client.CreateACheckoutSessionWithResponse(ctx, checkoutPayload)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(result.Body))
}

Initialize A New Client

You need to get your API key to initialize a new client. You can find it on your dashboard.

You can also customize the client by passing function options into the constructors.

client, _ := NewClientWithResponses("<SECRET_KEY>", WithHTTPClient(&httpClient), WithBaseURL("http://localhost:9000"))

Invoke an API Point

Our clients supprts struct parameters and responses for API calls. In most cases you'll be satisfied with this method. Take the example from above, CreateACheckoutSessionWithResponse is so much easier to use with the predefined request and response objects.

But if you want full control for maximium flexibility, then you can use CreateACheckoutSessionWithBody and handle the request and response on your own.

This design applies to all our APIs.

License

Distributed under the MIT License. See LICENSE.txt for more information.

# Packages

No description provided by the author

# Functions

No description provided by the author
CalculateWebhookSignatureMiddleware return a middleware that adds Calculated-Signature to request header.
No description provided by the author
NewCancelAnOrderRequest generates requests for CancelAnOrder.
Creates a new Client, with reasonable defaults.
NewClientWithResponses creates a new ClientWithResponses, which wraps Client with return type handling.
NewCreateACheckoutSessionForATokenRequest calls the generic CreateACheckoutSession builder with application/json body.
NewCreateACheckoutSessionRequest calls the generic CreateACheckoutSession builder with application/json body.
NewCreateACheckoutSessionRequestWithBody generates requests for CreateACheckoutSession with any type of body.
NewCreateACouponRequest calls the generic CreateACoupon builder with application/json body.
NewCreateACouponRequestWithBody generates requests for CreateACoupon with any type of body.
NewCreateAnOrderUsingATokenRequest calls the generic CreateAnOrderUsingAToken builder with application/json body.
NewCreateAnOrderUsingATokenRequestWithBody generates requests for CreateAnOrderUsingAToken with any type of body.
NewCreateAPaymentRequest calls the generic CreateAPayment builder with application/json body.
NewCreateAPaymentRequestWithBody generates requests for CreateAPayment with any type of body.
NewCreateAPromotionCodeRequest calls the generic CreateAPromotionCode builder with application/json body.
NewCreateAPromotionCodeRequestWithBody generates requests for CreateAPromotionCode with any type of body.
NewCreateARefundRequest calls the generic CreateARefund builder with application/json body.
NewCreateARefundRequestWithBody generates requests for CreateARefund with any type of body.
NewCreateAWebhookEndpointRequest calls the generic CreateAWebhookEndpoint builder with application/json body.
NewCreateAWebhookEndpointRequestWithBody generates requests for CreateAWebhookEndpoint with any type of body.
NewDeleteATokenRequest generates requests for DeleteAToken.
NewDeleteAWebhookEndpointRequest generates requests for DeleteAWebhookEndpoint.
NewDisableATokenRequest generates requests for DisableAToken.
NewEnableATokenRequest generates requests for EnableAToken.
NewListAllCheckoutSessionsRequest generates requests for ListAllCheckoutSessions.
NewListAllCouponsRequest generates requests for ListAllCoupons.
NewListAllOrdersRequest generates requests for ListAllOrders.
NewListAllPaymentsRequest generates requests for ListAllPayments.
NewListAllPromotionCodesRequest generates requests for ListAllPromotionCodes.
NewListAllRefundsRequest generates requests for ListAllRefunds.
NewListAllTokensRequest generates requests for ListAllTokens.
NewListAllWebhookEndpointsRequest generates requests for ListAllWebhookEndpoints.
NewRetrieveACheckoutSessionRequest generates requests for RetrieveACheckoutSession.
NewRetrieveACouponRequest generates requests for RetrieveACoupon.
NewRetrieveAnOrderRequest generates requests for RetrieveAnOrder.
NewRetrieveAPaymentRequest generates requests for RetrieveAnOrder.
NewRetrieveAPromotionCodeRequest generates requests for RetrieveAPromotionCode.
NewRetrieveARefundRequest generates requests for RetrieveARefund.
NewRetrieveATokenRequest generates requests for RetrieveAToken.
NewRetrieveAWebhookEndpointRequest generates requests for RetrieveAWebhookEndpoint.
NewUpdateACouponRequest calls the generic UpdateACoupon builder with application/json body.
NewUpdateACouponRequestWithBody generates requests for UpdateACoupon with any type of body.
NewUpdateAPaymentRequest calls the generic UpdateAPayment builder with application/json body.
NewUpdateAPaymentRequestWithBody generates requests for UpdateAPayment with any type of body.
NewUpdateAPromotionCodeRequest calls the generic UpdateAPromotionCode builder with application/json body.
NewUpdateAPromotionCodeRequestWithBody generates requests for UpdateAPromotionCode with any type of body.
NewUpdateARefundRequest calls the generic UpdateARefund builder with application/json body.
NewUpdateARefundRequestWithBody generates requests for UpdateARefund with any type of body.
NewUpdateAWebhookEndpointRequest calls the generic UpdateAWebhookEndpoint builder with application/json body.
NewUpdateAWebhookEndpointRequestWithBody generates requests for UpdateAWebhookEndpoint with any type of body.
ParseCancelAnOrderResponse parses an HTTP response from a CancelAnOrderWithResponse call.
ParseCreateACheckoutSessionResponse parses an HTTP response from a CreateACheckoutSessionWithResponse call.
ParseCreateACouponResponse parses an HTTP response from a CreateACouponWithResponse call.
ParseCreateAnOrderUsingATokenResponse parses an HTTP response from a CreateAnOrderUsingATokenWithResponse call.
ParseCreateAPaymentResponse parses an HTTP response from a CreateAPaymentWithResponse call.
ParseCreateAPromotionCodeResponse parses an HTTP response from a CreateAPromotionCodeWithResponse call.
ParseCreateARefundResponse parses an HTTP response from a CreateARefundWithResponse call.
ParseCreateAWebhookEndpointResponse parses an HTTP response from a CreateAWebhookEndpointWithResponse call.
ParseDeleteATokenResponse parses an HTTP response from a DeleteATokenWithResponse call.
ParseDeleteAWebhookEndpointResponse parses an HTTP response from a DeleteAWebhookEndpointWithResponse call.
ParseDisableATokenResponse parses an HTTP response from a DisableATokenWithResponse call.
ParseEnableATokenResponse parses an HTTP response from a EnableATokenWithResponse call.
ParseListAllCheckoutSessionsResponse parses an HTTP response from a ListAllCheckoutSessionsWithResponse call.
ParseListAllCouponsResponse parses an HTTP response from a ListAllCouponsWithResponse call.
ParseListAllOrdersResponse parses an HTTP response from a ListAllOrdersWithResponse call.
ParseListAllPaymentsResponse parses an HTTP response from a ListAllPaymentsWithResponse call.
ParseListAllPromotionCodesResponse parses an HTTP response from a ListAllPromotionCodesWithResponse call.
ParseListAllRefundsResponse parses an HTTP response from a ListAllRefundsWithResponse call.
ParseListAllTokensResponse parses an HTTP response from a ListAllTokensWithResponse call.
ParseListAllWebhookEndpointsResponse parses an HTTP response from a ListAllWebhookEndpointsWithResponse call.
ParseRetrieveACheckoutSessionResponse parses an HTTP response from a RetrieveACheckoutSessionWithResponse call.
ParseRetrieveACouponResponse parses an HTTP response from a RetrieveACouponWithResponse call.
ParseRetrieveAnOrderResponse parses an HTTP response from a RetrieveAnOrderWithResponse call.
ParseRetrieveAPaymentResponse parses an HTTP response from a RetrieveAPaymentWithResponse call.
ParseRetrieveAPromotionCodeResponse parses an HTTP response from a RetrieveAPromotionCodeWithResponse call.
ParseRetrieveARefundResponse parses an HTTP response from a RetrieveARefundWithResponse call.
ParseRetrieveATokenResponse parses an HTTP response from a RetrieveATokenWithResponse call.
ParseRetrieveAWebhookEndpointResponse parses an HTTP response from a RetrieveAWebhookEndpointWithResponse call.
ParseUpdateACouponResponse parses an HTTP response from a UpdateACouponWithResponse call.
ParseUpdateAPaymentResponse parses an HTTP response from a UpdateAPaymentWithResponse call.
ParseUpdateAPromotionCodeResponse parses an HTTP response from a UpdateAPromotionCodeWithResponse call.
ParseUpdateARefundResponse parses an HTTP response from a UpdateARefundWithResponse call.
ParseUpdateAWebhookEndpointResponse parses an HTTP response from a UpdateAWebhookEndpointWithResponse call.
Ptr Inline pointer helper.
No description provided by the author
WithBaseURL overrides the baseURL.
WithHTTPClient allows overriding the default Doer, which is automatically created using http.Client.
WithRequestEditorFn allows setting up a callback function, which will be called right before sending the request.
WithRetryOptions allows setting up retry policies for the default http client.

# Constants

Defines values for AddressCountry.
Defines values for AddressType.
Defines values for AddressType.
Defines values for AddressType.
Defines values for AddressType.
Defines values for AddressType.
No description provided by the author
Defines values for CaptureMethod.
Defines values for CaptureMethod.
Defines values for CollectionObject.
Defines values for Currency.
Defines values for CustomerInfoLegalGender.
Defines values for CustomerInfoLegalGender.
No description provided by the author
No description provided by the author
No description provided by the author
Defines values for DiscountType.
Defines values for DiscountType.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for EventSubscription.
Defines values for Expand.
Defines values for Expand.
Defines values for LineItemKind.
Defines values for LineItemKind.
Defines values for LineItemKind.
Defines values for Locale.
Defines values for Locale.
Defines values for Mode.
Defines values for OrderStatus.
Defines values for OrderStatus.
Defines values for OrderStatus.
Defines values for OrderStatus.
Defines values for OrderStatus.
Defines values for OrderStatus.
Defines values for PaymentCreateCancelRemainder.
Defines values for PaymentCreateCancelRemainder.
Defines values for PaymentExpandedStatus.
Defines values for PaymentExpandedStatus.
Defines values for PaymentStatus.
Defines values for PaymentStatus.
Defines values for RefundExpandedReason.
Defines values for RefundExpandedReason.
Defines values for RefundExpandedStatus.
Defines values for RefundExpandedStatus.
Defines values for RefundReason.
Defines values for RefundReason.
Defines values for RefundStatus.
Defines values for RefundStatus.
Defines values for TokenStatus.
Defines values for TokenStatus.
Defines values for TokenStatus.
Defines values for TokenStatus.
Defines values for TokenStatus.
Version is the current smartpay sdk-go version.

# Structs

Address.
No description provided by the author
Checkout Session.
CheckoutSessionCreate defines model for checkout-session_create.
Expanded Checkout Session.
CheckoutSessionForATokenCreate defines model for checkout-session_create.
Client which conforms to the OpenAPI3 specification for this service.
ClientWithResponses builds on ClientInterface to offer response payloads.
Coupon.
CouponCreate defines model for coupon_create.
Coupons defines model for coupons.
CouponUpdate defines model for coupon_update.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Customer Information, the details provided here are used to pre-populate forms for your customer's checkout experiences.
No description provided by the author
No description provided by the author
No description provided by the author
Discount.
No description provided by the author
ExpandableCheckoutSessions defines model for expandableCheckoutSessions.
ExpandableOrders defines model for expandableOrders.
ExpandablePayments defines model for expandablePayments.
ExpandableRefunds defines model for expandableRefunds.
Item.
Line Item.
ListAllCheckoutSessionsParams defines parameters for ListAllCheckoutSessions.
No description provided by the author
ListAllCouponsParams defines parameters for ListAllCoupons.
No description provided by the author
ListAllOrdersParams defines parameters for ListAllOrders.
No description provided by the author
ListAllPaymentsParams defines parameters for ListAllPayments.
No description provided by the author
ListAllPromotionCodesParams defines parameters for ListAllPromotionCodes.
No description provided by the author
ListAllRefundsParams defines parameters for ListAllRefunds.
No description provided by the author
ListAllTokensParams defines parameters for ListAllTokens.
No description provided by the author
ListAllWebhookEndpointsParams defines parameters for ListAllWebhookEndpoints.
No description provided by the author
N401 defines model for 401.
Order.
CheckoutSessionCreate defines model for checkout-session_create.
Expanded Order.
Payment.
PaymentCreate defines model for payment_create.
Expanded Payment.
PaymentUpdate defines model for payment_update.
Price.
Product.
A promotion code points to a coupon, and can be used to (attempt to) attach that coupon to an order.
PromotionCodeCreate defines model for promotion-code_create.
PromotionCodes defines model for promotion-codes.
PromotionCodeUpdate defines model for promotion-code_update.
Refund.
RefundCreate defines model for refund_create.
Expanded Refund.
RefundUpdate defines model for refund_update.
RetrieveACheckoutSessionParams defines parameters for RetrieveACheckoutSession.
No description provided by the author
No description provided by the author
RetrieveAnOrderParams defines parameters for RetrieveAnOrder.
No description provided by the author
RetrieveAPaymentParams defines parameters for RetrieveAPayment.
No description provided by the author
No description provided by the author
RetrieveARefundParams defines parameters for RetrieveARefund.
No description provided by the author
No description provided by the author
No description provided by the author
Shipping Information.
Token.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
WebhookEndpoint defines model for webhookEndpoint.
WebhookEndpointCreate defines model for webhook-endpoint_create.
WebhookEndpointNotFound defines model for WebhookEndpointNotFound.
WebhookEndpoints defines model for webhookEndpoints.
WebhookEndpointUpdate defines model for webhook-endpoint_update.

# Interfaces

CheckoutSessionOptions defines model for checkoutSessionOptions.
The interface specification for the client.
ClientWithResponsesInterface is the interface specification for the client with responses.
Doer performs HTTP requests.
Expandable Order.
Expandable Payment.
Expandable Refund.

# Type aliases

The country as represented by the two-letter ISO 3166-1 code.
Address Type.
Order.
The URL the customer will be redirected to if the Checkout Session hasn't completed successfully.
CaptureMethod defines model for captureMethod.
The unique identifier for the Checkout Session object.
The URL to launch Smartpay checkout for this checkout session.
ClientOption allows setting custom parameters during construction.
A string representing the object’s type.
The unique identifier for the Coupon object.
CreateACheckoutSessionForATokenJSONRequestBody defines body for CheckoutSessionForATokenCreate for application/json ContentType.
CreateACheckoutSessionJSONRequestBody defines body for CreateACheckoutSession for application/json ContentType.
CreateACouponJSONRequestBody defines body for CreateACoupon for application/json ContentType.
CreateAnOrderUsingATokenJSONRequestBody defines body for CreateAnOrderUsingAToken for application/json ContentType.
CreateAPaymentJSONRequestBody defines body for CreateAPayment for application/json ContentType.
CreateAPromotionCodeJSONRequestBody defines body for CreateAPromotionCode for application/json ContentType.
CreateARefundJSONBodyReason defines parameters for CreateARefund.
CreateARefundJSONRequestBody defines body for CreateARefund for application/json ContentType.
CreateAWebhookEndpointJSONRequestBody defines body for CreateAWebhookEndpoint for application/json ContentType.
Time at which the object was created.
Three-letter ISO currency code, in uppercase.
The (legal) gender of your customer.
The discount amount applied to the order through a Smartpay coupontype DiscountAmount int.
The unique identifier for the Discount object.
Discount Type.
Even name to subscribe to.
Expand defines model for expand.
ExpandableCheckoutSession defines model for expandableCheckoutSession.
Expandable Order.
Expandable Refund.
A URL for an image for this product, meant to be displayed to the customer.
The unique identifier for the Line Item object.
LineItem Kind.
ListAllCheckoutSessionsParamsExpand defines parameters for ListAllCheckoutSessions.
ListAllOrdersParamsExpand defines parameters for ListAllOrders.
ListAllPaymentsParamsExpand defines parameters for ListAllPayments.
ListAllRefundsParamsExpand defines parameters for ListAllRefunds.
Locale.
The maximum number of objects returned for this call.
Set of up to 20 key-value pairs that you can attach to the object.
Payment.
Refund.
No description provided by the author
No description provided by the author
No description provided by the author
The token for the next page of the collection of objects.
The amount intended to be collected through this order.
The unique identifier for the Payment object.
Order Status.
The token for the page of the collection of objects.
PaymentCreateCancelRemainder defines parameters for CreateAPayment.
PaymentExpandedStatus defines model for PaymentExpanded.Status.
The unique identifier for the Payment object.
PaymentStatus defines model for Payment.Status.
The unique identifier for the Price object.
A category of items the product belongs to.
The unique identifier for the Product object.
A URL of the publicly accessible page for this Product on your site or store.
The unique identifier for the Promotion Code object.
RefundExpandedReason defines model for RefundExpanded.Reason.
RefundExpandedStatus defines model for RefundExpanded.Status.
The unique identifier for the Refund object.
RefundReason defines model for Refund.Reason.
RefundStatus defines model for Refund.Status.
RequestEditorFn is the function signature for the RequestEditor callback function.
The actual number of objects returned for this call.
RetrieveACheckoutSessionParamsExpand defines parameters for RetrieveACheckoutSession.
RetrieveAnOrderParamsExpand defines parameters for RetrieveAnOrder.
RetrieveAPaymentParamsExpand defines parameters for RetrieveAnOrder.
RetrieveARefundParamsExpand defines parameters for RetrieveARefund.
The URL the customer will be redirected to if the Checkout Session completed successfully.
A flag with a value `false` if the object exists in live mode or `true` if the object exists in test mode.
The unique identifier for the Token object.
Token Status.
UpdateACouponJSONRequestBody defines body for UpdateACoupon for application/json ContentType.
UpdateAPaymentJSONRequestBody defines body for UpdateAPayment for application/json ContentType.
UpdateAPromotionCodeJSONRequestBody defines body for UpdateAPromotionCode for application/json ContentType.
UpdateARefundJSONRequestBody defines body for UpdateARefund for application/json ContentType.
UpdateAWebhookEndpointJSONRequestBody defines body for UpdateAWebhookEndpoint for application/json ContentType.
The moment at which the object was last updated.
The unique identifier for the Webhook Endpoint object.