etpay-dotnet-sdk 1.0.0

dotnet add package etpay-dotnet-sdk --version 1.0.0
                    
NuGet\Install-Package etpay-dotnet-sdk -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="etpay-dotnet-sdk" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="etpay-dotnet-sdk" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="etpay-dotnet-sdk" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add etpay-dotnet-sdk --version 1.0.0
                    
#r "nuget: etpay-dotnet-sdk, 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.
#:package etpay-dotnet-sdk@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=etpay-dotnet-sdk&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=etpay-dotnet-sdk&version=1.0.0
                    
Install as a Cake Tool

etpay-sdk-net

Source for the EtPay library

Installation

Requires SDK .NET 6.0 (Install the version corresponding to the operating system).

Within the address: [project directory]\Etpay.Services.WebApi

Open the appsettings.json file.

Update the Settings Section parameters with the data received from ETpay.

"Configs": {
    "API_URL": "https://<etpay-api-url>",
    "MERCHANT_CODE": "<etpay-merchant-code>",
    "MERCHANT_API_TOKEN": "9mTf8[...]pThof"
  }

Parameters:

Parameter Type Required Description
merchant_code String True Merchant code of the client
merchant_api_token String True Merchant api token of the client
api_url String True Api url of the client

Run unit tests

Within the address: [project directory]\Etpay.MSTest

Open Terminal and run:

dotnet test

Verify that the tests run correctly

Correctas! - Con error: X, Superado: X, Omitido: X, Total: X, Duración: XXX ms

Build and run

Within the address: [project directory]\Etpay.Services.WebApi

Open Terminal and run:

dotnet build
dotnet run

Check that the application is running on https://localhost:7076/swagger/index.html

Publish

Define an output directory (example: C:\etpay-sdk-net).

Within the address: [project directory]\Etpay.Services.WebApi

Open Terminal and run:

dotnet publish -c Release -o [Ruta directorio]

Using

Method to create transaction process.

  • [POST] /api/v1/Transactions/Create

Parameters:

Parameter Type Required Description
merchant_order_id string true Id used by the merchant to identify the transaction.
order_amount string true Transaction amount.
payment_completed_url string true URL to which the API will redirect in the event of a successful payment.
payment_cancellation_url string true URL to which the API will redirect in the event that the payer explicitly cancels the payment, or an unforeseen error occurs.
customer_email string false Customer email.
user_bank_code string false If this field is sent, the session starts with the bank already selected.
user_rut string false If this field is sent, the session starts with the client's RUT already entered in the respective field.
is_rut_block string false If this field is sent, the session starts with the client's RUT field already blocked. Important to consider sending user_rut together wit this attribute.
concat string false When merchants have URLs that vary based on different inputs, this value is what ETpay uses to recognize the character/symbol that concatenates those inputs.
metadata Metadata false Data showing on transaction process

Parameters Metadata: | Parameter | Type | Required | Description |--------------|---------|-----------|------------------------- | name | string | true | JSON key called "name" | value | string | true | JSON key called "value" | show | boolean | true | JSON key called "show"

Payload:

{
  "merchant_order_id": "oc123456",
  "order_amount": 1000,
  "payment_completed_url": "http://localhost:3000",
  "payment_cancellation_url": "http://localhost:3000",
  "customer_email": "example@mail.com",
  "metadata": [
    {
      "name": "Cuenta",
      "value": "11111",
      "show": true
    }
  ]
}

Response

{
  "token": "LnA0o[...]UaDgTa",
  "signature_token": "J1Bdd[...]jzsLD5",
  "terms_url": "https://<etpay-terms-url>"
}

Method to consult payment status (Require at least one argument).

  • [POST] /api/v1/Transactions/Status

Parameters:

Parameter Type Required Description
session_token string false Received when transaction was created
merchant_order_id string false Internal merchant order identifier
payment_token string false Received when transaction was created

Payload:

{
  "session_token": "eyJhbGc[...]l_TU2Y",
  "merchant_order_id": "oc123456",
  "payment_token": "J1Bdd[...]jzsLD5"
}

Response

[
  {
    "session_token": "wWkob[...]wC0L5",
    "merchant_account_bank": "cl_estado",
    "merchant_account_type": "cuenta_vista",
    "merchant_account": "99999999",
    "merchant_name": "Sandbox Developer Merchant",
    "merchant_currency": "CLP",
    "merchant_order_id": "oc123456789",
    "merchant_amount": 1,
    "user_bank": "Banco de prueba",
    "user_rut": "111111111",
    "user_account": "Cuenta Corriente 12345678",
    "payment_token": "prNZK[...]yuPfd",
    "payment_status": true,
    "payment_process": "auto",
    "iat": 918273645536271809
  }
]

Verify and decode transaction process.

  • [POST] /api/v1/Transactions/Verify

Parameters:

Parameter Type Required Description
jwt string true Received jwt on transaction succeed
signature_token string true Signature Received when transaction was created

Payload:

{
  "jwt": "eyJhbGc[...]l_TU2Y",
  "signature_token": "J1Bdd[...]jzsLD5"
}

Response

{
  "session_token": "wWkob[...]wC0L5",
  "merchant_account_bank": "cl_estado",
  "merchant_account_type": "cuenta_vista",
  "merchant_account": "99999999",
  "merchant_name": "Sandbox Developer Merchant",
  "merchant_currency": "CLP",
  "merchant_order_id": "oc123456789",
  "merchant_amount": 1,
  "user_bank": "Banco de prueba",
  "user_rut": "111111111",
  "user_account": "Cuenta Corriente 12345678",
  "payment_token": "prNZK[...]yuPfd",
  "payment_status": true,
  "payment_process": "auto",
  "iat": 918273645536271809
}

Error Handler

  • SDK common errors [POST] /api/v1/Transactions/Verify
Error Common Cause
TokenVerificationError: Invalid Signature The signature token value is incorrect for the entered token
  • SDK common errors [POST] /api/v1/Transactions/Status
Error Common Cause
ValueError: The function requires at least one argument No argument was send in this method. Is required at least one
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.0 337 5/11/2023