paypalsdk

package module
v0.0.0-...-1d1d6e5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2016 License: MIT Imports: 9 Imported by: 0

README

Build Status Godoc

GO client for PayPal REST API

Coverage

  • POST /v1/oauth2/token
  • POST /v1/payments/payment
  • GET /v1/payments/payment/ID
  • GET /v1/payments/payment
  • GET /v1/payments/authorization/ID
  • POST /v1/payments/authorization/ID/capture
  • POST /v1/payments/authorization/ID/void
  • POST /v1/payments/authorization/ID/reauthorize
  • GET /v1/payments/sale/ID
  • POST /v1/payments/sale/ID/refund
  • GET /v1/payments/refund/ID
  • GET /v1/payments/orders/ID
  • POST /v1/payments/orders/ID/authorize
  • POST /v1/payments/orders/ID/capture
  • POST /v1/payments/orders/ID/do-void
  • POST /v1/identity/openidconnect/tokenservice
  • GET /v1/identity/openidconnect/userinfo/?schema=SCHEMA
  • POST /v1/payments/payouts?sync_mode=true

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

Create Client

import "github.com/logpacker/PayPal-Go-SDK"
// Create a client instance
c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
c.SetLog(os.Stdout) // Set log to terminal stdout

Get access token

// When you will have authorization_code you can get an access_token
accessToken, err := c.GetAccessToken()

Create direct paypal payment

// Now we can create a paypal payment
amount := paypalsdk.Amount{
    Total:    "7.00",
    Currency: "USD",
}
redirectURI := "http://example.com/redirect-uri"
cancelURI := "http://example.com/cancel-uri"
description := "Description for this payment"
paymentResult, err := c.CreateDirectPaypalPayment(amount, redirectURI, cancelURI, description)

// If paymentResult.ID is not empty and paymentResult.Links is also
// we can redirect user to approval page (paymentResult.Links[1]).
// After approval user will be redirected to return_url from Request with PaymentID

Create any payment

p := paypalsdk.Payment{
    Intent: "sale",
    Payer: &paypalsdk.Payer{
        PaymentMethod: "credit_card",
        FundingInstruments: []paypalsdk.FundingInstrument{paypalsdk.FundingInstrument{
            CreditCard: &paypalsdk.CreditCard{
                Number:      "4111111111111111",
                Type:        "visa",
                ExpireMonth: "11",
                ExpireYear:  "2020",
                CVV2:        "777",
                FirstName:   "John",
                LastName:    "Doe",
            },
        }},
    },
    Transactions: []paypalsdk.Transaction{paypalsdk.Transaction{
        Amount: &paypalsdk.Amount{
            Currency: "USD",
            Total:    "7.00",
        },
        Description: "My Payment",
    }},
    RedirectURLs: &paypalsdk.RedirectURLs{
        ReturnURL: "http://...",
        CancelURL: "http://...",
    },
}
paymentResponse, err := client.CreatePayment(p)

Execute approved payment

// And the last step is to execute approved payment
// paymentID is returned via return_url
paymentID := "PAY-17S8410768582940NKEE66EQ"
// payerID is returned via return_url
payerID := "7E7MGXCWTTKK2"
executeResult, err := c.ExecuteApprovedPayment(paymentID, payerID)

Get payment by ID

// Get created payment info
payment, err := c.GetPayment(paymentID)

Get list of payments

// Get all payments slice
payments, err := c.GetPayments()

Get authorization by ID

authID := "2DC87612EK520411B"
auth, err := c.GetAuthorization(authID)

Capture authorization

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

Void authorization

auth, err := c.VoidAuthorization(authID)

Reauthorize authorization

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

Get Sale by ID

saleID := "36C38912MN9658832"
sale, err := c.GetSale(saleID)

Refund Sale by ID

