Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "poolman"

Question

Hello all!

I have seen many people post about wanting an automatic recurring payment integration. We built one in ANZ using Stripe that allows for a choice between using Stripe and PayPal that is currently provided. Since I work for a startup, we decided to share some of our code and experience in doing this with the ANZ community (hopefully some other startups). Over the next few days I will post the code we used to make this happen.

We are currently using ANZ version 5.0.4 jQuery & MVC (seems to work with Core and 4.6.1). We have not done any work with the angular version. We have also switched our setup to use MySQL, so if you see code related to that it can be safely ignored (we will try to pull it out when posting).

We also assume you know how to set up a Stripe account, and therefore we will not cover that.

Please note: While we have spent some time working on this project, it is not yet in use on our production system. It seems to work, but there might be a few bugs floating around that we have not found yet. Since we are being nice enough to share our code with the community, if you find a bug please let us know. :D

I am getting the following error when trying to edit my entity Customer"

AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.

Mapping types:
Customer -> CustomerEditDto

App Service

public async Task<GetCustomerForEditOutput> GetCustomerForEdit(NullableIdDto<Guid> input)
{
    var output = new GetCustomerForEditOutput{ };
    if (!input.Id.HasValue)
    {
        //Creating a new customer
        output.Customer = new CustomerEditDto
        {
            IsActive = true
        };
    }
    else
    {
        //Editing an existing customer
        var customer = await _customerRepository.GetAsync(input.Id.Value);
        output.Customer = ObjectMapper.Map<CustomerEditDto>(customer);
    }
    return output;
}

GetCustomerForEditOutput

public class GetCustomerForEditOutput
{
    public CustomerEditDto Customer { get; set; }
}

CustomerEditDto

[AutoMapTo(typeof(Customer))]
public class CustomerEditDto : IPassivable
{
    /// <summary>
    /// Set null to create a new customer. Set customer's Id to update a customer
    /// </summary>
    public Guid? Id { get; set; }

    [Required]
    [MaxLength(Customer.MaxFirstNameLength)]
    public virtual string FirstName { get; set; }

    [Required]
    [MaxLength(Customer.MaxLastNameLength)]
    public virtual string LastName { get; set; }

    [Required]
    [MaxLength(Customer.MaxEmailAddressLength)]
    public virtual string EmailAddress { get; set; }

    [Required]
    [MaxLength(Customer.MaxPhoneLength)]
    public virtual string Phone { get; set; }

    public bool IsActive { get; set; }
}

I have a feeling it is something stupid, but I just can't see it. Any help would be appreciated. :D

Showing 1 to 2 of 2 entries