TransbankSDK 1.0.0
See the version list below for details.
dotnet add package TransbankSDK --version 1.0.0
NuGet\Install-Package TransbankSDK -Version 1.0.0
<PackageReference Include="TransbankSDK" Version="1.0.0" />
paket add TransbankSDK --version 1.0.0
#r "nuget: TransbankSDK, 1.0.0"
// 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
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:
- Abrir el explorador de soluciones.
- Clic derecho en un proyecto dentro de tu soluci�n.
- Clic en Administrar paquetes NuGet.
- Clic en la pesta�a Examinar y busque
TransbankSDK
- 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.
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]";
Pasando el
APIKEY
yAPISECRET
a cada petici�nUtilizando 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 | Versions 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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. |
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
- Newtonsoft.Json (>= 11.0.2)
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 |
---|---|---|
7.0.1 | 2,724 | 6/3/2024 |
7.0.0 | 144 | 5/28/2024 |
6.0.0 | 14,304 | 9/7/2022 |
5.0.0 | 7,246 | 3/23/2022 |
4.0.1 | 4,636 | 1/18/2022 |
4.0.0 | 1,432 | 12/23/2021 |
3.0.1 | 14,596 | 6/24/2021 |
3.0.0 | 2,159 | 5/26/2021 |
2.6.2 | 343 | 3/1/2023 |
2.6.1 | 864 | 8/25/2021 |
2.6.0 | 17,212 | 12/17/2020 |
2.5.1 | 5,102 | 11/9/2020 |
2.5.0 | 652 | 10/20/2020 |
2.5.0-beta | 415 | 10/20/2020 |
2.4.0 | 8,726 | 12/30/2019 |
2.3.0 | 1,048 | 11/21/2019 |
2.2.1 | 5,308 | 5/22/2019 |
2.2.0 | 802 | 4/8/2019 |
2.1.0 | 1,950 | 2/25/2019 |
2.0.2-ci-22627534 | 510 | 2/25/2019 |
2.0.1 | 2,470 | 2/8/2019 |
2.0.1-ci-22145435 | 547 | 2/5/2019 |
2.0.1-ci-22140366 | 507 | 2/5/2019 |
2.0.0 | 692 | 2/5/2019 |
1.3.1-ci-22114533 | 569 | 2/4/2019 |
1.3.1-ci-22110910 | 535 | 2/4/2019 |
1.3.1-ci-22062525 | 543 | 2/1/2019 |
1.3.0 | 965 | 10/23/2018 |
1.2.1 | 795 | 10/3/2018 |
1.2.0 | 915 | 8/30/2018 |
1.1.1 | 777 | 8/27/2018 |
1.1.0 | 792 | 8/23/2018 |
1.0.1 | 829 | 8/3/2018 |
1.0.0 | 866 | 8/1/2018 |
First Release