// Full
refund, err := c.RefundSale(saleID, nil)
// Partial
refund, err := c.RefundSale(saleID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"})

Get Refund by ID

orderID := "O-4J082351X3132253H"
refund, err := c.GetRefund(orderID)

Get Order by ID

order, err := c.GetOrder(orderID)

Authorize Order

auth, err := c.AuthorizeOrder(orderID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"})

Capture Order

capture, err := c.CaptureOrder(orderID, &paypalsdk.Amount{Total: "7.00", Currency: "USD"}, true, nil)

Void Order

order, err := c.VoidOrder(orderID)

Identity

// Retreive tolen by authorization code
token, err := c.GrantNewAccessTokenFromAuthCode("<Authorization-Code>", "http://example.com/myapp/return.php")
// ... or by refresh token
token, err := c.GrantNewAccessTokenFromRefreshToken("<Refresh-Token>")

Retreive user information

userInfo, err := c.GetUserInfo("openid")

Create single payout to email

payout := paypalsdk.Payout{
    SenderBatchHeader: &paypalsdk.SenderBatchHeader{
        EmailSubject: "Subject will be displayed on PayPal",
    },
    Items: []paypalsdk.PayoutItem{
        paypalsdk.PayoutItem{
            RecipientType: "EMAIL",
            Receiver:      "single-email-payout@mail.com",
            Amount: &paypalsdk.AmountPayout{
                Value:    "15.11",
                Currency: "USD",
            },
            Note:         "Optional note",
            SenderItemID: "Optional Item ID",
        },
    },
}

payoutResp, err := c.CreateSinglePayout(payout)

How to Contribute

  • Fork a repository
  • Add/Fix something
  • Run ./before-commit.sh to check that tests passed and code is formatted well
  • Push to your repository
  • Create pull request

Documentation

Overview

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)

Then you can get an access token from PayPal:

accessToken, err := c.GetAccessToken()

After you have an access token you can call built-in funtions to get data from PayPal. paypalsdk will assign all responses to go structures.

Example
package main

import (
	paypalsdk "github.com/logpacker/PayPal-Go-SDK"
)

func main() {
	// Initialize client
	c, err := paypalsdk.NewClient("clientID", "secretID", paypalsdk.APIBaseSandBox)
	if err != nil {
		panic(err)
	}

	// Retreive access token
	_, err = c.GetAccessToken()
	if err != nil {
		panic(err)
	}

	// Create credit card payment
	p := paypalsdk.Payment{
		Intent: "sale",
		Payer: &paypalsdk.Payer{
			PaymentMethod: "credit_card",
			FundingInstruments: []paypalsdk.FundingInstrument{paypalsdk.FundingInstrument{
				CreditCard: &paypalsdk.CreditCard{
					Number:      "4111111111111111",
					Type:        "visa",
					ExpireMonth: "11",
					ExpireYear:  "2020",
					CVV2:        "777",
					FirstName:   "John",
					LastName:    "Doe",
				},
			}},
		},
		Transactions: []paypalsdk.Transaction{paypalsdk.Transaction{
			Amount: &paypalsdk.Amount{
				Currency: "USD",
				Total:    "7.00",
			},
			Description: "My Payment",
		}},
		RedirectURLs: &paypalsdk.RedirectURLs{
			ReturnURL: "http://...",
			CancelURL: "http://...",
		},
	}
	_, err = c.CreatePayment(p)
	if err != nil {
		panic(err)
	}
}
Output:

Index

Examples

Constants

View Source
const (
	// APIBaseSandBox points to the sandbox (for testing) version of the API
	APIBaseSandBox = "https://api.sandbox.paypal.com"

	// APIBaseLive points to the live version of the API
	APIBaseLive = "https://api.paypal.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	Line1       string `json:"line1"`
	Line2       string `json:"line2,omitempty"`
	City        string `json:"city"`
	CountryCode string `json:"country_code"`
	PostalCode  string `json:"postal_code,omitempty"`
	State       string `json:"state,omitempty"`
	Phone       string `json:"phone,omitempty"`
}

Address https://developer.paypal.com/webapps/developer/docs/api/#address-object

type Amount

type Amount struct {
	Currency string `json:"currency"`
	Total    string `json:"total"`
}

Amount https://developer.paypal.com/webapps/developer/docs/api/#amount-object

type AmountPayout

type AmountPayout struct {
	Currency string `json:"currency"`
	Value    string `json:"value"`
}

AmountPayout https://developer.paypal.com/docs/integration/direct/create-single-payout/

type Authorization

type Authorization struct {
	Amount                    *Amount    `json:"amount,omitempty"`
	CreateTime                *time.Time `json:"create_time,omitempty"`
	UpdateTime                *time.Time `json:"update_time,omitempty"`
	State                     string     `json:"state,omitempty"`
	ParentPayment             string     `json:"parent_payment,omitempty"`
	ID                        string     `json:"id,omitempty"`
	ValidUntil                *time.Time `json:"valid_until,omitempty"`
	Links                     []Links    `json:"links,omitempty"`
	ClearingTime              string     `json:"clearing_time,omitempty"`
	ProtectionEligibility     string     `json:"protection_eligibility,omitempty"`
	ProtectionEligibilityType string     `json:"protection_eligibility_type,omitempty"`
}

Authorization rhttps://developer.paypal.com/webapps/developer/docs/api/#authorization-object

type BatchHeader

type BatchHeader struct {
	Amount            *AmountPayout      `json:"amount,omitempty"`
	Fees              *AmountPayout      `json:"fees,omitempty"`
	PayoutBatchID     string             `json:"payout_batch_id,omitempty"`
	BatchStatus       string             `json:"batch_status,omitempty"`
	TimeCreated       *time.Time         `json:"time_created,omitempty"`
	TimeCompleted     *time.Time         `json:"time_completed,omitempty"`
	SenderBatchHeader *SenderBatchHeader `json:"sender_batch_header,omitempty"`
}

BatchHeader https://developer.paypal.com/docs/integration/direct/create-single-payout/

type Capture

type Capture struct {
	Amount         *Amount    `json:"amount,omitempty"`
	IsFinalCapture bool       `json:"is_final_capture"`
	CreateTime     *time.Time `json:"create_time,omitempty"`
	UpdateTime     *time.Time `json:"update_time,omitempty"`
	State          string     `json:"state,omitempty"`
	ParentPayment  string     `json:"parent_payment,omitempty"`
	ID             string     `json:"id,omitempty"`
	Links          []Links    `json:"links,omitempty"`
}

Capture https://developer.paypal.com/webapps/developer/docs/api/#capture-object

type Client

type Client struct {
	ClientID string
	Secret   string
	APIBase  string
	Log      io.Writer // If user set log file name all requests will be logged there
	Token    *TokenResponse
	// contains filtered or unexported fields
}

Client represents a Paypal REST API Client

func NewClient

func NewClient(clientID string, secret string, APIBase string) (*Client, error)

NewClient returns new Client struct APIBase is a base API URL, for testing you can use paypalsdk.APIBaseSandBox

func (*Client) AuthorizeOrder

func (c *Client) AuthorizeOrder(orderID string, amount *Amount) (*Authorization, error)

AuthorizeOrder - Use this call to authorize an order. Endpoint: POST /v1/payments/orders/ID/authorize

func (*Client) CaptureAuthorization

func (c *Client) CaptureAuthorization(authID string, a *Amount, isFinalCapture bool) (*Capture, error)

CaptureAuthorization captures and process an existing authorization. To use this method, the original payment must have Intent set to "authorize" Endpoint: POST /v1/payments/authorization/ID/capture

func (*Client) CaptureOrder

func (c *Client) CaptureOrder(orderID string, amount *Amount, isFinalCapture bool, currency *Currency) (*Capture, error)

CaptureOrder - Use this call to capture a payment on an order. To use this call, an original payment call must specify an intent of order. Endpoint: POST /v1/payments/orders/ID/capture

func (*Client) CreateDirectPaypalPayment

func (c *Client) CreateDirectPaypalPayment(amount Amount, redirectURI string, cancelURI string, description string) (*PaymentResponse, error)

CreateDirectPaypalPayment sends request to create a payment with payment_method=paypal CreatePayment is more common function for any kind of payment Endpoint: POST /v1/payments/payment

func (*Client) CreatePayment

func (c *Client) CreatePayment(p Payment) (*CreatePaymentResp, error)

CreatePayment creates a payment in Paypal Depending on the payment_method and the funding_instrument, you can use the payment resource for direct credit card payments, stored credit card payments, or PayPal account payments. Endpoint: POST /v1/payments/payment

func (*Client) CreateSinglePayout

func (c *Client) CreateSinglePayout(p Payout) (*PayoutResponse, error)

CreateSinglePayout submits a payout with a synchronous API call, which immediately returns the results of a PayPal payment. For email payout set RecipientType: "EMAIL" and receiver email into Receiver Endpoint: POST /v1/payments/payouts?sync_mode=true

func (*Client) ExecuteApprovedPayment

func (c *Client) ExecuteApprovedPayment(paymentID string, payerID string) (*ExecuteResponse, error)

ExecuteApprovedPayment - Use this call to execute (complete) a PayPal payment that has been approved by the payer. You can optionally update transaction information when executing the payment by passing in one or more transactions. Endpoint: POST /v1/payments/payment/paymentID/execute

func (*Client) GetAccessToken

func (c *Client) GetAccessToken() (*TokenResponse, error)

GetAccessToken returns struct of TokenResponse No need to call SetAccessToken to apply new access token for current Client Endpoint: POST /v1/oauth2/token

func (*Client) GetAuthorization

func (c *Client) GetAuthorization(authID string) (*Authorization, error)

GetAuthorization returns an authorization by ID Endpoint: GET /v1/payments/authorization/ID

func (*Client) GetOrder

func (c *Client) GetOrder(orderID string) (*Order, error)

GetOrder retreives order by ID Endpoint: GET /v1/payments/orders/ID

func (*Client) GetPayment

func (c *Client) GetPayment(paymentID string) (*Payment, error)

GetPayment gets a payment from PayPal Endpoint: GET /v1/payments/payment/ID

func (*Client) GetPayments

func (c *Client) GetPayments() ([]Payment, error)

GetPayments retrieve payments resources from Paypal Endpoint: GET /v1/payments/payment/

func (*Client) GetRefund

func (c *Client) GetRefund(refundID string) (*Refund, error)

GetRefund by ID Use it to look up details of a specific refund on direct and captured payments. Endpoint: GET /v1/payments/refund/ID

func (*Client) GetSale

func (c *Client) GetSale(saleID string) (*Sale, error)

GetSale returns a sale by ID Use this call to get details about a sale transaction. Note: This call returns only the sales that were created via the REST API. Endpoint: GET /v1/payments/sale/ID

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(schema string) (*UserInfo, error)

GetUserInfo - Use this call to retrieve user profile attributes. Endpoint: GET /v1/identity/openidconnect/userinfo/?schema=<Schema> Pass the schema that is used to return as per openidconnect protocol. The only supported schema value is openid.

func (*Client) GrantNewAccessTokenFromAuthCode

func (c *Client) GrantNewAccessTokenFromAuthCode(code string, redirectURI string) (*TokenResponse, error)

GrantNewAccessTokenFromAuthCode - Use this call to grant a new access token, using the previously obtained authorization code. Endpoint: POST /v1/identity/openidconnect/tokenservice

func (*Client) GrantNewAccessTokenFromRefreshToken

func (c *Client) GrantNewAccessTokenFromRefreshToken(refreshToken string) (*TokenResponse, error)

GrantNewAccessTokenFromRefreshToken - Use this call to grant a new access token, using a refresh token. Endpoint: POST /v1/identity/openidconnect/tokenservice

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, payload interface{}) (*http.Request, error)

