Skip to content

Commit

Permalink
Merge pull request #3 from TibebeJS/develop
Browse files Browse the repository at this point in the history
:WIP: Develop
  • Loading branch information
TibebeJS authored Dec 29, 2020
2 parents c37addb + 274b425 commit b7bc008
Show file tree
Hide file tree
Showing 6 changed files with 157 additions and 32 deletions.
51 changes: 51 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Contributing

When contributing to this repository, please first discuss the change you wish to make via issue,
email, or any other method with the owners of this repository before making a change or assign yourself to a card on the [Project's board](https://github.com/TibebeJS/yenepay.sdk.go/projects/1)

We'd love to accept your patches and contributions to this project.

## Pull Request Process

1. Ensure any install or build dependencies are removed before the end of the layer when doing a
build.
2. Update the README.md with details of changes to the interface, this includes new environment
variables, exposed ports, useful file locations and container parameters.
3. Increase the version numbers in any examples files and the README.md to the new version that this
Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
do not have permission to do that, you may request the second reviewer to merge it for you.


## Tasks #

You can find the project's Canban board (Todo, Tasks in Progress, etc..) here:\
[Project Board](https://github.com/TibebeJS/yenepay.sdk.go/projects/1)

## Code reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Testing ##
Before sending a pull-request, please make sure your code is well-tested and linted locally.
To run the tests, use the following command:
```
$ go test -v ./...
```

Alternatively, you may use [`goconvey`](https://github.com/smartystreets/goconvey) (Recommended)

To install [`goconvey`](https://github.com/smartystreets/goconvey), run:
```
$ go get github.com/smartystreets/goconvey
```

After installation, use the following to execute the tests:
```
$ goconvey
```

There are also GitHub Actions/Workflows on the repo to assist with these, make sure your changes do pass these workflows.
18 changes: 0 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,6 @@ And simply import in your source code.

Bugs or suggestions? Visit the [issue tracker](https://github.com/TibebeJS/yenepay.sdk.go/issues)

## Testing ##
To run the tests, use the following command:
```
$ go test -v ./...
```

Alternatively, you may use [`goconvey`](https://github.com/smartystreets/goconvey) (Recommended)

To install [`goconvey`](https://github.com/smartystreets/goconvey), run:
```
$ go get github.com/smartystreets/goconvey
```

After installation, use the following to execute the tests:
```
$ goconvey
```

## Deployment ##

> To Be Documented Soon
Expand Down
28 changes: 14 additions & 14 deletions checkout/chkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import (
)

type YenePayCheckOut struct {
checkoutBaseUrlProd string
checkoutBaseUrlSandbox string
ipnVerifyUrlProd string
ipnVerifyUrlSandbox string
pdtUrlProd string
pdtUrlSandbox string
CheckoutBaseUrlProd string
CheckoutBaseUrlSandbox string
IpnVerifyUrlProd string
IpnVerifyUrlSandbox string
PdtUrlProd string
PdtUrlSandbox string
}

func NewYenePayCheckOut() *YenePayCheckOut {
self := &YenePayCheckOut{}

self.checkoutBaseUrlProd = "https://www.yenepay.com/checkout/Home/Process/"
self.checkoutBaseUrlSandbox = "https://test.yenepay.com/Home/Process/"
self.ipnVerifyUrlProd = "https://endpoints.yenepay.com/api/verify/ipn/"
self.ipnVerifyUrlSandbox = "https://testapi.yenepay.com/api/verify/ipn/"
self.pdtUrlProd = "https://endpoints.yenepay.com/api/verify/pdt/"
self.pdtUrlSandbox = "https://testapi.yenepay.com/api/verify/pdt/"
self.CheckoutBaseUrlProd = "https://www.yenepay.com/checkout/Home/Process/"
self.CheckoutBaseUrlSandbox = "https://test.yenepay.com/Home/Process/"
self.IpnVerifyUrlProd = "https://endpoints.yenepay.com/api/verify/ipn/"
self.IpnVerifyUrlSandbox = "https://testapi.yenepay.com/api/verify/ipn/"
self.PdtUrlProd = "https://endpoints.yenepay.com/api/verify/pdt/"
self.PdtUrlSandbox = "https://testapi.yenepay.com/api/verify/pdt/"

return self
}
Expand All @@ -30,10 +30,10 @@ func (self *YenePayCheckOut) GetCheckoutUrlForExpress(checkoutOptions *CheckoutO

v, _ := query.Values(checkoutOptions.GetCartFields())

checkoutUrl := self.checkoutBaseUrlProd + "?" + v.Encode()
checkoutUrl := self.CheckoutBaseUrlProd + "?" + v.Encode()

if checkoutOptions.UseSandbox {
checkoutUrl = self.checkoutBaseUrlSandbox + "?" + v.Encode()
checkoutUrl = self.CheckoutBaseUrlSandbox + "?" + v.Encode()
}

return checkoutUrl
Expand Down
24 changes: 24 additions & 0 deletions checkout/chkout_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package checkout

import (
"testing"

"github.com/google/go-cmp/cmp"
)

func TestNewYenePayCheckOut(t *testing.T) {
checkout := NewYenePayCheckOut()

expected := &YenePayCheckOut{
"https://www.yenepay.com/checkout/Home/Process/",
"https://test.yenepay.com/Home/Process/",
"https://endpoints.yenepay.com/api/verify/ipn/",
"https://testapi.yenepay.com/api/verify/ipn/",
"https://endpoints.yenepay.com/api/verify/pdt/",
"https://testapi.yenepay.com/api/verify/pdt/",
}

if !cmp.Equal(checkout, expected) {
t.Error("NewYenePayCheckOut Constructor is not working as expected")
}
}
40 changes: 40 additions & 0 deletions checkout/pdt.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package checkout

import "encoding/json"

type PdtRequestModel struct {
PdtToken string
TransactionId string
MerchantId string
UseSandbox bool
RequestType string
}

func NewPdtRequestModel(
PdtToken string,
TransactionId string,
MerchantId string,
UseSandbox bool,
) *PdtRequestModel {
return &PdtRequestModel{
PdtToken,
TransactionId,
MerchantId,
UseSandbox,
"PDT",
}
}

func (self *PdtRequestModel) ToJSON() ([]byte, error) {
return json.Marshal(struct {
PdtToken string
TransactionId string
MerchantId string
RequestType string
}{
self.PdtToken,
self.TransactionId,
self.MerchantId,
self.RequestType,
})
}
28 changes: 28 additions & 0 deletions checkout/pdt_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package checkout

import (
"testing"

"github.com/google/go-cmp/cmp"
)

func TestNewPdtRequestModel(t *testing.T) {
pdt := NewPdtRequestModel(
"test",
"1234",
"2345",
true,
)

expected := &PdtRequestModel{
"test",
"1234",
"2345",
true,
"PDT",
}

if !cmp.Equal(pdt, expected) {
t.Error("NewPdtRequestModel Constructor is not working as expected")
}
}

0 comments on commit b7bc008

Please sign in to comment.