Exemplo n.º 1
0
        public void AddStripeCharge(AppointmentChargeAddRequest request)
        {
            string procName = "[dbo].[StripeAppointmentCharges_Insert]";

            _data.ExecuteNonQuery(
                procName,
                delegate(SqlParameterCollection inputCollection)
            {
                inputCollection.AddWithValue("@AppointmentId", request.AppointmentId);
                inputCollection.AddWithValue("@StripeChargeId", request.StripeChargeId);
            },
                null
                );
        }
Exemplo n.º 2
0
        public ActionResult <SuccessResponse> AddCharge(AppointmentChargeGetRequest request)
        {
            int          responseCode = 200;
            BaseResponse responseData = null;

            try
            {
                int    appointmentId   = request.AppointmentId;
                string paymentIntentId = request.PaymentIntentId;

                // Get charge id by payment intent id
                StripeList <Charge> charges = GetCharges(paymentIntentId);
                string chargeId             = charges.Data[0].Id;

                /* Good place to get charge info here */

                // Create a StripeChargeAddRequest
                AppointmentChargeAddRequest model = new AppointmentChargeAddRequest
                {
                    AppointmentId  = appointmentId,
                    StripeChargeId = chargeId
                };

                // Add charge to the database
                _service.AddStripeCharge(model);

                // When successful return success response
                responseData = new SuccessResponse();
            }
            catch (Exception exception)
            {
                responseCode = 500;
                responseData = new ErrorResponse($"Generic Error: {exception.Message}");
                base.Logger.LogError(exception.ToString());
            }

            return(StatusCode(responseCode, responseData));
        }