Beispiel #1
0
// DeleteCustomer deletes customer for a group. Here for symmetry.
func DeleteCustomer(u *url.URL, h http.Header, _ interface{}, context *models.Context) (int, http.Header, interface{}, error) {
	// do not allow customer deletion, causes losing track of transactions.
	return http.StatusForbidden, nil, nil, nil

	if err := context.IsGroupAdmin(); err != nil {
		return response.NewBadRequest(err)
	}

	if err := payment.DeleteCustomerForGroup(context.GroupName); err != nil {
		return response.NewBadRequest(err)
	}

	return response.NewDeleted()
}
Beispiel #2
0
func withStubData(endpoint string, f func(username string, groupName string, sessionID string)) {
	createURL := endpoint + EndpointCustomerCreate
	acc, _, groupName := models.CreateRandomGroupDataWithChecks()

	group, err := modelhelper.GetGroup(groupName)
	tests.ResultedWithNoErrorCheck(group, err)

	err = modelhelper.MakeAdmin(bson.ObjectIdHex(acc.OldId), group.Id)
	So(err, ShouldBeNil)

	ses, err := modelhelper.FetchOrCreateSession(acc.Nick, groupName)
	tests.ResultedWithNoErrorCheck(ses, err)

	req, err := json.Marshal(&stripe.CustomerParams{})
	tests.ResultedWithNoErrorCheck(req, err)

	res, err := rest.DoRequestWithAuth("POST", createURL, req, ses.ClientId)
	tests.ResultedWithNoErrorCheck(res, err)

	f(acc.Nick, groupName, ses.ClientId)

	So(payment.DeleteCustomerForGroup(groupName), ShouldBeNil)
}