Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApplicationContext ¶
type ApplicationContext struct {
ShippingPreference string `json:"shipping_preference"`
}
type AuthResult ¶
type CaptureRequest ¶
type CaptureRequest struct {
OrderID string `json:"orderID"`
}
type CaptureResponse ¶
type CaptureResponse struct { ID string `json:"id"` Status string `json:"status"` PaymentSource struct { Paypal struct { EmailAddress string `json:"email_address"` AccountID string `json:"account_id"` AccountStatus string `json:"account_status"` Name struct { GivenName string `json:"given_name"` Surname string `json:"surname"` } `json:"name"` Address struct { CountryCode string `json:"country_code"` } `json:"address"` } `json:"paypal"` } `json:"payment_source"` PurchaseUnits []struct { ReferenceID string `json:"reference_id"` Shipping struct { Address struct { AddressLine1 string `json:"address_line_1"` AddressLine2 string `json:"address_line_2"` AdminArea2 string `json:"admin_area_2"` AdminArea1 string `json:"admin_area_1"` PostalCode string `json:"postal_code"` CountryCode string `json:"country_code"` } `json:"address"` } `json:"shipping"` Payments struct { Captures []struct { ID string `json:"id"` Status string `json:"status"` Amount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"amount"` FinalCapture bool `json:"final_capture"` SellerProtection struct { Status string `json:"status"` DisputeCategories []string `json:"dispute_categories"` } `json:"seller_protection"` SellerReceivableBreakdown struct { GrossAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"gross_amount"` PaypalFee struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"paypal_fee"` NetAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"net_amount"` } `json:"seller_receivable_breakdown"` InvoiceID string `json:"invoice_id"` Links []struct { Href string `json:"href"` Rel string `json:"rel"` Method string `json:"method"` } `json:"links"` CreateTime time.Time `json:"create_time"` UpdateTime time.Time `json:"update_time"` } `json:"captures"` } `json:"payments"` } `json:"purchase_units"` Payer struct { Name struct { GivenName string `json:"given_name"` Surname string `json:"surname"` } `json:"name"` EmailAddress string `json:"email_address"` PayerID string `json:"payer_id"` Address struct { CountryCode string `json:"country_code"` } `json:"address"` } `json:"payer"` Links []struct { Href string `json:"href"` Rel string `json:"rel"` Method string `json:"method"` } `json:"links"` }
Generated 2023-11-22 with json-to-go from docs (Shipping) and a real response (the rest). Note that PurchaseUnits does not contain the custom_id.
type Config ¶
type Config struct { OAuthAPI string `json:"oauth-api"` OrderAPI string `json:"order-api"` ClientID string `json:"client-id"` Secret string `json:"secret"` }
func Load ¶
Load unmarshals a json config file into a Config. If the file doesn't exist, it is created and an error is returned.
func (*Config) Auth ¶
func (config *Config) Auth() (*AuthResult, error)
Auth gets an access token from the PayPal API.
func (*Config) Capture ¶
func (config *Config) Capture(auth *AuthResult, orderID string) (*CaptureResponse, error)
Capture calls PayPal to capture the order.
func (*Config) CreateOrder ¶
func (config *Config) CreateOrder(auth *AuthResult, description, invoiceID, referenceID string, euroCents int) (*GenerateOrderResponse, error)
CreateOrder calls PayPal to set up a transaction.
type GenerateOrderResponse ¶
type OrderRequest ¶
type OrderRequest struct { Intent string `json:"intent"` PurchaseUnits []PurchaseUnit `json:"purchase_units"` ApplicationContext ApplicationContext `json:"application_context"` }
type PurchaseUnit ¶
type PurchaseUnit struct { ReferenceID string `json:"reference_id,omitempty"` // "[ 1 .. 256 ] characters: The API caller-provided external ID for the purchase unit.", omitempty because paypal fails if it exists but is empty Description string `json:"description"` // "[ 1 .. 127 ] characters: The purchase description." InvoiceID string `json:"invoice_id"` // "[ 1 .. 127 ] characters: The API caller-provided external invoice ID for this order. Appears in both the payer's transaction history and the emails that the payer receives." Amount Amount `json:"amount"` }
See https://developer.paypal.com/docs/api/orders/v2/#definition-purchase_unit
type SuccessResponse ¶
type SuccessResponse struct {
OrderID string `json:"id"`
}
Click to show internal directories.
Click to hide internal directories.