NewRequest constructs a request Convert payload to a JSON

func (*Client) ReauthorizeAuthorization

func (c *Client) ReauthorizeAuthorization(authID string, a *Amount) (*Authorization, error)

ReauthorizeAuthorization reauthorize a Paypal account payment. PayPal recommends to reauthorize payment after ~3 days Endpoint: POST /v1/payments/authorization/ID/reauthorize

func (*Client) RefundSale

func (c *Client) RefundSale(saleID string, a *Amount) (*Refund, error)

RefundSale refunds a completed payment. Use this call to refund a completed payment. Provide the sale_id in the URI and an empty JSON payload for a full refund. For partial refunds, you can include an amount. Endpoint: POST /v1/payments/sale/ID/refund

func (*Client) Send

func (c *Client) Send(req *http.Request, v interface{}) error

Send makes a request to the API, the response body will be unmarshaled into v, or if v is an io.Writer, the response will be written to it without decoding

func (*Client) SendWithAuth

func (c *Client) SendWithAuth(req *http.Request, v interface{}) error

SendWithAuth makes a request to the API and apply OAuth2 header automatically. If the access token soon to be expired, it will try to get a new one before making the main request

func (*Client) SetAccessToken

func (c *Client) SetAccessToken(token string) error

SetAccessToken sets saved token to current client

