Skip to content

Commit

Permalink
conekta-go V1.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
leofischer committed Jan 15, 2020
1 parent df4c0e4 commit 16cc937
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,3 @@
## [1.0.0](https://github.com/conekta/conekta-php/releases/tag/v1.0.0) - 2020-01-20
### Feature
- Initial Release of conekta-go
117 changes: 117 additions & 0 deletions README.md
@@ -0,0 +1,117 @@
<div align="center">

![banner](readme_files/banner.png)

# Conekta GO

</div>

## Requeriments

conekta-go is tested against against all officially supported releases (Go 1.12 and 1.13).

## Installation

You can import conekta-go directly from github as follows:

```go
import (
conekta "github.com/conekta/conekta-go"
"github.com/conekta/conekta-go/order"
"github.com/conekta/conekta-go/customer"
"time"
)
```

## Usage

```go
conekta.APIKey = "key_ZLy4aP2szht1HqzkCezDEA"

customerParams := &conekta.CustomerParams{
Name: "Cándida Eréndira",
Email: "la.candida.erendira@gmail.com",
Phone: "55-5555-5555",
}

lineItemParams := &conekta.LineItemsParams{
Name: "Naranjas Robadas",
UnitPrice: 10000,
Quantity: 2,
}

chargeParams := &conekta.ChargeParams{
PaymentMethodParams: &conekta.PaymentMethodParams{
Type: "oxxo_cash",
ExpiresAt: time.Now().AddDate(0, 0, 90).Unix(),
},
}

orderParams := &conekta.OrderParams{}
orderParams.Currency = "MXN"
orderParams.CustomerInfo = customerParams
orderParams.LineItems = append(op.LineItems, lineItemParams)
orderParams.Charges = append(op.Charges, chargeParams)

ord, err := order.Create(orderParams)
if err != nil {
code := err.(conekta.Error).Details[0].Code
//do something
} else {
orderId := order.ID
chargeId := o.Charges.Data[0].ID
oxxoReference := o.Charges.Data[0].PaymentMethod.Reference
//do something
}
```

## Run Tests

```bash
go test -v ./...
```

## Changelog

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

## Contributing

1. Fork the repository
2. Clone the repository
```bash
git clone git@github.com:yourUserName/conekta-go.git
```
3. Create a branch
```bash
git checkout develop
git pull origin develop
# You should choose the name of your branch
git checkout -b <feature/my_branch>
```
4. Make necessary changes and commit those changes
```bash
git add .
git commit -m "my changes"
```
5. Push changes to GitHub
```bash
git push origin <feature/my_branch>
```
6. Submit your changes for review, create a pull request

To create a pull request, you need to have made your code changes on a separate branch. This branch should be named like this: **feature/my_feature** or **fix/my_fix**.

Make sure that, if you add new features to our library, be sure to add the corresponding **unit tests**.

If you go to your repository on GitHub, you’ll see a Compare & pull request button. Click on that button.

***

## License

Developed in Mexico by [Conekta](https://www.conekta.com). Available with [MIT License](LICENSE).

## We are always hiring!

If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills. Send us your CV and GitHub to quieroser@conekta.com
5 changes: 3 additions & 2 deletions charge/charge_test.go
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/conekta/conekta-go/customer"
"github.com/conekta/conekta-go/order"
"github.com/conekta/conekta-go/paymentsource"
"time"
)

func init() {
Expand Down Expand Up @@ -93,8 +94,8 @@ func TestFind(t *testing.T) {
assert.Equal(t, res.PaymentMethod.Last4, "4242")
assert.Equal(t, res.PaymentMethod.Brand, "visa")
assert.Equal(t, res.PaymentMethod.Name, "Jorge Lopez")
assert.Equal(t, res.PaymentMethod.ExpMonth, "12")
assert.Equal(t, res.PaymentMethod.ExpYear, "19")
assert.Equal(t, res.PaymentMethod.ExpMonth, time.Now().Format("01"))
assert.Equal(t, res.PaymentMethod.ExpYear, time.Now().AddDate(1, 0, 0).Format("06"))
}

func TestFindError(t *testing.T) {
Expand Down
8 changes: 3 additions & 5 deletions mocks.go
Expand Up @@ -197,17 +197,15 @@ func (p *TokenParams) Mock() *TokenParams {
func (p *CardParams) Mock() *CardParams {
p.Number = "4242424242424242"
p.Name = "Eduardo Enriquez"
p.ExpMonth = "12"
p.ExpYear = "2020"
p.ExpMonth = time.Now().Format("01")
p.ExpYear = time.Now().AddDate(1, 0, 0).Format("2006")
p.Cvc = "123"
return p
}

// Mock fills WebhookParams with dummy data
func (p *WebhookParams) Mock() *WebhookParams {
p.URL = "c.testgowebhook.com"
p.DevelopmentEnabled = true
p.ProductionEnabled = false
p.URL = "https://c.testgowebhook.com"
return p
}

Expand Down
Binary file added readme_files/banner.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion webhook/webhook_test.go
Expand Up @@ -30,7 +30,7 @@ func TestCreateError(t *testing.T) {
func TestUpdate(t *testing.T) {
whp := &conekta.WebhookParams{}
wh, _ := Create(whp.Mock())
newURL := "anotherurl.com"
newURL := "https://www.anotherurl.com"
whp.URL = newURL
wh, err := Update(wh.ID, whp)
assert.Equal(t, newURL, wh.URL)
Expand Down

0 comments on commit 16cc937

Please sign in to comment.