Beispiel #1
0
    private IPaymentHandlerSubscriptionDTO CreateSubscription(string customerId, string priceId)
    {
        var subscriptionOptions = new SubscriptionCreateOptions
        {
            Customer = customerId,
            Items    = new List <SubscriptionItemOptions>
            {
                new SubscriptionItemOptions
                {
                    Price = priceId,
                },
            },
        };

        subscriptionOptions.AddExpand("latest_invoice.payment_intent");

        var subscription = _subscriptionService.Create(subscriptionOptions);

        var id     = subscription.Id;
        var status = subscription.Status;
        var latestInvoicePaymentIntentStatus       = subscription.LatestInvoice.PaymentIntent.Status;
        var latestInvoicePaymentIntentClientSecret = subscription.LatestInvoice.PaymentIntent.ClientSecret;

        var subscriptionDTO = new StripePaymentHandlerSubscriptionDTO(id, status, latestInvoicePaymentIntentStatus, latestInvoicePaymentIntentClientSecret);

        return(subscriptionDTO);
    }
    public IPaymentHandlerSubscriptionDTO CreateSubscriptionError(string errorMessage)
    {
        var subscriptionError = new StripePaymentHandlerSubscriptionDTO(errorMessage);

        return(subscriptionError);
    }