diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..397c2ca --- /dev/null +++ b/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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..046d8ad --- /dev/null +++ b/README.md @@ -0,0 +1,117 @@ +
+ +![banner](readme_files/banner.png) + +# Conekta GO + +
+ +## 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 +``` +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 +``` +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 diff --git a/charge/charge_test.go b/charge/charge_test.go index 06cdbda..1a4d250 100644 --- a/charge/charge_test.go +++ b/charge/charge_test.go @@ -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() { @@ -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) { diff --git a/mocks.go b/mocks.go index 05c77ab..0e6fdd9 100644 --- a/mocks.go +++ b/mocks.go @@ -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 } diff --git a/readme_files/banner.png b/readme_files/banner.png new file mode 100644 index 0000000..762a392 Binary files /dev/null and b/readme_files/banner.png differ diff --git a/webhook/webhook_test.go b/webhook/webhook_test.go index 7e0a1a9..6437d44 100644 --- a/webhook/webhook_test.go +++ b/webhook/webhook_test.go @@ -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)