referralCodesController := client.ReferralCodesController()
ReferralCodesController
Use this method to determine if the referral code is valid and applicable within your Site. This method is useful for validating referral codes that are entered by a customer.
Full documentation on how to use the referrals feature in the Chargify UI can be located here.
If the referral code is valid the status code will be 200
and the referral code will be returned. If the referral code is invalid, a 404
response will be returned.
ValidateReferralCode(
ctx context.Context,
code string) (
models.ApiResponse[models.ReferralValidationResponse],
error)
Parameter | Type | Tags | Description |
---|---|---|---|
code |
string |
Query, Required | The referral code you are trying to validate |
models.ReferralValidationResponse
ctx := context.Background()
code := "code8"
apiResponse, err := referralCodesController.ValidateReferralCode(ctx, code)
if err != nil {
log.Fatalln(err)
} else {
// Printing the result and response
fmt.Println(apiResponse.Data)
fmt.Println(apiResponse.Response.StatusCode)
}
{
"referral_code": {
"id": 1032514,
"site_id": 31615,
"subscription_id": 16254270,
"code": "9b6cdw"
}
}
HTTP Status Code | Error Description | Exception Class |
---|---|---|
404 | Not Found | SingleStringErrorResponseException |