func (*Client) SetLog

func (c *Client) SetLog(log io.Writer) error

SetLog will set/change the output destination. If log file is set paypalsdk will log all requests and responses to this Writer

func (*Client) VoidAuthorization

func (c *Client) VoidAuthorization(authID string) (*Authorization, error)

VoidAuthorization voids a previously authorized payment Endpoint: POST /v1/payments/authorization/ID/void

func (*Client) VoidOrder

func (c *Client) VoidOrder(orderID string) (*Order, error)

VoidOrder - Use this call to void an existing order. Note: An order cannot be voided if payment has already been partially or fully captured. Endpoint: POST /v1/payments/orders/ID/do-void

type CreatePaymentResp

type CreatePaymentResp struct {
	*Payment
	Links []Links `json:"links"`
}

CreatePaymentResp contains Payment Info and Links slice

type CreditCard

type CreditCard struct {
	ID             string   `json:"id,omitempty"`
	PayerID        string   `json:"payer_id,omitempty"`
	Number         string   `json:"number"`
	Type           string   `json:"type"`
	ExpireMonth    string   `json:"expire_month"`
	ExpireYear     string   `json:"expire_year"`
	CVV2           string   `json:"cvv2,omitempty"`
	FirstName      string   `json:"first_name,omitempty"`
	LastName       string   `json:"last_name,omitempty"`
	BillingAddress *Address `json:"billing_address,omitempty"`
	State          string   `json:"state,omitempty"`
	ValidUntil     string   `json:"valid_until,omitempty"`
}

