Create
Create a credit grant
client.V1.CreditGrants.New(ctx, body) (*DataIDV1CreditGrantNewResponse, error)
post/v1/credits/createGrant
Create a new credit grant
Parameters
bodyCustomerIDfieldExpiresAtfieldGrantAmountfieldNamefieldPaidAmountfieldPriorityfieldCreditGrantTypefieldCustomFieldsfieldEffectiveAtfieldInvoiceDatefieldProductIDsfieldReasonfieldRolloverSettingsfieldUniquenessKeyfieldV1CreditGrantNewParams
Returns
V1CreditGrantNewResponsestruct
package main
import (
"context"
"fmt"
"time"
"github.com/Metronome-Industries/metronome-go"
"github.com/Metronome-Industries/metronome-go/option"
)
func main() {
client := metronome.NewClient(
option.WithBearerToken("My Bearer Token"),
)
creditGrant, err := client.V1.CreditGrants.New(context.TODO(), metronome.V1CreditGrantNewParams{
CustomerID: metronome.F("9b85c1c1-5238-4f2a-a409-61412905e1e1"),
ExpiresAt: metronome.F(time.Now()),
GrantAmount: metronome.F(metronome.V1CreditGrantNewParamsGrantAmount{
Amount: metronome.F(1000.000000),
CreditTypeID: metronome.F("5ae401dc-a648-4b49-9ac3-391bb5bc4d7b"),
}),
Name: metronome.F("Acme Corp Promotional Credit Grant"),
PaidAmount: metronome.F(metronome.V1CreditGrantNewParamsPaidAmount{
Amount: metronome.F(5000.000000),
CreditTypeID: metronome.F("2714e483-4ff1-48e4-9e25-ac732e8f24f2"),
}),
Priority: metronome.F(0.500000),
CreditGrantType: metronome.F("trial"),
EffectiveAt: metronome.F(time.Now()),
Reason: metronome.F("Incentivize new customer"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", creditGrant.Data)
}
200 Example
{
"data": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
}