Skip to content

fixed bugs in code sample of readme file #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,20 @@ Where possible, the services available on the client groups the API into logical
## Usage

``` go
import "github.com/rpip/paystack-go"
import (
"github.com/rpip/paystack-go"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try importing the package this way, it's less ambiguous.

import (
paystack "github.com/rpip/paystack-go"
"strconv"
"fmt"
)

"strconv"
"fmt"
)

apiKey := "sk_test_b748a89ad84f35c2f1a8b81681f956274de048bb"

// second param is an optional http client, allowing overriding of the HTTP client to use.
// This is useful if you're running in a Google AppEngine environment
// where the http.DefaultClient is not available.
client := paystack.NewClient(apiKey)
client := paystack.NewClient(apiKey,nil)

recipient := &TransferRecipient{
recipient := &paystack.TransferRecipient{
Type: "Nuban",
Name: "Customer 1",
Description: "Demo customer",
Expand All @@ -30,7 +34,7 @@ recipient := &TransferRecipient{

recipient1, err := client.Transfer.CreateRecipient(recipient)

req := &TransferRequest{
req := &paystack.TransferRequest{
Source: "balance",
Reason: "Delivery pickup",
Amount: 30,
Expand All @@ -46,10 +50,10 @@ if err != nil {
plans, err := client.Plan.List()

for i, plan := range plans.Values {
fmt.Printf("%+v", plan)
fmt.Printf("%+v", plan)
}

cust := &Customer{
cust := &paystack.Customer{
FirstName: "User123",
LastName: "AdminUser",
Email: "user123@gmail.com",
Expand All @@ -62,7 +66,7 @@ if err != nil {
}

// Get customer by ID
customer, err := client.Customers.Get(customer.ID)
customer, err = client.Customer.Get(strconv.Itoa(customer.ID))
```

See the test files for more examples.
Expand Down