Exemple #1
0
func (w whmcsBiller) Deduct(o *BillOpts, m map[string]string) error {
	add := &addons.Addons{
		ProviderName: constants.WHMCS,
		AccountId:    o.AccountId,
	}
	if add.AccountId != "" {
		err := add.Get(m)
		if err != nil {
			return err
		}
	} else {
		return fmt.Errorf("account_id should not empty")
	}

	client := whmcs.NewClient(nil, m[constants.DOMAIN])
	a := map[string]string{
		"username":      m[constants.USERNAME],
		"password":      GetMD5Hash(m[constants.PASSWORD]),
		"clientid":      add.ProviderId,
		"description":   o.AssemblyName,
		"hours":         "1",
		"amount":        o.Consumed,
		"invoiceaction": "nextcron",
	}
	_, _, err := client.Billables.Create(a)

	return err
}
Exemple #2
0
func (w whmcsBiller) Onboard(o *BillOpts, m map[string]string) error {
	log.Debugf("User Onboarding...")

	bacc, err := NewAccounts(m)
	if err != nil {
		return err
	}

	org, err := AccountsOrg(o.AccountId, m)
	if err != nil {
		return err
	}

	sDec, _ := b64.StdEncoding.DecodeString(bacc.Password.Password)

	client := whmcs.NewClient(nil, m[constants.DOMAIN])
	a := map[string]string{
		"username":     m[constants.USERNAME],
		"password":     GetMD5Hash(m[constants.PASSWORD]),
		"firstname":    bacc.Name.FirstName,
		"lastname":     bacc.Name.LastName,
		"email":        bacc.Email,
		"address1":     "Dummy address",
		"city":         "Dummy city",
		"state":        "Dummy state",
		"postcode":     "00001",
		"country":      "IN",
		"phonenumber":  bacc.Phone.Phone,
		"password2":    string(sDec),
		"customfields": GetBase64(map[string]string{m[constants.VERTICE_EMAIL]: bacc.Email, m[constants.VERTICE_ORGID]: org.Id, m[constants.VERTICE_APIKEY]: bacc.ApiKey}),
	}

	_, res, err := client.Accounts.Create(a)
	if err != nil {
		return err
	}

	err = onboardNotify(bacc.Email, res.Body, m)
	return err
}