# README
Splitit SDK for Go language
This is Splitit Web API SDK source code for Go applications. For other languages, please visit Splitit.SDKs.
Overview
- API version: 1.0.0
- Package version: 1.6.10
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get github.com/fatih/structs
go get golang.org/x/net/context
go get github.com/antihax/optional
go get github.com/btubbs/datetime
Install the Splitit SDK package:
go get github.com/splitit/splitit.sdks.go
Getting Started
Replace YOUR_API_KEY, YOUR_USERNAME and YOUR_PASSWORD placeholders with your corresponding credentials. Please install required packages as described above and then run the following:
package main
import (
"context"
"fmt"
"os"
"github.com/splitit/splitit.sdks.go"
)
func main() {
// Recommended to have one shared client
// Use splitit.NewSandboxAPIClient for development and splitit.NewAPIClient in production
client := splitit.NewSandboxAPIClient(
"_YOUR_API_KEY_",
"_YOUR_USERNAME_",
"_YOUR_PASSWORD_",
// Supply optional configuration
// splitit.Debug(), // print out full request and response
splitit.DefaultCulture("en-US"),
)
ctx := context.TODO()
// Create initiate request
initReq := splitit.InitiateInstallmentPlanRequest{
PlanData: &splitit.PlanData{
Amount: &splitit.MoneyWithCurrencyCode{300, "USD"},
NumberOfInstallments: 3,
},
BillingAddress: &splitit.AddressData{
AddressLine: "260 Madison Avenue.",
AddressLine2: "Apartment 1",
City: "New York",
State: "NY",
Country: "USA",
Zip: "10016",
},
ConsumerData: &splitit.ConsumerData{
FullName: "John Smith",
Email: "[email protected]",
PhoneNumber: "1-415-775-4848",
CultureName: "en-us",
},
}
initResponse, _, err := client.InstallmentPlanApi.InstallmentPlanInitiate(
// DefaultCulture could be overridden on per-request basis:
splitit.WithCulture(ctx, "en-GB"),
initReq,
)
if err != nil {
fmt.Printf("Error during initiate: %s\n", err)
os.Exit(1)
} else {
fmt.Printf("Initiate success: %t\n", initResponse.ResponseHeader.Succeeded)
}
createReq := splitit.CreateInstallmentPlanRequest{
CreditCardDetails: &splitit.CardData{
CardNumber: "411111111111111",
CardCvv: "111",
CardHolderFullName: "John Smith",
CardExpMonth: "12",
CardExpYear: "2022",
},
InstallmentPlanNumber: initResponse.InstallmentPlan.InstallmentPlanNumber,
}
createResponse, _, err := client.InstallmentPlanApi.InstallmentPlanCreate(ctx, createReq)
if err != nil {
fmt.Printf("Create error: %s\n", err)
} else {
fmt.Printf("Create success: %t\t", createResponse.ResponseHeader.Succeeded)
}
}
Flex Fields
Common usage for Splitit PHP SDK is in making necessary server-side requests as part of FlexFields product integration. The code below is an example of how SDK wrappers can be used to simplify acquiring public token and verifying payment. For more information, please visit FlexFields documentation.
Server-side code consists of two parts: acquiring public token which needs to be passed to FlexFields JS library and verifying payment before order is finalized and shipped.
Getting public token
func get_flexfields_public_token() string {
ctx := context.TODO()
client := splitit.NewSandboxAPIClient(
"_YOUR_API_KEY_",
"_YOUR_USERNAME_",
"_YOUR_PASSWORD_",
splitit.DefaultCulture("en-US"),
)
ff := splitit.NewFlexFields(client)
token, _ := ff.GetPublicToken(ctx, 350, "USD")
return token
}
Payment verification
func verify_payment(planNumber string, originalAmount float64) {
ctx := context.TODO()
client := splitit.NewSandboxAPIClient(
"_YOUR_API_KEY_",
"_YOUR_USERNAME_",
"_YOUR_PASSWORD_",
)
ff := splitit.NewFlexFields(client)
isVerified, _ := ff.VerifyPayment(ctx, planNumber, originalAmount)
if !isVerified {
// Respond to potential fraud attempt.
}
}
For detailed information on request and response procedures, please visit Splitit Web API documentation
Documentation for API Endpoints
All URIs are relative to https://webapi.production.splitit.com
Class | Method | HTTP request | Description |
---|---|---|---|
InfoApi | InfoGetLearnMoreDetails | Post /api/Merchant/GetLearnMoreDetails | |
InfrastructureApi | InfrastructureGetResources | Post /api/Infrastructure/GetResources | |
InfrastructureApi | InfrastructureGetResources2 | Get /api/Infrastructure/GetResources | |
InstallmentPlanApi | InstallmentPlanApprove | Post /api/InstallmentPlan/Approve | |
InstallmentPlanApi | InstallmentPlanCancel | Post /api/InstallmentPlan/Cancel | |
InstallmentPlanApi | InstallmentPlanChargeBack | Post /api/InstallmentPlan/ChargeBack | |
InstallmentPlanApi | InstallmentPlanCreate | Post /api/InstallmentPlan/Create | |
InstallmentPlanApi | InstallmentPlanGet | Post /api/InstallmentPlan/Get | |
InstallmentPlanApi | InstallmentPlanGet3DSecureParameters | Post /api/InstallmentPlan/Get3DSecureParameters | |
InstallmentPlanApi | InstallmentPlanGetExtended | Post /api/InstallmentPlan/GetExtended | |
InstallmentPlanApi | InstallmentPlanGetFraudStatusDisplay | Post /api/InstallmentPlan/GetFraudStatusDisplay | |
InstallmentPlanApi | InstallmentPlanGetInitiatedInstallmentPlanRequest | Post /api/InstallmentPlan/GetInitiatedInstallmentPlanRequest | |
InstallmentPlanApi | InstallmentPlanGetInitiatedUpdatePaymentData | Get /api/InstallmentPlan/GetInitiatedUpdatePaymentData | |
InstallmentPlanApi | InstallmentPlanGetLearnMoreDetails | Post /api/InstallmentPlan/GetLearnMoreDetails | |
InstallmentPlanApi | InstallmentPlanGetPGTL | Post /api/InstallmentPlan/GetPGTL | |
InstallmentPlanApi | InstallmentPlanGetSchedules | Post /api/InstallmentPlan/GetSchedules | |
InstallmentPlanApi | InstallmentPlanInitiate | Post /api/InstallmentPlan/Initiate | |
InstallmentPlanApi | InstallmentPlanRefund | Post /api/InstallmentPlan/Refund | |
InstallmentPlanApi | InstallmentPlanRequestPayment | Post /api/InstallmentPlan/RequestPayment | |
InstallmentPlanApi | InstallmentPlanStartInstallments | Post /api/InstallmentPlan/StartInstallments | |
InstallmentPlanApi | InstallmentPlanTermsAndConditions | Post /api/InstallmentPlan/TermsAndConditions | |
InstallmentPlanApi | InstallmentPlanTestCard | Post /api/InstallmentPlan/TestCard | |
InstallmentPlanApi | InstallmentPlanUpdate | Post /api/InstallmentPlan/Update | |
InstallmentPlanApi | InstallmentPlanVerifyPayment | Post /api/InstallmentPlan/Get/VerifyPayment | |
LoginApi | LoginPost | Post /api/Login |
Documentation For Models
- AddressData
- AddressData2
- AmountDetails
- AmountDetails2
- ApproveInstallmentPlanRequest
- AuthenticationType
- CancelInstallmentPlanRequest
- CardBrand
- CardData
- CardResult
- CardType
- CartData
- ChargebackRequest
- ConsumerData
- CreateInstallmentPlanLegacyResponse
- CreateInstallmentPlanRequest
- CreateInstallmentsPlanResponse
- CreateInstallmentsPlanResponseAllOf
- Currency
- CurrencyAllOf
- DelayResolution
- DisputeStatus
- Disputes
- Error
- EventsEndpoints
- ExtendedCurrency
- ExtendedCurrencyAllOf
- ExternalAuth
- FraudCheck
- FraudCheckResult
- Get3DSecureParametersRequest
- Get3DSecureParametersResponse
- GetFraudStatusDisplayRequest
- GetFraudStatusDisplayResponse
- GetInitiatedInstallmentPlanRequest
- GetInitiatedInstallmentPlanResponse
- GetInitiatedUpdatePaymentDataResponse
- GetInstallmentSchedulesRequest
- GetInstallmentsPlanExtendedResponse
- GetInstallmentsPlanResponse
- GetInstallmentsPlanSearchCriteriaRequest
- GetInstallmentsScheduleResponse
- GetPgtlRequest
- GetPgtlResponse
- GetResourcesRequest
- GetResourcesRequestContext
- GetResourcesResponse
- InitiateInstallmentPlanRequest
- InitiateInstallmentsPlanResponse
- InitiateInstallmentsPlanResponseAllOf
- Installment
- Installment2
- InstallmentPlan
- InstallmentPlanActivityStatus
- InstallmentPlanCancelationReason
- InstallmentPlanDateInfo
- InstallmentPlanInitiatedStatuses
- InstallmentPlanQueryCriteria
- InstallmentPlanResponse
- InstallmentPlanStatus
- InstallmentsPlanDateType
- ItemData
- LearnMoreDetailsRequest
- LearnMoreDetailsResponse
- LoginRequest
- LoginResponse
- MerchantRef
- MerchantRefAllOf
- Money
- MoneyFlows
- MoneyWithCurrencyCode
- OperationType
- PagingRequestHeader
- PagingResponseHeader
- PaymentFormMessage
- PaymentFormMessageType
- PaymentMethods
- PaymentToken
- PaymentWizardData
- PaymentWizardDataResponse
- PaymentWizardDataResponseAllOf
- PgtlDto
- PlanApprovalEvidence
- PlanData
- PlanStrategy
- PurchaseMethod
- ReAuthorization
- RedirectUrls
- ReferenceEntityBase
- RefundInstallmentPlanResponse
- RefundInstallmentPlanResponseAllOf
- RefundPlanRequest
- RefundStrategy
- RefundUnderCancelation
- RelationsLoad
- RequestHeader
- RequestPaymentRequest
- RequestPaymentResponse
- ResponseHeader
- Schedule
- ScheduleElements
- StartInstallmentsRequest
- SystemTextCategory
- TermsAndConditions
- TermsAndConditionsGetRequest
- TermsAndConditionsGetResponse
- TestCardRequest
- TestModes
- TouchPoint
- TransactionInfo
- TransactionResult
- TransactionStatus
- TransactionType
- UpdateInstallmentPlanRequest
- UpdateInstallmentPlanRequestAllOf
- UpdateInstallmentsPlanResponse
- UpdateInstallmentsPlanResponseAllOf
- User
- VerifyPaymentRequest
- VerifyPaymentResponse
Documentation For Authorization
Usually, login request is performed server-side, sessionId is acquired and publicToken is obtained by calling InstallmentPlanApi.InstallmentPlanInitiate. For that particular transaction, publicToken should be used on client side for maximum security.