Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
fenriz07 authored Jan 8, 2021
1 parent eaa7459 commit 39a549a
Showing 1 changed file with 2 additions and 120 deletions.
122 changes: 2 additions & 120 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@

## Ejemplos de uso:

-
Ejemplo de proyecto donde esta implementado

- https://github.com/fenriz07/oneclick-golang-example todas las caracteristicas implementadas bajo Iris Framework y Docker

## Instalación
Expand Down Expand Up @@ -61,7 +58,7 @@ import (
Configura el cliente y todas las transacciones seran ejecutadas bajo este ambiente automaticamente
*/
webpayplus.SetEnvironmentIntegration()
oneclickmall.SetEnvironmentIntegration()
```

#### Producción
Expand All @@ -80,125 +77,10 @@ webpayplus.SetEnvironmentIntegration()
APIKeyID := "Código de comercio"
APIKeySecret := "Llave secreta"

webpayplus.SetEnvironmentProduction(APIKeyID,APIKeySecret)
```

### Crear una transacción Webpay Plus

Para crear una transacción basta llamar al método `transaction.Create()`

```go
/* Se deben pasar los siguentes parametros
buyOrder = numero de la orden (string)
sessionID = session (string)
amount = monto a cobrar (int)
returnURL = url de retorno que devolvera webpay
*/
Create(buyOrder string, sessionID string, amount int, returnURL string)
```

El mismo retornara el siguente `struct` de respuesta:

```go
/*TransactionCreateResponse struct with contain skeleton json to createResponse*/
type TransactionCreateResponse struct {
Token string `json:"token"`
URL string `json:"url"`
}
```

### Confirmar una transacción Webpay Plus

Cuando el comercio retoma el control mediante return_url debes confirmar y obtener el resultado de una transacción usando el método `transaction.Commit()`

```go
/* Se deben pasar los siguentes parametros
token = token devuelto por transbank (string)
*/
Commit(token string) (response.TransactionCommitResponse, error)
```

El mismo retornara el siguente `struct` de respuesta:

```go
/*TransactionCommitResponse struct with contain skeleton json to commitResponse*/
type TransactionCommitResponse struct {
Vci string `json:"vci"`
Amount int `json:"amount"`
Status string `json:"status"`
BuyOrder string `json:"buy_order"`
SessionID string `json:"session_id"`
CardDetail struct {
CardNumber string `json:"card_number"`
} `json:"card_detail"`
AccountingDate string `json:"accounting_date"`
TransactionDate time.Time `json:"transaction_date"`
AuthorizationCode string `json:"authorization_code"`
PaymentTypeCode string `json:"payment_type_code"`
ResponseCode int `json:"response_code"`
InstallmentsNumber int `json:"installments_number"`
}

```

### Obtener estado de una transacción Webpay Plus

Esta operación permite obtener el estado de la transacción en cualquier momento. En condiciones normales es probable que no se requiera ejecutar, pero en caso de ocurrir un error inesperado permite conocer el estado y tomar las acciones que correspondan. `transaction.GetStatus()`

```go
/* Se deben pasar los siguentes parametros
token = token devuelto por transbank (string)
*/
GetStatus(token string) (response.TransactionStatusResponse, error)
```

El mismo retornara el siguente `struct` de respuesta:

```go
/*TransactionCommitResponse struct with contain skeleton json to commitResponse*/
type TransactionCommitResponse struct {
Vci string `json:"vci"`
Amount int `json:"amount"`
Status string `json:"status"`
BuyOrder string `json:"buy_order"`
SessionID string `json:"session_id"`
CardDetail struct {
CardNumber string `json:"card_number"`
} `json:"card_detail"`
AccountingDate string `json:"accounting_date"`
TransactionDate time.Time `json:"transaction_date"`
AuthorizationCode string `json:"authorization_code"`
PaymentTypeCode string `json:"payment_type_code"`
ResponseCode int `json:"response_code"`
InstallmentsNumber int `json:"installments_number"`
}

```

### Reversar o Anular un pago Webpay Plus

Este método permite a todo comercio habilitado, reembolsar o anular una transacción que fue generada en Webpay Plus. `transaction.Refund()`

```go
/* Se deben pasar los siguentes parametros
token = token devuelto por transbank (string)
amount = monto a reembolsar o anular (int)
*/
func Refund(token string, amount int) (response.TransactionRefundResponse, error)
oneclickmall.SetEnvironmentProduction(APIKeyID,APIKeySecret)
```

El mismo retornara el siguente `struct` de respuesta:

```go
/*TransactionRefundResponse struct with contain skeleton json to refundResponse*/
type TransactionRefundResponse struct {
Type string `json:"type"`
AuthorizationCode string `json:"authorization_code"`
AuthorizationDate time.Time `json:"authorization_date"`
NullifiedAmount float64 `json:"nullified_amount"`
Balance float64 `json:"balance"`
ResponseCode int `json:"response_code"`
}

```
Expand Down

0 comments on commit 39a549a

Please sign in to comment.