-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add TransactionSearch API - Move merchant to client/merchant
- Loading branch information
1 parent
af4fdc1
commit 715a677
Showing
25 changed files
with
414 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package client | ||
|
||
import ( | ||
"github.com/evalphobia/go-paypal-classic/config" | ||
"github.com/evalphobia/go-paypal-classic/request" | ||
) | ||
|
||
const ( | ||
endpointSandbox = "https://api-3t.sandbox.paypal.com/nvp" | ||
endpointProduction = "https://api-3t.paypal.com/nvp" | ||
|
||
redirectSandbox = "https://www.sandbox.paypal.com/webscr" | ||
redirectProduction = "https://www.paypal.com/webscr" | ||
) | ||
|
||
// Client is base struct for PayPal Classic API | ||
type Client struct { | ||
Config *config.Config `url:",squash"` | ||
} | ||
|
||
// New creates Client with given config | ||
func New(conf *config.Config) Client { | ||
return Client{ | ||
Config: conf, | ||
} | ||
} | ||
|
||
// NewDefault creates Client with default config | ||
func NewDefault() Client { | ||
return New(config.DefaultConfig) | ||
} | ||
|
||
// Call sends HTTP request to PayPal api. | ||
func (c Client) Call(param interface{}, result interface{}) error { | ||
p := parameter{ | ||
Common: c, | ||
Extra: param, | ||
} | ||
if c.Config.IsProduction() { | ||
return request.CallPOST(endpointProduction, p, result) | ||
} | ||
return request.CallPOST(endpointSandbox, p, result) | ||
} | ||
|
||
type parameter struct { | ||
Common Client `url:",squash"` | ||
Extra interface{} `url:",squash"` | ||
} | ||
|
||
// RedirectBase returns base url of PayPal ExpressCheckout | ||
func (c Client) RedirectBase() string { | ||
if c.Config.IsProduction() { | ||
return redirectProduction | ||
} | ||
return redirectSandbox | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package merchant | ||
package client | ||
|
||
import ( | ||
"testing" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package merchant | ||
|
||
import ( | ||
"github.com/evalphobia/go-paypal-classic/client" | ||
"github.com/evalphobia/go-paypal-classic/config" | ||
) | ||
|
||
// New creates client.Client with given config | ||
func New(conf *config.Config) client.Client { | ||
return client.Client{ | ||
Config: conf, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.