CreditCard https://developer.paypal.com/webapps/developer/docs/api/#creditcard-object

type CreditCardToken

type CreditCardToken struct {
	CreditCardID string `json:"credit_card_id"`
	PayerID      string `json:"payer_id,omitempty"`
	Last4        string `json:"last4,omitempty"`
	ExpireYear   string `json:"expire_year,omitempty"`
	ExpireMonth  string `json:"expire_month,omitempty"`
}

CreditCardToken https://developer.paypal.com/webapps/developer/docs/api/#creditcardtoken-object

type Currency

type Currency struct {
	Currency string `json:"currency,omitempty"`
	Value    string `json:"value,omitempty"`
}

Currency https://developer.paypal.com/webapps/developer/docs/api/#currency-object

type ErrorDetail

type ErrorDetail struct {
	Field string `json:"field"`
	Issue string `json:"issue"`
}

ErrorDetail https://developer.paypal.com/webapps/developer/docs/api/#errordetails-object

type ErrorResponse

type ErrorResponse struct {
	Response        *http.Response `json:"-"`
	Name            string         `json:"name"`
	DebugID         string         `json:"debug_id"`
	Message         string         `json:"message"`
	InformationLink string         `json:"information_link"`
	Details         []ErrorDetail  `json:"details"`
}

ErrorResponse https://developer.paypal.com/webapps/developer/docs/api/#error-object

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error method implementation for ErrorResponse struct

type ExecuteResponse

type ExecuteResponse struct {
	ID           string        `json:"id"`
	Links        []PaymentLink `json:"links"`
	State        string        `json:"state"`
	Transactions []Transaction `json:"transactions,omitempty"`
}

ExecuteResponse structure

type FundingInstrument

type FundingInstrument struct {
	CreditCard      *CreditCard      `json:"credit_card,omitempty"`
	CreditCardToken *CreditCardToken `json:"credit_card_token,omitempty"`
}

FundingInstrument https://developer.paypal.com/webapps/developer/docs/api/#fundinginstrument-object

type Item

type Item struct {
	Quantity    int    `json:"quantity"`
	Name        string `json:"name"`
	Price       string `json:"price"`
	Currency    string `json:"currency"`
	SKU         string `json:"sku,omitempty"`
	Description string `json:"description,omitempty"`
	Tax         string `json:"tax,omitempty"`
}

Item https://developer.paypal.com/webapps/developer/docs/api/#item-object

type ItemList

type ItemList struct {
	Items           []Item           `json:"items,omitempty"`
	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}

ItemList struct

type Links struct {
	Href    string `json:"href"`
	Rel     string `json:"rel,omitempty"`
	Method  string `json:"method,omitempty"`
	Enctype string `json:"enctype,omitempty"`
}

Links https://developer.paypal.com/webapps/developer/docs/api/#itemlist-object

type ListPaymentsResp

type ListPaymentsResp struct {
	Payments []Payment `json:"payments"`
}

ListPaymentsResp slice of payments

type Order

type Order struct {
	ID            string     `json:"id,omitempty"`
	CreateTime    *time.Time `json:"create_time,omitempty"`
	UpdateTime    *time.Time `json:"update_time,omitempty"`
	State         string     `json:"state,omitempty"`
	Amount        *Amount    `json:"amount,omitempty"`
	PendingReason string     `json:"pending_reason,omitempty"`
	ParentPayment string     `json:"parent_payment,omitempty"`
	Links         []Links    `json:"links,omitempty"`
}

Order https://developer.paypal.com/webapps/developer/docs/api/#order-object

type Payer

type Payer struct {
	PaymentMethod      string              `json:"payment_method"`
	FundingInstruments []FundingInstrument `json:"funding_instruments,omitempty"`
	PayerInfo          *PayerInfo          `json:"payer_info,omitempty"`
	Status             string              `json:"payer_status,omitempty"`
}

Payer https://developer.paypal.com/webapps/developer/docs/api/#payer-object

type PayerInfo

type PayerInfo struct {
	Email           string           `json:"email,omitempty"`
	FirstName       string           `json:"first_name,omitempty"`
	LastName        string           `json:"last_name,omitempty"`
	PayerID         string           `json:"payer_id,omitempty"`
	Phone           string           `json:"phone,omitempty"`
	ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
	TaxIDType       string           `json:"tax_id_type,omitempty"`
	TaxID           string           `json:"tax_id,omitempty"`
}

PayerInfo https://developer.paypal.com/webapps/developer/docs/api/#itemlist-object

type Payment

type Payment struct {
	Intent              string        `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               string        `json:"state,omitempty"`
	UpdateTime          *time.Time    `json:"update_time,omitempty"`
	ExperienceProfileID string        `json:"experience_profile_id,omitempty"`
}

Payment https://developer.paypal.com/webapps/developer/docs/api/#payment-object

type PaymentLink struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
}

PaymentLink https://developer.paypal.com/webapps/developer/docs/api/#paymentlink-object

type PaymentResponse

type PaymentResponse struct {
	ID    string        `json:"id"`
	Links []PaymentLink `json:"links"`
}

PaymentResponse structure

type Payout

type Payout struct {
	SenderBatchHeader *SenderBatchHeader `json:"sender_batch_header"`
	Items             []PayoutItem       `json:"items"`
}

Payout https://developer.paypal.com/docs/integration/direct/create-single-payout/

type PayoutItem

type PayoutItem struct {
	RecipientType string        `json:"recipient_type"`
	Receiver      string        `json:"receiver"`
	Amount        *AmountPayout `json:"amount"`
	Note          string        `json:"note,omitempty"`
	SenderItemID  string        `json:"sender_item_id,omitempty"`
}

PayoutItem https://developer.paypal.com/docs/integration/direct/create-single-payout/

type PayoutItemResponse

type PayoutItemResponse struct {
	PayoutItemID      string        `json:"payout_item_id"`
	TransactionID     string        `json:"transaction_id"`
	TransactionStatus string        `json:"transaction_status"`
	PayoutBatchID     string        `json:"payout_batch_id,omitempty"`
	PayoutItemFee     *AmountPayout `json:"payout_item_fee,omitempty"`
	PayoutItem        *PayoutItem   `json:"payout_item"`
	TimeProcessed     *time.Time    `json:"time_processed,omitempty"`
	Links             []Links       `json:"links"`
}

PayoutItemResponse https://developer.paypal.com/docs/integration/direct/create-single-payout/

type PayoutResponse

type PayoutResponse struct {
	BatchHeader *BatchHeader         `json:"batch_header"`
	Items       []PayoutItemResponse `json:"items"`
	Links       []Links              `json:"links"`
}

PayoutResponse https://developer.paypal.com/docs/integration/direct/create-single-payout/

type RedirectURLs

type RedirectURLs struct {
	ReturnURL string `json:"return_url,omitempty"`
	CancelURL string `json:"cancel_url,omitempty"`
}

RedirectURLs https://developer.paypal.com/webapps/developer/docs/api/#redirecturls-object

type Refund

type Refund struct {
	ID            string     `json:"id,omitempty"`
	Amount        *Amount    `json:"amount,omitempty"`
	CreateTime    *time.Time `json:"create_time,omitempty"`
	State         string     `json:"state,omitempty"`
	CaptureID     string     `json:"capture_id,omitempty"`
	ParentPayment string     `json:"parent_payment,omitempty"`
	UpdateTime    *time.Time `json:"update_time,omitempty"`
}

Refund https://developer.paypal.com/webapps/developer/docs/api/#refund-object

type Related struct {
	Sale          *Sale          `json:"sale,omitempty"`
	Authorization *Authorization `json:"authorization,omitempty"`
	Order         *Order         `json:"order,omitempty"`
	Capture       *Capture       `json:"capture,omitempty"`
	Refund        *Refund        `json:"refund,omitempty"`
}

Related https://developer.paypal.com/docs/api/payments/#definition-related

type Sale

type Sale struct {
	ID                        string     `json:"id,omitempty"`
	Amount                    *Amount    `json:"amount,omitempty"`
	Description               string     `json:"description,omitempty"`
	CreateTime                *time.Time `json:"create_time,omitempty"`
	State                     string     `json:"state,omitempty"`
	ParentPayment             string     `json:"parent_payment,omitempty"`
	UpdateTime                *time.Time `json:"update_time,omitempty"`
	PaymentMode               string     `json:"payment_mode,omitempty"`
	PendingReason             string     `json:"pending_reason,omitempty"`
	ReasonCode                string     `json:"reason_code,omitempty"`
	ClearingTime              string     `json:"clearing_time,omitempty"`
	ProtectionEligibility     string     `json:"protection_eligibility,omitempty"`
	ProtectionEligibilityType string     `json:"protection_eligibility_type,omitempty"`
	Links                     []Links    `json:"links,omitempty"`
}

Sale https://developer.paypal.com/webapps/developer/docs/api/#sale-object

type SenderBatchHeader

type SenderBatchHeader struct {
	EmailSubject string `json:"email_subject"`
}

SenderBatchHeader https://developer.paypal.com/docs/integration/direct/create-single-payout/

type ShippingAddress

type ShippingAddress struct {
	RecipientName string `json:"recipient_name,omitempty"`
	Type          string `json:"type,omitempty"`
	Line1         string `json:"line1"`
	Line2         string `json:"line2,omitempty"`
	City          string `json:"city"`
	CountryCode   string `json:"country_code"`
	PostalCode    string `json:"postal_code,omitempty"`
	State         string `json:"state,omitempty"`
	Phone         string `json:"phone,omitempty"`
}

ShippingAddress https://developer.paypal.com/webapps/developer/docs/api/#shippingaddredd-object

type TokenResponse

type TokenResponse struct {
	RefreshToken string `json:"refresh_token"`
	Token        string `json:"access_token"`
	Type         string `json:"token_type"`
	ExpiresIn    int64  `json:"expires_in"`
}

TokenResponse is for API response for the /oauth2/token endpoint

type Transaction

type Transaction struct {
	Amount           *Amount   `json:"amount"`
	Description      string    `json:"description,omitempty"`
	ItemList         *ItemList `json:"item_list,omitempty"`
	InvoiceNumber    string    `json:"invoice_number,omitempty"`
	Custom           string    `json:"custom,omitempty"`
	SoftDescriptor   string    `json:"soft_descriptor,omitempty"`
	RelatedResources []Related `json:"related_resources,omitempty"`
}

Transaction https://developer.paypal.com/webapps/developer/docs/api/#transaction-object

type UserInfo

type UserInfo struct {
	ID              string   `json:"user_id"`
	Name            string   `json:"name"`
	GivenName       string   `json:"given_name"`
	FamilyName      string   `json:"family_name"`
	Email           string   `json:"email"`
	Verified        bool     `json:"verified,omitempty"`
	Gender          string   `json:"gender,omitempty"`
	BirthDate       string   `json:"birthdate,omitempty"`
	ZoneInfo        string   `json:"zoneinfo,omitempty"`
	Locale          string   `json:"locale,omitempty"`
	Phone           string   `json:"phone_number,omitempty"`
	Address         *Address `json:"address,omitempty"`
	VerifiedAccount bool     `json:"verified_account,omitempty"`
	AccountType     string   `json:"account_type,omitempty"`
	AgeRange        string   `json:"age_range,omitempty"`
	PayerID         string   `json:"payer_id,omitempty"`
}

UserInfo https://developer.paypal.com/webapps/developer/docs/api/#userinfo-object

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL