TransbankSDK 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TransbankSDK --version 1.0.0
NuGet\Install-Package TransbankSDK -Version 1.0.0
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="TransbankSDK" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add TransbankSDK --version 1.0.0
#r "nuget: TransbankSDK, 1.0.0"
#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 TransbankSDK as a Cake Addin
#addin nuget:?package=TransbankSDK&version=1.0.0

// Install TransbankSDK as a Cake Tool
#tool nuget:?package=TransbankSDK&version=1.0.0

Build Status

Transbank .Net SDK

SDK Oficial de Transbank

Soporte:

  • .Net Standard 1.3+
  • .Net Core 1.0+
  • .Net Framework 4.6+

Dependencias

Al realizar la instalaci�n con NuGet las dependencias debieran instalarse autom�ticamente.

  • Newtonsoft 11.0.2

Instalaci�n

Instalar con NuGet

Desde una l�nea de comandos:

nuget install TransbankSDK

Desde Package Manager:

PM> Install-Package TransbankSDK

Desde Visual Studio:

  1. Abrir el explorador de soluciones.
  2. Clic derecho en un proyecto dentro de tu soluci�n.
  3. Clic en Administrar paquetes NuGet.
  4. Clic en la pesta�a Examinar y busque TransbankSDK
  5. Clic en el paquete TransbankSDK, seleccione la versi�n que desea utilizar y finalmente selecciones instalar.

Primeros pasos

Onepay

Configuraci�n del APIKEY y APISECRET

Existen 2 formas de configurar esta informaci�n, la cual es �nica para cada comercio.

  1. En la inicializaci�n de tu proyecto. (Solo una vez, al iniciar)

    Primero es necesario importar el espacio de nombres:

    using Transbank.Onepay;
    

    La clase Onepay contiene la configuraci�n b�sica de tu comercio.

    Onepay.ApiKey = "[your api key here]";
    Onepay.SharedSecret = "[your shared secret here]";
    
  2. Pasando el APIKEY y APISECRET a cada petici�n

    Utilizando un objeto Transbank.Onepay.Model.Options

     TransactionCreateResponse response = Transaction.Create(cart, new Options()
            {
                ApiKey = "[your api key here]",
                SharedSecret = "[your shared secret here]"
            });
    
Ambientes

Adicionalmente, puedes configurar el SDK para utilizar los servicios del ambiente de LIVE (Producci�n) o un MOCK alternativo.

La clase OnepayIntegrationType dentro del espacio de nombres Transbank.Onepay.Enums contiene la informaci�n de los distintos ambientes disponibles.

using Transbank.Onepay;
...
Onepay.IntegrationType = Transbank.Onepay.Enums.OnepayIntegrationType.LIVE;

El valor por defecto para el tipo de Integraci�n es siempre: TEST.

Crear una nueva transacci�n

Para iniciar un proceso de pago mediante la aplicaci�n m�vil de Onepay, primero es necesario crear la transacci�n en Transbank. Para esto se debe crear en primera instancia un objeto Transbank.Onepay.Model.ShoppingCart el cual se debe llenar con �tems Transbank.Onepay.Model.Items

using Transbank.Onepay:
using Transbank.Onepay.Model:
...

            ShoppingCart cart = new ShoppingCart();
            cart.Add(new Item(
                description: "Zapatos",
                quantity: 1,
                amount: 10000,
                additionalData: null,
                expire: 10));

El monto en el carro de compras, debe ser positivo, en caso contrario se lanzar� una excepci�n del tipo Transbank.Onepay.Exceptions.AmountException

Luego que el carro de compras contiene todos los �tems. Se crea la transacci�n:

using Transbank.Onepay:
using Transbank.Onepay.Model:
...
    TransactionCreateResponse response = Transaction.Create(cart);

El resultado entregado contiene la confirmaci�n de la creaci�n de la transacci�n, en la forma de un objeto TransactionCreateResponse.

"occ": "1807983490979289",
"ott": 64181789,
"signature": "USrtuoyAU3l5qeG3Gm2fnxKRs++jQaf1wc8lwA6EZ2o=",
"externalUniqueNumber": "f506a955-800c-4185-8818-4ef9fca97aae",
"issuedAt": 1532103896,
"qrCodeAsBase64": "QRBASE64STRING"

En el caso que no se pueda completar la transacci�n o la respuesta del servicio sea distinta a http 200 Se lanzara una excepci�n Transbank.Onepay.Exceptions.TransactionCreateResponse

Posteriormente, se debe presentar al usuario el c�digo QR y el n�mero de OTT para que pueda proceder al pago mediante la aplicaci�n m�vil.

Confirmar una transacci�n

Una vez que el usuario realiz� el pago mediante la aplicaci�n, dispones de 30 segundos para realizar la confirmaci�n de la transacci�n, de lo contrario, se realizar� autom�ticamente la reversa de la transacci�n.

 TransactionCommitResponse commitResponse = Transaction.Commit(
               createResponse.Occ, createResponse.ExternalUniqueNumber);
Anular una transacci�n

Cuando una transacci�n fue creada correctamente, se dispone de un plazo de 30 d�as para realizar la anulaci�n de esta.

 RefundCreateResponse refundResponse = Refund.Create(commitResponse.Amount,
                commitResponse.Occ, response.ExternalUniqueNumber,
                commitResponse.AuthorizationCode);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.3 is compatible.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 was computed. 
.NET Framework net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
6.0.0 7,260 9/7/2022
5.0.0 5,717 3/23/2022
4.0.1 3,100 1/18/2022
4.0.0 1,033 12/23/2021
3.0.1 11,589 6/24/2021
3.0.0 1,936 5/26/2021
2.6.2 271 3/1/2023
2.6.1 807 8/25/2021
2.6.0 17,083 12/17/2020
2.5.1 4,957 11/9/2020
2.5.0 607 10/20/2020
2.5.0-beta 387 10/20/2020
2.4.0 8,560 12/30/2019
2.3.0 990 11/21/2019
2.2.1 5,003 5/22/2019
2.2.0 759 4/8/2019
2.1.0 1,913 2/25/2019
2.0.2-ci-22627534 479 2/25/2019
2.0.1 2,043 2/8/2019
2.0.1-ci-22145435 517 2/5/2019
2.0.1-ci-22140366 477 2/5/2019
2.0.0 657 2/5/2019
1.3.1-ci-22114533 536 2/4/2019
1.3.1-ci-22110910 518 2/4/2019
1.3.1-ci-22062525 512 2/1/2019
1.3.0 919 10/23/2018
1.2.1 742 10/3/2018
1.2.0 868 8/30/2018
1.1.1 730 8/27/2018
1.1.0 763 8/23/2018
1.0.1 791 8/3/2018
1.0.0 827 8/1/2018

First Release