Skip to content
This repository has been archived by the owner on Jun 11, 2023. It is now read-only.

Invoice Paid Webhook Fails #8

Open
benfoster opened this issue May 29, 2015 · 4 comments
Open

Invoice Paid Webhook Fails #8

benfoster opened this issue May 29, 2015 · 4 comments

Comments

@benfoster
Copy link

This was when running the MyNotes example. Not sure if it applies to the core code.

BillingAddress is defined as a [ComplexType] which means it has to be initialised (even if it's properties are null). The current code will fail because Invoice.BillingAddress is null:

Null value for non-nullable member. Member: 'BillingAddress'.

I guess (looking at the MyNotes example) that the solution would be to grab the user's current billing address and attach this to the invoice before saving. This would require a way to obtain the User from the Stripe Customer Id. As a temporary fix I did the following:

                case "invoice.payment_succeeded": // Occurs whenever an invoice attempts to be paid, and the payment succeeds.
                    StripeInvoice stripeInvoice = Stripe.Mapper<StripeInvoice>.MapFromJson(stripeEvent.Data.Object.ToString());
                    Invoice invoice = SaasEcom.Core.Infrastructure.Mappers.Map(stripeInvoice);
                    if (invoice != null && invoice.Total > 0)
                    {
                        // TODO get the customer billing address
                        // get the customer billing address
                        // for now we still have to instantiate the address on the invoice
                        invoice.BillingAddress = new BillingAddress();

                        await InvoiceDataService.CreateOrUpdateAsync(invoice);

                        // TODO: Send invoice by email

                    }
                    break;

Personally I'm not a fan of the dependency on ASP.NET Identity and Entity Framework which is why I probably can't use this library. That said, it's a great point of reference!

@pedropaf
Copy link
Owner

pedropaf commented Jun 3, 2015

Thanks @benfoster I just added that to the sample, this kind of things probably need to be polished as some people will want different requirements.

By the way, aren't you using EF and Identity for Fabrik? Would you suggest to have SaasEcom.Core coded against a more generic abstraction and add another library that would implement the data layer using EF + Identity but leave it open for other implementations if needed?

@benfoster
Copy link
Author

Hey @pedropaf,

No we're using RavenDB and our own hand-rolled identity system. I'm not sure about abstracting the entire data layer but certainly there is no need to be tied to Identity.

Having been working on our own implementation of recurring billing for the past week it seems that the subscriptions domain only crosses the identity system in a few discreet areas. I'd probably go for an ICustomer interface with a few of the SaasEcom required properties (Email, IP Address etc.) then leave it up to the developer to implement it.

By the end of next week I'm hoping to have completed our implementation (against RavenDB). It would be great to meet up after to discuss the experience and see if there's anything I've done that could be contributed to the project.

@pedropaf
Copy link
Owner

pedropaf commented Jun 3, 2015

@benfoster that sounds like a plan! let me know when you're done with your implementation and we can catch up and see what can be done. Also, what payment gateway are you using? Stripe? Paypal?

@benfoster
Copy link
Author

We're using Paymill currently but switching over to Stripe.

On 3 June 2015 at 10:50, Pedro Alonso [email protected] wrote:

@benfoster https://github.com/benfoster that sounds like a plan! let me
know when you're done with your implementation and we can catch up and see
what can be done. Also, what payment gateway are you using? Stripe? Paypal?


Reply to this email directly or view it on GitHub
#8 (comment).

Ben Foster
planetcloud

fabrik.
The portfolio and blogging service for creatives.
[email protected]
http://getfabrik.com

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants