コード例 #1
0
        /// <summary>
        /// This createCheckoutRequest endpoint creates a createCheckoutRequest in our system, and returns the URL that you should redirect the user to. We suggest you provide as much optional information about the user as you have available, since this will speed up our createCheckoutRequest process and increase conversion.
        /// Sezzle is able to handle the entire createCheckoutRequest process after a CreateCheckoutRequest has been provided.However, if your flow requires that the user confirm their createCheckoutRequest on your site after being approved by Sezzle, you may include the merchant_completes parameter with the createCheckoutRequest request.In this flow, Sezzle will not complete the order unless you make a createCheckoutRequest completion request.
        /// </summary>
        /// <remarks>
        ///     https://gateway.sezzle.com/v1/checkouts
        /// </remarks>
        /// <param name="createCheckoutRequest"></param>
        /// <returns></returns>
        public async Task <CreateCheckoutResponse> CreateAsync(CreateCheckoutRequest createCheckoutRequest)
        {
            var tokenTask = _authenticationEndpoint.CreateTokenAsync();

            //create url and request object
            var requestUrl = GetCheckoutsBaseUrl();

            var token    = await tokenTask;
            var response = await _sezzleHttpClient.PostAsync <CreateCheckoutRequest, CreateCheckoutResponse>(token.Token, requestUrl, createCheckoutRequest);

            return(response);
        }
コード例 #2
0
        /// <summary>
        /// Once an order is created, you can retrieve the details of the order using this endpoint.
        /// </summary>
        /// <remarks>
        ///     https://gateway.sezzle.com/v1/orders/{order_reference_id}
        /// </remarks>
        /// <returns></returns>
        public async Task <OrderDetailsResponse> GetDetailsAsync(OrderDetailsRequest orderDetailsRequest)
        {
            var tokenTask = _authenticationEndpoint.CreateTokenAsync();

            //build in the shipping information to true for all requests.  doesn't hurt to have it.
            var requestUrl = UrlStringExtensions.FormatRequestUrl(_baseConfiguration.ApiUrl, $"/orders/{orderDetailsRequest.OrderReferenceId}?include-shipping-info=true");

            var token = await tokenTask;
            //send null into the client; we have manually added the necessary request data to parameters and url.
            var response = await _sezzleHttpClient.GetAsync <OrderDetailsRequestBody, OrderDetailsResponse>(token.Token, requestUrl, null, null);

            return(response);
        }
コード例 #3
0
        /// <summary>
        /// At this time, Sezzle only allows configuration of the URL that we send our webhooks to.
        /// </summary>
        /// <remarks>
        ///     https://gateway.sezzle.com/v1/configuration
        /// </remarks>
        /// <returns></returns>
        public async Task <ConfigurationUpdateResponse> UpdateAsync(ConfigurationUpdateRequest configuration)
        {
            var tokenTask = _authenticationEndpoint.CreateTokenAsync();

            var requestUrl = UrlStringExtensions.FormatRequestUrl(_baseConfiguration.ApiUrl, "/configuration");

            var token    = await(tokenTask);
            var response = await _sezzleHttpClient.PostAsync <ConfigurationUpdateRequest, ConfigurationUpdateResponse>(token.Token, requestUrl, configuration);

            return(response);
        }
コード例 #4
0
        public async Task <HealthCheckResponse> CheckHealthAsync(HealthCheckRequest request)
        {
            var tokenTask = _authenticationEndpoint.CreateTokenAsync();

            //create url and request object
            var requestUrl = UrlStringExtensions.FormatRequestUrl(_baseConfiguration.ApiUrl, "/healthz");

            var token = await tokenTask;

            //tokens are not needed to check the health, but is done here for simplicity of code reuse.
            var response = await _sezzleHttpClient.GetAsync <HealthCheckRequest, HealthCheckResponse>(token.Token, requestUrl, request);

            return(response);
        }