From b79a544462ba0fa53addae6dd85fa65156a85371 Mon Sep 17 00:00:00 2001 From: fundary Date: Sun, 21 Sep 2014 16:11:00 +0100 Subject: [PATCH 1/9] Update LICENSE Added company name --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 5eb7861..e4f477b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 fundary +Copyright (c) 2014 Raise Awareness Ltd. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 4fd9c2ba580553fc102d75a757a5cbc26cd0e4b8 Mon Sep 17 00:00:00 2001 From: Sevki Hasirci Date: Sun, 8 Feb 2015 22:34:05 +0200 Subject: [PATCH 2/9] add: Added SQL Types --- paymenttype.go | 3 +++ paypal.go | 13 +++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/paymenttype.go b/paymenttype.go index 5f792c0..afd9b1f 100644 --- a/paymenttype.go +++ b/paymenttype.go @@ -132,6 +132,7 @@ type ( // Authorization maps to the authorization object Authorization struct { + Id int64 `json:"-"` Amount *Amount `json:"amount,omitempty"` CreateTime *time.Time `json:"create_time,omitempty"` UpdateTime *time.Time `json:"update_time,omitempty"` @@ -147,6 +148,7 @@ type ( // Capture maps to the capture object Capture struct { + Id int64 `json:"-"` Amount *Amount `json:"amount,omitempty"` IsFinalCapture bool `json:"is_final_capture"` CreateTime *time.Time `json:"create_time,omitempty"` @@ -159,6 +161,7 @@ type ( // Details maps to the details object Details struct { + Id int64 `json:"-"` Shipping string `json:"shipping,omitempty"` Subtotal string `json:"subtotal"` Tax string `json:"tax,omitempty"` diff --git a/paypal.go b/paypal.go index 871b879..1454a96 100644 --- a/paypal.go +++ b/paypal.go @@ -36,15 +36,15 @@ type ( // HTTP response that caused this error Response *http.Response `json:"-"` - Name string `json:"name"` - DebugID string `json:"debug_id"` - Message string `json:"message"` - InformationLink string `json:"information_link"` - Details ErrorDetails `json:"details"` + Name string `json:"name"` + DebugID string `json:"debug_id"` + Message string `json:"message"` + InformationLink string `json:"information_link"` + Details []ErrorDetail `json:"details"` } // ErrorDetails map to error_details object - ErrorDetails struct { + ErrorDetail struct { Field string `json:"field"` Issue string `json:"issue"` } @@ -134,6 +134,7 @@ func (c *Client) Send(req *http.Request, v interface{}) error { if c := resp.StatusCode; c < 200 || c > 299 { errResp := &ErrorResponse{Response: resp} data, err := ioutil.ReadAll(resp.Body) + if err == nil && len(data) > 0 { json.Unmarshal(data, errResp) } From d590415fa3ff142650a72ef92c9f15c4b8dec79e Mon Sep 17 00:00:00 2001 From: Maciej Ka Date: Fri, 20 Mar 2015 09:52:37 +0100 Subject: [PATCH 3/9] Changed RedirectURLs to pointer, not a slice --- paymenttype.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/paymenttype.go b/paymenttype.go index afd9b1f..c2fed5e 100644 --- a/paymenttype.go +++ b/paymenttype.go @@ -271,15 +271,15 @@ type ( // Payment maps to payment object Payment struct { - Intent PaymentIntent `json:"intent"` - Payer *Payer `json:"payer"` - Transactions []Transaction `json:"transactions"` - RedirectURLs []RedirectURLs `json:"redirect_urls,omitempty"` - ID string `json:"id,omitempty"` - CreateTime *time.Time `json:"create_time,omitempty"` - State PaymentState `json:"state,omitempty"` - UpdateTime *time.Time `json:"update_time,omitempty"` - ExperienceProfileID string `json:"experience_profile_id,omitempty"` + Intent PaymentIntent `json:"intent"` + Payer *Payer `json:"payer"` + Transactions []Transaction `json:"transactions"` + RedirectURLs *RedirectURLs `json:"redirect_urls,omitempty"` + ID string `json:"id,omitempty"` + CreateTime *time.Time `json:"create_time,omitempty"` + State PaymentState `json:"state,omitempty"` + UpdateTime *time.Time `json:"update_time,omitempty"` + ExperienceProfileID string `json:"experience_profile_id,omitempty"` } // PaymentExecution maps to payment_execution object From 74657e6522e25a1d05bd205ec80283aeac63389b Mon Sep 17 00:00:00 2001 From: CoderBlaine Date: Wed, 25 Mar 2015 12:59:46 -0600 Subject: [PATCH 4/9] Added: Paypal Vault Added the ability to use the paypal vault to store credit cards in paypal --- .gitignore | 1 + vault.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 vault.go diff --git a/.gitignore b/.gitignore index daf913b..bf0289d 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,4 @@ _testmain.go *.exe *.test *.prof +*.project diff --git a/vault.go b/vault.go new file mode 100644 index 0000000..a01b0b4 --- /dev/null +++ b/vault.go @@ -0,0 +1,42 @@ +package paypal + +import ( + "fmt" + "time" +) + +// https://developer.paypal.com/docs/api/#vault + +type ( + VaultRequest struct { + CreditCard + MerchantID string `json:"merchant_id,omitempty"` + ExternalCardID string `json:"external_card_id,omitempty"` + } + + VaultResponse struct { + VaultRequest + CreateTime *time.Time `json: "create_time"` + UpdateTime *time.Time `json: "update_time"` + State string `json: "state"` + ValidUntil string `json: "valid_until"` + Links []Links `json:"links"` + } +) + +// StoreInVault will store credit card details with PayPal. +func (c *Client) StoreInVault(cc VaultRequest) (*VaultResponse, error) { + + req, err := NewRequest("POST", fmt.Sprintf("%s/vault/credit-cards", c.APIBase), cc) + + if err != nil { + return nil, err + } + v := &VaultResponse{} + + err = c.SendWithAuth(req, v) + if err != nil { + return nil, err + } + return v, nil +} From 1d44f7d417b5af794c3b58a0b8d79ff0caf71df9 Mon Sep 17 00:00:00 2001 From: CoderBlaine Date: Thu, 26 Mar 2015 08:43:31 -0600 Subject: [PATCH 5/9] Added: Vault Struct Comments Added comments to vault.go to pass golint --- vault.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/vault.go b/vault.go index a01b0b4..76581b2 100644 --- a/vault.go +++ b/vault.go @@ -8,12 +8,14 @@ import ( // https://developer.paypal.com/docs/api/#vault type ( + // VaultRequest maps to vault_request object VaultRequest struct { CreditCard MerchantID string `json:"merchant_id,omitempty"` ExternalCardID string `json:"external_card_id,omitempty"` } + // VaultResponse maps to vault_response object VaultResponse struct { VaultRequest CreateTime *time.Time `json: "create_time"` From 2339c4e50240ddc0f6b67cf4fb18e034acad7e35 Mon Sep 17 00:00:00 2001 From: jixiuf Date: Tue, 10 Nov 2015 13:36:15 +0800 Subject: [PATCH 6/9] item.quantity as int --- paymenttype.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paymenttype.go b/paymenttype.go index c2fed5e..7004f82 100644 --- a/paymenttype.go +++ b/paymenttype.go @@ -219,7 +219,7 @@ type ( // Item maps to item object Item struct { - Quantity string `json:"quantity"` + Quantity int `json:"quantity"` Name string `json:"name"` Price string `json:"price"` Currency string `json:"currency"` From 82d6109276c9ead5b76eab12c9de841d462186ad Mon Sep 17 00:00:00 2001 From: Aliaksandr Pliutau Date: Thu, 17 Dec 2015 11:29:32 +0700 Subject: [PATCH 7/9] Fixed refund GET endpoint --- refund.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/refund.go b/refund.go index b3c887d..1119d5f 100644 --- a/refund.go +++ b/refund.go @@ -4,7 +4,7 @@ import "fmt" // GetRefund returns a refund by ID func (c *Client) GetRefund(refundID string) (*Refund, error) { - req, err := NewRequest("GET", fmt.Sprintf("%s/refund/%s", c.APIBase, refundID), nil) + req, err := NewRequest("GET", fmt.Sprintf("%s/payments/refund/%s", c.APIBase, refundID), nil) if err != nil { return nil, err } From 3cfdac9bec5fb89540cc9d53f8c6105bcbb43712 Mon Sep 17 00:00:00 2001 From: Lee Benson Date: Wed, 23 Dec 2015 15:34:26 +0000 Subject: [PATCH 8/9] Update README.md - moves repo to new *permanent* home at `leebenson/paypal` - fixes casing of "PayPal" in demo usage --- README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 4e67c69..9ee75ed 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # Payment REST API Go client - -[![Coverage Status](https://coveralls.io/repos/fundary/paypal/badge.png)](https://coveralls.io/r/fundary/paypal) [![GoDoc](https://godoc.org/github.com/fundary/paypal?status.svg)](https://godoc.org/github.com/fundary/paypal) + [![GoDoc](https://godoc.org/github.com/leebenson/paypal?status.svg)](https://godoc.org/github.com/leebenson/paypal) This is a client for the Paypal REST API ([https://developer.paypal.com/webapps/developer/docs/api/](https://developer.paypal.com/webapps/developer/docs/api/) @@ -13,7 +12,7 @@ This is a client for the Paypal REST API ([https://developer.paypal.com/webapps/ ## Usage ```bash -go get github.com/fundary/paypal +go get github.com/leebenson/paypal ``` Import into your app and start using it: @@ -26,18 +25,18 @@ import ( "log" "os" - "github.com/fundary/paypal" + "github.com/leebenson/paypal" ) func main() { clientID := os.Getenv("PAYPAL_CLIENTID") if clientID == "" { - panic("Paypal clientID is missing") + panic("PayPal clientID is missing") } secret := os.Getenv("PAYPAL_SECRET") if secret == "" { - panic("Paypal secret is missing") + panic("PayPal secret is missing") } client := paypal.NewClient(clientID, secret, paypal.APIBaseLive) From c3509b40ec2e4824dbbd2b8afe31012734f1eebc Mon Sep 17 00:00:00 2001 From: Lee Benson Date: Wed, 23 Dec 2015 15:36:31 +0000 Subject: [PATCH 9/9] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index e4f477b..a07fdf5 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014 Raise Awareness Ltd. +Copyright (c) 2015 Lee Benson. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal