Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Uchencho committed Sep 24, 2023
1 parent e250bb1 commit 63c8e65
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 1 deletion.
85 changes: 85 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Pawapay

[Pawapay](https://pawapay.io/) client application written in Go

## Usage

### Install Package

```bash
go get github.com/Uchencho/pawapay
```

### Documentation

Please see [the docs](https://pawapay.io/) for the most up-to-date documentation of the Pawapay API.

#### Pawapay

- Sample Usage

```go
package main

import (
"log"
"time"

"github.com/Uchencho/pawapay"
)

func main() {
cfg := pawapay.GetConfigFromEnvVars()
cfg.AllowRequestLogging() // only for debugging, would not advise this for production. Also not necessary, read on for why

/*
You can also explicitly declare the config
cfg := pawapay.Config{
APIKey: "key",
BaseURL: "url",
LogRequest: os.Getenv("env") == "production",
LogResponse: strings.EqualFold(os.Getenv("env"), "production"),
}
*/

service := pawapay.NewService(cfg)

amt := pawapay.Amount{Currency: "GHS", Value: "500"}
description := "sending money to all my children" // this will be truncated to the first 22 characters
pn := pawapay.PhoneNumber{CountryCode: "233", Number: "704584739348"}

allCorrespondentMappings, err := pawapay.GetAllCorrespondents()
if err != nil {
log.Fatal(err)
}

// each mapping, think country, have a number of correspondents, pick the one you are trying to send money to
// ideally you will take this as an input and map to the correspondent of your choice
correspondent := allCorrespondentMappings[0].Correspondents[0]
req := pawapay.PayoutRequest{
Amount: amt,
PhoneNumber: pn,
Description: description,
PayoutId: "uniqueId",
Correspondent: correspondent.Correspondent,
}

resp, err := service.CreatePayout(time.Now, req)
if err != nil {
log.Printf("something went wrong, we will confirm through their webhook")

// even in error, depending on the error, you might have access to the annotation

log.Printf("request failed with status code %v, response payload %s, error=%s",
resp.Annotation.ResponseCode, resp.Annotation.ResponsePayload, err)
}

log.Printf("response: %+v", resp)
}


```

> **NOTE**
> You also have access to deposit and refund functionalities
> Check the `client` directory to see a sample implementation and pawapay_test.go file to see sample tests
2 changes: 1 addition & 1 deletion payout.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (s *Service) GetPayout(payoutId string) (Payout, error) {
return result, nil
}

// ResendCallback provides the functionality of resending a callback (webhook)
// ResendPayoutCallback provides the functionality of resending a callback (webhook)
// See docs https://docs.pawapay.co.uk/#operation/payoutsResendCallback for more details
func (s *Service) ResendPayoutCallback(payoutId string) (PayoutStatusResponse, error) {

Expand Down

0 comments on commit 63c8e65

Please sign in to comment.