Persilsoft.Culqi.Blazor 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Persilsoft.Culqi.Blazor --version 1.0.1
NuGet\Install-Package Persilsoft.Culqi.Blazor -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Persilsoft.Culqi.Blazor" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Persilsoft.Culqi.Blazor --version 1.0.1
#r "nuget: Persilsoft.Culqi.Blazor, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Persilsoft.Culqi.Blazor as a Cake Addin
#addin nuget:?package=Persilsoft.Culqi.Blazor&version=1.0.1

// Install Persilsoft.Culqi.Blazor as a Cake Tool
#tool nuget:?package=Persilsoft.Culqi.Blazor&version=1.0.1

Persilsoft.Culqi.Blazor

Proporciona un bot�n como componente para abrir la interfaz de Culqi Custom Checkout. El resultado final ser� la obtenci�n de un token que deber� ser procesado por su Backend utilizando la Api de Culqi a trav�s de la generaci�n de Cargos �nicos.


Example

Primero, debe incluir el siguiente Script en su p�gina:

<script src="https://js.culqi.com/checkout-js"></script>

Nota: Recuerde que para integrarse con Culqi Custom Checkout debe contar con su llave p�blica que puede obtenerla a trav�s del CulqiPanel.

Luego, usted debe registrar en el contendor de dependencias los servicios requeridos:

Action<CulqiOptions> CulqiOptionsConfigurator = options =>
builder.Configuration.GetSection(CulqiOptions.SectionKey).Bind(options);

builder.Services.AddCulqiService(CulqiOptionsConfigurator);

En el archivo de configuraci�n appsettings.json, debe configurar la opciones de Culqi:

{
    "Culqi": {
        "PublicKey": "xxxxxxxxxxxx",
        "StoreName": "Persilsoft Store",
        "Tarjeta": true,
        "Yape": true,
        "BancaMovil": false,
        "Agente": false,
        "Billetera": false,
        "Cuotealo": false,
        "Lang": "auto",
        "Installments": false,
        "HiddenCulqiLogo": false,
        "HiddenToolBarAmount": false,
        "MenuType": "sidebar",
        "BannerColor": "#c00",
        "ButtonBackground": "#ffc107",
        "MenuColor": "tomato",
        "LinksColor": "green",
        "ButtonTextColor": "#333",
        "PriceColor": "red"
    }
}

D�nde:
PublicKey: Es la llave publica de la tienda virtual
StoreName: Nombre de la tienda virtual
Tarjeta: Indica si acepta tarjeta de cr�dito o d�bido como forma de pago
Yape: Indica si acepta Yape como forma de pago
BancaMovil: Indica si acepta Banca m�vil
Agente: Indica si acepta Agente
Billetera: Indica si acepta billeteras como forma de pago
Cuotealo: Indica si acepta Cuotealo del BCP como forma de pago
Lang: Idioma del checkout. Ejemplo: "auto","en","es"
Installments: Indica si se activa o no la opci�n de pago en cuotas
HiddenCulqiLogo: Indica si se oculta o no el logo de Culqi
HiddenToolBarAmount: Indica si se oculta o no el monto
MenuType: Establece el tipo de men�(sidebar, sliderTop, select)
BannerColor: Establece el color del baner
ButtonBackground: Establece el color de fondo del bot�n pagar
MenuColor: Establece el color de texto del men� cuando se activan las opciones
LinksColor: Establece el color de texto de los links
ButtonTextColor: Establece el color de texto de los botones
PriceColor: Establece el color de texto del precio

Ahora, necesita utilizar el componente CulqiCheckoutComponent y pasarle algunos par�metros

@page "/checkout"

<PageTitle>Checkout</PageTitle>

<h1>Checkout</h1>
<input @bind=amount type="number" step="0.50" placeholder="Ingrese monto" class="form-control mb-2 d-inline" style="width: 200px" />
<CulqiCheckoutComponent Modal=true
                        PayText="Realizar pago"
                        ButtonCssClass="btn btn-warning"
                        ToPay="ToPay"
                        TokenReceived="TokenReceived"
                        ErrorReceived="ErrorReceived" />
<div class="alert alert-@alertType">
    @message
</div>

Donde:
Modal: Indica si el checkout es modal incrustado o no
PayText: Texto para el bot�n Pagar
ButtonCssClass: Clases css para el bot�n Pagar
ToPay: Manejador de evento que mostrar� el checkout
TokenReceived: M�todo callback por donde se recibe el token generado que ser� enviado al Backend
ErrorReceived: M�todo callback por donde se recibe el error que pueda ocurrir al generar el token

A continuaci�n, se muestra el ejemplo con el Code-behind:

@code {
    private decimal amount;
    private CulqiCheckoutComponent culqi;
    private string alertType;
    private string message;

    private async void ToPay()
    {
        if (amount <= 0)
        {
            alertType = "warning";
            message = "Debe ingresar un monto > 0.";
        }
        else
        {
            long culqiAmount = (long)(amount * 100);

            await culqi.ShowCulqiCheckout(currency: "PEN", amount: culqiAmount, order: null, email: null, logo: null);
        }
    }

    private async Task TokenReceived(CulqiCheckoutEventArgs e)
    {
        message = $"Token: {e.Token} (Debe enviar este token al backend a trav�s de un gateway HttpClient)";
        alertType = "info";
        await Task.CompletedTask;
    }

    private async Task ErrorReceived(CheckoutErrorEventArgs e)
    {
        Console.WriteLine($"merchantMessage: {e.MerchantMessage}");
        Console.WriteLine($"userMessage: {e.UserMessage}");
        await Task.CompletedTask;
    }
}

Para el env�o del token al Backend puede revisar la documentaci�n de Persilsoft.Culqi.Server

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 135 5/22/2024
1.0.5 240 4/24/2024
1.0.4 86 4/18/2024
1.0.3 84 4/17/2024
1.0.2 88 4/16/2024
1.0.1 84 4/16/2024
1.0.0 81 4/16/2024