Skip to content

Commit

Permalink
Update package name
Browse files Browse the repository at this point in the history
  • Loading branch information
plutov committed Aug 21, 2019
1 parent f7f8c60 commit e70e544
Show file tree
Hide file tree
Showing 18 changed files with 67 additions and 69 deletions.
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Go Report Card](https://goreportcard.com/badge/plutov/PayPal-Go-SDK)](https://goreportcard.com/report/plutov/PayPal-Go-SDK)
[![Build Status](https://travis-ci.org/plutov/PayPal-Go-SDK.svg?branch=master)](https://travis-ci.org/plutov/PayPal-Go-SDK)
[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/plutov/PayPal-Go-SDK)
[![Go Report Card](https://goreportcard.com/badge/plutov/paypal)](https://goreportcard.com/report/plutov/paypal)
[![Build Status](https://travis-ci.org/plutov/paypal.svg?branch=master)](https://travis-ci.org/plutov/paypal)
[![Godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/plutov/paypal)

### Go client for PayPal REST API

Expand Down Expand Up @@ -43,15 +43,15 @@ Currently supports **v2** only, if you want to use **v1**, use **v1.1.4** git ta
* POST /v2/payments/billing-agreements/***TOKEN***/agreement-execute

### Missing endpoints
It is possible that some endpoints are missing in this SDK Client, but you can use built-in **paypalsdk** functions to perform a request: **NewClient -> NewRequest -> SendWithAuth**
It is possible that some endpoints are missing in this SDK Client, but you can use built-in **paypal** functions to perform a request: **NewClient -> NewRequest -> SendWithAuth**

### New Client

```go
import "github.com/plutov/PayPal-Go-SDK"
import "github.com/plutov/paypal"

// Create a client instance
c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
c.SetLog(os.Stdout) // Set log to terminal stdout

accessToken, err := c.GetAccessToken()
Expand All @@ -66,7 +66,7 @@ auth, err := c.GetAuthorization("2DC87612EK520411B")
### Capture authorization

```go
capture, err := c.CaptureAuthorization(authID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"}, true)
capture, err := c.CaptureAuthorization(authID, &paypal.Amount{Total: "7.00", Currency: "USD"}, true)
```

### Void authorization
Expand All @@ -78,7 +78,7 @@ auth, err := c.VoidAuthorization(authID)
### Reauthorize authorization

```go
auth, err := c.ReauthorizeAuthorization(authID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"})
auth, err := c.ReauthorizeAuthorization(authID, &paypal.Amount{Total: "7.00", Currency: "USD"})
```

### Get Sale by ID
Expand All @@ -93,7 +93,7 @@ sale, err := c.GetSale("36C38912MN9658832")
// Full
refund, err := c.RefundSale(saleID, nil)
// Partial
refund, err := c.RefundSale(saleID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"})
refund, err := c.RefundSale(saleID, &paypal.Amount{Total: "7.00", Currency: "USD"})
```

### Get Refund by ID
Expand All @@ -111,25 +111,25 @@ order, err := c.GetOrder("O-4J082351X3132253H")
### Create an Order

```go
order, err := c.CreateOrder(paypalsdk.OrderIntentCapture, []paypalsdk.PurchaseUnitRequest{paypalsdk.PurchaseUnitRequest{ReferenceID: "ref-id", Amount: paypalsdk.Amount{Total: "7.00", Currency: "USD"}}})
order, err := c.CreateOrder(paypal.OrderIntentCapture, []paypal.PurchaseUnitRequest{paypal.PurchaseUnitRequest{ReferenceID: "ref-id", Amount: paypal.Amount{Total: "7.00", Currency: "USD"}}})
```

### Update Order by ID

```go
order, err := c.UpdateOrder("O-4J082351X3132253H", []paypalsdk.PurchaseUnitRequest{})
order, err := c.UpdateOrder("O-4J082351X3132253H", []paypal.PurchaseUnitRequest{})
```

### Authorize Order

```go
auth, err := c.AuthorizeOrder(orderID, paypalsdk.AuthorizeOrderRequest{})
auth, err := c.AuthorizeOrder(orderID, paypal.AuthorizeOrderRequest{})
```

### Capture Order

```go
capture, err := c.CaptureOrder(orderID, paypalsdk.CaptureOrderRequest{})
capture, err := c.CaptureOrder(orderID, paypal.CaptureOrderRequest{})
```

### Identity
Expand All @@ -149,15 +149,15 @@ userInfo, err := c.GetUserInfo("openid")
### Create single payout to email

```go
payout := paypalsdk.Payout{
SenderBatchHeader: &paypalsdk.SenderBatchHeader{
payout := paypal.Payout{
SenderBatchHeader: &paypal.SenderBatchHeader{
EmailSubject: "Subject will be displayed on PayPal",
},
Items: []paypalsdk.PayoutItem{
paypalsdk.PayoutItem{
Items: []paypal.PayoutItem{
paypal.PayoutItem{
RecipientType: "EMAIL",
Receiver: "[email protected]",
Amount: &paypalsdk.AmountPayout{
Amount: &paypal.AmountPayout{
Value: "15.11",
Currency: "USD",
},
Expand Down Expand Up @@ -247,7 +247,7 @@ err := c.DeleteWebProfile("XP-CP6S-W9DY-96H8-MVN2")

```go
// Store CC
c.StoreCreditCard(paypalsdk.CreditCard{
c.StoreCreditCard(paypal.CreditCard{
Number: "4417119669820331",
Type: "visa",
ExpireMonth: "11",
Expand All @@ -261,8 +261,8 @@ c.StoreCreditCard(paypalsdk.CreditCard{
c.DeleteCreditCard("CARD-ID-123")

// Edit it
c.PatchCreditCard("CARD-ID-123", []paypalsdk.CreditCardField{
paypalsdk.CreditCardField{
c.PatchCreditCard("CARD-ID-123", []paypal.CreditCardField{
paypal.CreditCardField{
Operation: "replace",
Path: "/billing_address/line1",
Value: "New value",
Expand Down Expand Up @@ -290,5 +290,5 @@ Current contributors:

### Tests

* Unit tests: `go test`
* Unit tests: `go test -v ./...`
* Integration tests: `go test -tags=integration`
2 changes: 1 addition & 1 deletion authorization.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion billing.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"bytes"
Expand Down
40 changes: 19 additions & 21 deletions billing_test.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
package paypalsdk_test
package paypal_test

import (
"fmt"
"time"

pp "github.com/plutov/PayPal-Go-SDK"
)

func BillingExample() {
plan := pp.BillingPlan{
plan := BillingPlan{
Name: "Plan with Regular and Trial Payment Definitions",
Description: "Plan with regular and trial payment definitions.",
Type: "fixed",
PaymentDefinitions: []pp.PaymentDefinition{
PaymentDefinitions: []PaymentDefinition{
{
Name: "Regular payment definition",
Type: "REGULAR",
Frequency: "MONTH",
FrequencyInterval: "2",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "100",
Currency: "USD",
},
Cycles: "12",
ChargeModels: []pp.ChargeModel{
ChargeModels: []ChargeModel{
{
Type: "SHIPPING",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "10",
Currency: "USD",
},
},
{
Type: "TAX",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "12",
Currency: "USD",
},
Expand All @@ -45,31 +43,31 @@ func BillingExample() {
Type: "trial",
Frequency: "week",
FrequencyInterval: "5",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "9.19",
Currency: "USD",
},
Cycles: "2",
ChargeModels: []pp.ChargeModel{
ChargeModels: []ChargeModel{
{
Type: "SHIPPING",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "1",
Currency: "USD",
},
},
{
Type: "TAX",
Amount: pp.AmountPayout{
Amount: AmountPayout{
Value: "2",
Currency: "USD",
},
},
},
},
},
MerchantPreferences: &pp.MerchantPreferences{
SetupFee: &pp.AmountPayout{
MerchantPreferences: &MerchantPreferences{
SetupFee: &AmountPayout{
Value: "1",
Currency: "USD",
},
Expand All @@ -80,7 +78,7 @@ func BillingExample() {
MaxFailAttempts: "0",
},
}
c, err := pp.NewClient("clientID", "secretID", pp.APIBaseSandBox)
c, err := NewClient("clientID", "secretID", APIBaseSandBox)
if err != nil {
panic(err)
}
Expand All @@ -94,18 +92,18 @@ func BillingExample() {
}
err = c.ActivatePlan(planResp.ID)
fmt.Println(err)
agreement := pp.BillingAgreement{
agreement := BillingAgreement{
Name: "Fast Speed Agreement",
Description: "Agreement for Fast Speed Plan",
StartDate: pp.JSONTime(time.Now().Add(time.Hour * 24)),
Plan: pp.BillingPlan{ID: planResp.ID},
Payer: pp.Payer{
StartDate: JSONTime(time.Now().Add(time.Hour * 24)),
Plan: BillingPlan{ID: planResp.ID},
Payer: Payer{
PaymentMethod: "paypal",
},
}
resp, err := c.CreateBillingAgreement(agreement)
fmt.Println(err, resp)

bps, err := c.ListBillingPlans(pp.BillingPlanListParams{Status: "ACTIVE"})
bps, err := c.ListBillingPlans(BillingPlanListParams{Status: "ACTIVE"})
fmt.Println(err, bps)
}
6 changes: 3 additions & 3 deletions client.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"bytes"
Expand All @@ -13,7 +13,7 @@ import (
)

// NewClient returns new Client struct
// APIBase is a base API URL, for testing you can use paypalsdk.APIBaseSandBox
// APIBase is a base API URL, for testing you can use paypal.APIBaseSandBox
func NewClient(clientID string, secret string, APIBase string) (*Client, error) {
if clientID == "" || secret == "" || APIBase == "" {
return nil, errors.New("ClientID, Secret and APIBase are required to create a Client")
Expand Down Expand Up @@ -65,7 +65,7 @@ func (c *Client) SetAccessToken(token string) {
}

// SetLog will set/change the output destination.
// If log file is set paypalsdk will log all requests and responses to this Writer
// If log file is set paypal will log all requests and responses to this Writer
func (c *Client) SetLog(log io.Writer) {
c.Log = log
}
Expand Down
10 changes: 5 additions & 5 deletions doc.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/*
Package paypalsdk provides a wrapper to PayPal API (https://developer.paypal.com/webapps/developer/docs/api/).
The first thing you do is to create a Client (you can select API base URL using paypalsdk contants).
c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
Package paypal provides a wrapper to PayPal API (https://developer.paypal.com/webapps/developer/docs/api/).
The first thing you do is to create a Client (you can select API base URL using paypal contants).
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
Then you can get an access token from PayPal:
accessToken, err := c.GetAccessToken()
After you have an access token you can call built-in functions to get data from PayPal.
paypalsdk will assign all responses to go structures.
paypal will assign all responses to go structures.
*/
package paypalsdk
package paypal
6 changes: 3 additions & 3 deletions example_test.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package paypalsdk_test
package paypal_test

import paypalsdk "github.com/plutov/PayPal-Go-SDK"
import paypal "github.com/plutov/paypal"

func Example() {
// Initialize client
c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
c, err := paypal.NewClient("clientID", "secretID", paypal.APIBaseSandBox)
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion filter.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion filter_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion identity.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion integration_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// +build integration

package paypalsdk
package paypal

import (
"testing"
Expand Down
2 changes: 1 addition & 1 deletion order.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import "fmt"

Expand Down
2 changes: 1 addition & 1 deletion payout.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"fmt"
Expand Down
2 changes: 1 addition & 1 deletion sale.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import "fmt"

Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion unit_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion vault.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package paypalsdk
package paypal

import (
"fmt"
Expand Down
Loading

0 comments on commit e70e544

Please sign in to comment.