Documentation ¶
Index ¶
- Constants
- func CreateNonce() string
- type Amount
- type Client
- func (c *Client) AuthRequest(endpoint string, b []byte, method string) (*http.Request, error)
- func (c Client) BasicRequest(endpoint string, b []byte, method string) (*http.Request, error)
- func (c Client) CreatePayment(payment Payment) (*paymentCreateResponse, error)
- func (c Client) Execute(req *http.Request) ([]byte, error)
- func (c Client) ExecutePayment(paymentID, payerID string) (*paymentCreateResponse, error)
- func (c Client) GenerateIdentityURL(state string, ret string, scope []string) (*url.URL, error)
- func (c *Client) GetAccessToken() (*oauthResponse, error)
- func (c *Client) GetTokenFromIdentityCode(code, ret string) (*IdentityAccessTokenResponse, error)
- func (c *Client) GetTokenFromRefreshToken(refresh string) (*IdentityAccessTokenResponse, error)
- func (c Client) GetUserInfo(tkn string) (*IdentityUserInfoResponse, error)
- func (c Client) PaymentInformation(paymentID string) (*paymentCreateResponse, error)
- type Details
- type IdentityAccessTokenResponse
- type IdentityAddress
- type IdentityUserInfoResponse
- type Item
- type ItemList
- type Link
- type PayPalError
- type Payer
- type PayerInfo
- type Payment
- type PaymentOptions
- type RedirectURL
- type RelatedResources
- type Sale
- type Transaction
Constants ¶
const ( SandBoxURL = "https://api.sandbox.paypal.com" LiveURL = "https://api.paypal.com" IdentitySandBoxURL = "https://www.sandbox.paypal.com" IdentityLiveURL = "https://www.paypal.com" IdentityUserInfoURL = "/v1/identity/openidconnect/userinfo/?schema=openid" PaymentCreateURL = "/v1/payments/payment" PaymentExecuteURL = "/v1/payments/payment/%v/execute" PaymentInfoURL = "/v1/payments/payment/%v" OAuthURL = "/v1/oauth2/token" IdentityURL = "/signin/authorize" IdentityTokenURL = "/v1/identity/openidconnect/tokenservice" )
Variables ¶
This section is empty.
Functions ¶
func CreateNonce ¶
func CreateNonce() string
CreateNonce creates and returns an arbitrary ID that may only be used once
Types ¶
type Client ¶
type Client struct { AccessToken *oauthResponse // contains filtered or unexported fields }
Client gopaypal client for communicating with the PayPal REST API endpoints
func (*Client) AuthRequest ¶
AuthRequest creates a basic request to the PayPal endpoint with the Authorization header set
func (Client) BasicRequest ¶
BasicRequest creates a basic request to the PayPal endpoint without the Authorization header
func (Client) CreatePayment ¶
CreatePayment creates a PayPal payment with the given payment object
func (Client) ExecutePayment ¶
func (Client) GenerateIdentityURL ¶
GenerateIdentityURL creates and returns an identity URL used to log-in into the PayPal services
func (*Client) GetAccessToken ¶
GetAccessToken gets the OAuth2 token from the PayPal endpoint
func (*Client) GetTokenFromIdentityCode ¶
func (c *Client) GetTokenFromIdentityCode(code, ret string) (*IdentityAccessTokenResponse, error)
GetTokenFromIdentityCode returns the access token from the given identity login code
func (*Client) GetTokenFromRefreshToken ¶
func (c *Client) GetTokenFromRefreshToken(refresh string) (*IdentityAccessTokenResponse, error)
GetTokenFromRefreshToken returns the access token from the given identity refresh token
func (Client) GetUserInfo ¶
func (c Client) GetUserInfo(tkn string) (*IdentityUserInfoResponse, error)
GetUserInfo gets user profile attributes by the given access token
func (Client) PaymentInformation ¶
type Details ¶
type Details struct { SubTotal string `json:"subtotal,omitempty"` Shipping string `json:"shipping,omitempty"` Tax string `json:"tax,omitempty"` HandlingFee string `json:"handling_fee,omitempty"` ShippingDiscount string `json:"shipping_discount,omitempty"` Insurance string `json:"insurance,omitempty"` GiftWrap string `json:"gift_wrap,omitempty"` }
type IdentityAddress ¶
type IdentityUserInfoResponse ¶
type IdentityUserInfoResponse struct { UserID string `json:"user_id"` Sub string `json:"sub"` Name string `json:"name"` GivenName string `json:"given_name"` FamilyName string `json:"family_name"` MiddleName string `json:"middle_name"` Picture string `json:"picture"` Email string `json:"email"` EmailVerified bool `json:"email_verified"` Gender string `json:"gender"` BirthDate string `json:"birthdate"` ZoneInfo string `json:"zoneinfo"` Locale string `json:"locale"` PhoneNumber string `json:"phone_number"` AccountVerified bool `json:"verified_account"` Address IdentityAddress `json:"address"` AccountType string `json:"account_type"` AgeRange string `json:"age_range"` PayerID string `json:"payer_id"` }
type Item ¶
type Item struct { Sku string `json:"sku,omitempty"` Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Quantity int `json:"quantity,omitempty"` Price string `json:"price,omitempty"` Currency string `json:"currency,omitempty"` Tax string `json:"tax,omitempty"` URL string `json:"url,omitempty"` }
type PayPalError ¶
type Payment ¶
type Payment struct { Intent string `json:"intent,omitempty"` Payer Payer `json:"payer,omitempty"` Transactions []Transaction `json:"transactions,omitempty"` RedirectURL RedirectURL `json:"redirect_urls,omitempty"` }
type PaymentOptions ¶
type PaymentOptions struct {
AllowedPaymentMethod string `json:"allowed_payment_method,omitempty"`
}
type RedirectURL ¶
type RelatedResources ¶
type RelatedResources struct {
Sale Sale `json:"sale,omitempty"`
}
type Sale ¶
type Sale struct { ID string `json:"id,omitempty"` PurchaseUnitReferenceID string `json:"purchase_unit_reference_id,omitempty"` Amount Amount `json:"amount,omitempty"` PaymentMode string `json:"payment_mode,omitempty"` State string `json:"state,omitempty"` ReasonCode string `json:"reason_code,omitempty"` ClearingTime string `json:"clearing_time,omitempty"` ReceiptID string `json:"receipt_id,omitempty"` }
type Transaction ¶
type Transaction struct { Amount Amount `json:"amount,omitempty"` Description string `json:"description,omitempty"` NoteToPayee string `json:"note_to_payee,omitempty"` Custom string `json:"custom,omitempty"` InvoiceNumber string `json:"invoice_number,omitempty"` SoftDescriptor string `json:"soft_descriptor,omitempty"` PaymentOptions PaymentOptions `json:"payment_options,omitempty"` ItemList ItemList `json:"item_list,omitempty"` NotifyURL string `json:"notify_url,omitempty"` OrderURL string `json:"order_url,omitempty"` RelatedResources []*RelatedResources `json:"related_resources,omitempty"` }