paypal

package module
v0.0.0-...-ffce287 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2017 License: MIT Imports: 10 Imported by: 0

README

Payment REST API Go client

Coverage Status GoDoc

This is a client for the Paypal REST API (https://developer.paypal.com/webapps/developer/docs/api/

Goals

  • Automated tests that don't require manual approval in Paypal account
  • Automated tests that require manual approval in a Paypal account (with a different build tag, eg. PAYPAL_APPROVED_PAYMENT_ID
  • Concurrency safety by utilizing PayPal-Request-Id

Usage

go get github.com/fundary/paypal

Import into your app and start using it:

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/fundary/paypal"
)

func main() {
	clientID := os.Getenv("PAYPAL_CLIENTID")
	if clientID == "" {
		panic("Paypal clientID is missing")
	}

	secret := os.Getenv("PAYPAL_SECRET")
	if secret == "" {
		panic("Paypal secret is missing")
	}

	client := paypal.NewClient(clientID, secret, paypal.APIBaseLive)

	payments, err := client.ListPayments(map[string]string{
		"count":   "10",
		"sort_by": "create_time",
	})
	if err != nil {
		log.Fatal("Could not retrieve payments: ", err)
	}

	fmt.Println(payments)
}

Run tests

This library use Goconvey for tests, so to run them, start Goconvey:

PAYPAL_TEST_CLIENTID=[Paypal Client ID] PAYPAL_TEST_SECRET=[Paypal Secret] goconvey

Or you can just use go test

PAYPAL_TEST_CLIENTID=[Paypal Client ID] PAYPAL_TEST_SECRET=[Paypal Secret] go test

Roadmap

Documentation

Index

Constants

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

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

Variables

View Source
var (
	AuthorizationStatePending           AuthorizationState = "pending"
	AuthorizationStateAuthorized        AuthorizationState = "authorized"
	AuthorizationStateCaptured          AuthorizationState = "captured"
	AuthorizationStatePartiallyCaptured AuthorizationState = "partially_captured"
	AuthorizationStateExpired           AuthorizationState = "expired"
	AuthorizationStateVoided            AuthorizationState = "voided"

	CaptureStatePending           CaptureState = "pending"
	CaptureStateCompleted         CaptureState = "completed"
	CaptureStateRefunded          CaptureState = "refunded"
	CaptureStatePartiallyRefunded CaptureState = "partially_refunded"

	CreditCardStateExpired CreditCardState = "expired"
	CreditCardStateOK      CreditCardState = "ok"

	OrderStatePending           OrderState = "PENDING"
	OrderStateCompleted         OrderState = "COMPLETED"
	OrderStateRefunded          OrderState = "REFUNDED"
	OrderStatePartiallyRefunded            = "PARTIALLY_REFUNDED"

	PendingReasonPayerShippingUnconfirmed PendingReason = "PAYER-SHIPPING-UNCONFIRMED"
	PendingReasonMultiCurrency            PendingReason = "MULTI-CURRENCY"
	PendingReasonRiskReview               PendingReason = "RISK-REVIEW"
	PendingReasonRegulatoryReview         PendingReason = "REGULATORY-REVIEW"
	PendingReasonVerificationRequired     PendingReason = "VERIFICATION-REQUIRED"
	PendingReasonOrder                    PendingReason = "ORDER"
	PendingReasonOther                    PendingReason = "OTHER"

	ReasonCodeChargeback                              ReasonCode = "CHARGEBACK"
	ReasonCodeGuarantee                               ReasonCode = "GUARANTEE"
	ReasonCodeBuyerComplaint                          ReasonCode = "BUYER_COMPLAINT"
	ReasonCodeRefund                                  ReasonCode = "REFUND"
	ReasonCodeUnconfirmedShippingAddress              ReasonCode = "UNCONFIRMED_SHIPPING_ADDRESS"
	ReasonCodeEcheck                                  ReasonCode = "ECHECK"
	ReasonCodeInternationalWithdrawal                 ReasonCode = "INTERNATIONAL_WITHDRAWAL"
	ReasonCodeReceivingPreferenceMandatesManualAction ReasonCode = "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"
	ReasonCodePaymentReview                           ReasonCode = "PAYMENT_REVIEW"
	ReasonCodeRegulatoryReview                        ReasonCode = "REGULATORY_REVIEW"
	ReasonCodeUnilateral                              ReasonCode = "UNILATERAL"
	ReasonCodeVerificationRequired                    ReasonCode = "VERIFICATION_REQUIRED"

	ProtectionEligibilityEligible          ProtectionEligibility = "ELIGIBLE"
	ProtectionEligibilityPartiallyEligible ProtectionEligibility = "PARTIALLY_ELIGIBLE"
	ProtectionEligibilityIneligible        ProtectionEligibility = "INELIGIBLE"

	ProtectionEligibilityTypeEligible                    ProtectionEligibilityType = "ELIGIBLE"
	ProtectionEligibilityTypeItemNotReceivedEligible     ProtectionEligibilityType = "ITEM_NOT_RECEIVED_ELIGIBLE"
	ProtectionEligibilityTypeIneligible                  ProtectionEligibilityType = "INELIGIBLE"
	ProtectionEligibilityTypeUnauthorizedPaymentEligible ProtectionEligibilityType = "UNAUTHORIZED_PAYMENT_ELIGIBLE"

	PaymentMethodCreditCard PaymentMethod = "credit_card"
	PaymentMethodPaypal     PaymentMethod = "paypal"

	PayerStatusVerified   PayerStatus = "VERIFIED"
	PayerStatusUnverified PayerStatus = "UNVERIFIED"

	PaymentStateCreated  PaymentState = "created"
	PaymentStateApproved PaymentState = "approved"
	PaymentStateFailed   PaymentState = "failed"
	PaymentStatePending  PaymentState = "pending"
	PaymentStateCanceled PaymentState = "canceled"
	PaymentStateExpired  PaymentState = "expired"

	AddressTypeResidential AddressType = "residential"
	AddressTypeBusiness    AddressType = "business"
	AddressTypeMailbox     AddressType = "mailbox"

	PaymentIntentSale      PaymentIntent = "sale"
	PaymentIntentAuthorize PaymentIntent = "authorize"
	PaymentIntentOrder     PaymentIntent = "order"

	RefundStatePending   RefundState = "pending"
	RefundStateCompleted RefundState = "completed"
	RefundStateFailed    RefundState = "failed"

	SaleStatePending           SaleState = "pending"
	SaleStateCompleted         SaleState = "completed"
	SaleStateRefunded          SaleState = "refunded"
	SaleStatePartiallyRefunded SaleState = "partially_refunded"

	SalePaymentModeInstantTransfer    SalePaymentMode = "INSTANT_TRANSFER"
	SalePaymentModeManualBankTransfer SalePaymentMode = "MANUAL_BANK_TRANSFER"
	SalePaymentModeDelayedTransfer    SalePaymentMode = "DELAYED_TRANSFER"
	SalePaymentModeEcheck             SalePaymentMode = "ECHECK"
)

Functions

func NewRequest

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

NewRequest constructs a request. If payload is not empty, it will be marshalled into JSON

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 maps to address object

type AddressType

type AddressType string

type Agreement

type Agreement struct {
	Id          string `json:"id,omitempty"`
	State       string `json:"state,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	StartDate   string `json:"start_date,omitempty"`
	//AgreementDetails
	Payer           *Payer   `json:"payer,omitempty"`
	ShippingAddress *Address `json:"shipping_address,omitempty"`
	//OverrideMerchantPreferences
	//OverrideChargeModels	[]
	Plan       *Plan   `json:"plan,omitempty"`
	CreateTime string  `json:"create_time,omitempty"`
	UpdateTime string  `json:"update_time,omitempty"`
	Links      []Links `json:"links,omitempty"`
}

type Amount

type Amount struct {
	Currency string   `json:"currency"`
	Total    string   `json:"total"`
	Details  *Details `json:"details,omitempty"`
}

Amount maps to the amount object

type AuthWithAmountReq

type AuthWithAmountReq struct {
	Amount *Amount `json:"amount"`
}

type Authorization

type Authorization struct {
	Id                        int64              `json:"-"`
	Amount                    *Amount            `json:"amount,omitempty"`
	CreateTime                *time.Time         `json:"create_time,omitempty"`
	UpdateTime                *time.Time         `json:"update_time,omitempty"`
	State                     AuthorizationState `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 maps to the authorization object

type AuthorizationState

type AuthorizationState string

type BillinAgreementReq

type BillinAgreementReq struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	StartDate   string `json:"start_date"`
	Payer       *Payer `json:"payer"`
	Plan        *Plan  `json:"plan"`
}

type Capture

type Capture struct {
	Id             int64        `json:"-"`
	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          CaptureState `json:"state,omitempty"`
	ParentPayment  string       `json:"parent_payment,omitempty"`
	ID             string       `json:"id,omitempty"`
	Links          []Links      `json:"links,omitempty"`
}

Capture maps to the capture object

type CaptureState

type CaptureState string

type Client

type Client struct {
	ClientID string
	Secret   string
	APIBase  string
	Token    *TokenResp
	// contains filtered or unexported fields
}

Client represents a Paypal REST API Client

func NewClient

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

NewClient returns a new Client struct

func NewClientForGAE

func NewClientForGAE(clientID, secret, APIBase string, c context.Context) *Client

NewClient returns a new Client struct

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 PaymentIntentAuthorize

func (*Client) CreateAgreement

func (c *Client) CreateAgreement(bar *BillinAgreementReq) (*Agreement, error)

func (*Client) CreatePayment

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

CreatePayment creates a payment in Paypal

func (*Client) ExecutePayment

func (c *Client) ExecutePayment(paymentID, payerID string, transactions []Transaction) (*ExecutePaymentResp, error)

ExecutePayment completes an approved Paypal payment that has been approved by the payer

func (*Client) GetAccessToken

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

GetAcessToken request a new access token from Paypal

func (*Client) GetAuthorization

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

GetAuthorization returns an authorization by ID

func (*Client) GetCapture

func (c *Client) GetCapture(captureID string) (*Capture, error)

GetCapture returns details about a captured payment

func (*Client) GetPayment

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

GetPayment fetches a payment in Paypal

func (*Client) GetRefund

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

GetRefund returns a refund by ID

func (*Client) GetSale

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

GetSales returns a sale by ID

func (*Client) ListPayments

func (c *Client) ListPayments(filter map[string]string) ([]Payment, error)

ListPayments retrieve payments resources from Paypal

func (Client) OverrideHttpClient

func (c Client) OverrideHttpClient(client *http.Client)

OverrideHttpClient set a new http.Client in case of been needed by other infrastructure like GAE

func (*Client) ReauthorizeAuthorization

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

ReauthorizeAuthorization reauthorize a Paypal account payment. Paypal recommends that a payment should be reauthorized after the initial 3-day honor period to ensure that funds are still available. Only paypal account payments can be re- authorized

func (*Client) RefundCapture

func (c *Client) RefundCapture(captureID string, a *Amount) (*Refund, error)

RefundCapture refund a captured payment. For partial refunds, a lower Amount object can be passed in.

func (*Client) RefundSale

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

RefundSale refunds a completed payment and accepts an optional Amount struct. If Amount is provided, a partial refund is requested, or else a full refund is made instead

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) SendString

func (c *Client) SendString(req *http.Request) (error, string)

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) SendWithAuthString

func (c *Client) SendWithAuthString(req *http.Request) (error, string)

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) StoreInVault

func (c *Client) StoreInVault(cc VaultRequest) (*VaultResponse, error)

StoreInVault will store credit card details with PayPal.

func (*Client) VoidAuthorization

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

VoidAuthorization voids a previously authorized payment. A fully captured authorization cannot be voided

type CreatePaymentResp

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

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          CreditCardState `json:"state,omitempty"`
	ValidUntil     string          `json:"valid_until,omitempty"`
}

CreditCard maps to credit_card object

type CreditCardState

type CreditCardState string

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 maps to credit_card_token object

type Details

type Details struct {
	Id               int64  `json:"-"`
	Shipping         string `json:"shipping,omitempty"`
	Subtotal         string `json:"subtotal"`
	Tax              string `json:"tax,omitempty"`
	Fee              string `json:"fee,omitempty"`
	HandlingFee      string `json:"handling_fee,omitempty"`
	Insurance        string `json:"insurance,omitempty"`
	ShippingDiscount string `json:"shipping_discount,omitempty"`
}

Details maps to the details object

type ErrorDetail

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

ErrorDetails map to error_details object

type ErrorResponse

type ErrorResponse struct {
	// 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         []ErrorDetail `json:"details"`
}

ErrorResponse is used when a response contains errors maps to error object

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type ExecutePaymentResp

type ExecutePaymentResp struct {
	Intent       PaymentIntent `json:"intent"`
	Payer        *Payer        `json:"payer"`
	Transactions []Transaction `json:"transactions"`
	Links        []Links       `json:"links"`
}

type FundingInstrument

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

FundingInstrument maps to funding_instrument object

type Item

type Item struct {
	Quantity    string `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 maps to item object

type ItemList

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

ItemList maps to item_list object

type Links struct {
	Href string `json:"href"`
	Rel  string `json:"rel"`
	// TODO: Support HyperSchema with its multiple types per field
	// TargetSchema HyperSchema `json:"targetSchema"`
	Method  string `json:"method"`
	Enctype string `json:"enctype"`
}

Links maps to links object

type ListPaymentsResp

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

type Order

type Order struct {
	ID                        string        `json:"id,omitempty"`
	PurchaseUnitReferenceID   string        `json:"purchase_unit_reference_id,omitempty"`
	CreateTime                *time.Time    `json:"create_time,omitempty"`
	UpdateTime                *time.Time    `json:"update_time,omitempty"`
	Amount                    []Amount      `json:"amount,omitempty"`
	State                     OrderState    `json:"state,omitempty"`
	PendingReason             PendingReason `json:"pending_reason,omitempty"`
	ReasonCode                ReasonCode    `json:"reason_code,omitempty"`
	ClearingTime              string        `json:"clearing_time,omitempty"`
	ProtectionEligibility     string        `json:"protection_eligibility,omitempty"`
	ProtectionEligibilityType string        `json:"protection_eligiblity_type,omitempty"`
}

Order maps to order object

type OrderState

type OrderState string

type Payer

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

Payer maps to 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       TaxIDType        `json:"tax_id_type,omitempty"`
	TaxID           string           `json:"tax_id,omitempty"`
}

PayerInfo maps to payer_info object

type PayerStatus

type PayerStatus string

type Payment

type 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"`
}

Payment maps to payment object

type PaymentError

type PaymentError struct {
	Name            string               `json:"name,omitempty"`
	DebugID         string               `json:"debug_id,omitempty"`
	Message         string               `json:"message,omitempty"`
	InformationLink string               `json:"information_link,omitempty"`
	Details         *PaymentErrorDetails `json:"details,omitempty"`
}

PaymentError maps to the error object for payments

type PaymentErrorDetails

type PaymentErrorDetails struct {
	Field string `json:"field,omitempty"`
	Issue string `json:"issue,omitempty"`
}

PaymentErrorDetails maps to the error_details object for payments

type PaymentExecution

type PaymentExecution struct {
	PayerID      string        `json:"payer_id,omitempty"`
	Transactions []Transaction `json:"transactions,omitempty"`
}

PaymentExecution maps to payment_execution object

type PaymentIntent

type PaymentIntent string

type PaymentMethod

type PaymentMethod string

type PaymentState

type PaymentState string

type PendingReason

type PendingReason string

type Plan

type Plan struct {
	Id          string     `json:"id,omitempty"`
	Name        string     `json:"name,omitempty"`
	Description string     `json:"description,omitempty"`
	Type        string     `json:"type,omitempty"`
	State       string     `json:"state,omitempty"`
	CreateTime  *time.Time `json:"create_time,omitempty"`
	UpdateTime  *time.Time `json:"update_time,omitempty"`
	//PaymentDefinitions	string    `json:"payment_definitions,omitempty"`
	//Terms				string    `json:"terms,omitempty"`
	//MerchantPreferences	string    `json:"merchant_preferences,omitempty"`
	Links []Links `json:"links,omitempty"`
}
Plan and agreement objects

Plan Object

type ProtectionEligibility

type ProtectionEligibility string

type ProtectionEligibilityType

type ProtectionEligibilityType string

type ReasonCode

type ReasonCode string

type RedirectURLs

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

RedirectURLs maps to redirect_urls object

type Refund

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

Refund maps to refund object

type RefundReq

type RefundReq struct {
	Amount *Amount `json:"amount"`
}

type RefundState

type RefundState string

type Resource

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

Resource can be either sale, authorization, capture or refund object

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                     SaleState                 `json:"state,omitempty"`
	ParentPayment             string                    `json:"parent_payment,omitempty"`
	UpdateTime                *time.Time                `json:"update_time,omitempty"`
	PaymentMode               SalePaymentMode           `json:"payment_mode,omitempty"`
	PendingReason             PendingReason             `json:"pending_reason,omitempty"`
	ReasonCode                ReasonCode                `json:"reason_code,omitempty"`
	ClearingTime              string                    `json:"clearing_time,omitempty"`
	ProtectionEligibility     ProtectionEligibility     `json:"protection_eligibility,omitempty"`
	ProtectionEligibilityType ProtectionEligibilityType `json:"protection_eligibility_type,omitempty"`
	Links                     []Links                   `json:"links,omitempty"`
}

Sale maps to sale object

type SalePaymentMode

type SalePaymentMode string

type SaleState

type SaleState string

type ShippingAddress

type ShippingAddress struct {
	RecipientName string      `json:"recipient_name,omitempty"`
	Type          AddressType `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 maps to shipping_address object

type TaxIDType

type TaxIDType string

type TokenResp

type TokenResp struct {
	Scope     string    `json:"scope"`        // "https://api.paypal.com/v1/payments/.* https://api.paypal.com/v1/vault/credit-card https://api.paypal.com/v1/vault/credit-card/.*",
	Token     string    `json:"access_token"` // "EEwJ6tF9x5WCIZDYzyZGaz6Khbw7raYRIBV_WxVvgmsG",
	Type      string    `json:"token_type"`   // "Bearer",
	AppID     string    `json:"app_id"`       // "APP-6XR95014BA15863X",
	ExpiresIn int       `json:"expires_in"`   // 28800
	ExpiresAt time.Time `json:"expires_at"`
}

TokenResp maps to the 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"`
	RelatedResources []Resource `json:"related_resources,omitempty"`
	InvoiceNumber    string     `json:"invoice_number,omitempty"`
	Custom           string     `json:"custom,omitempty"`
	SoftDescriptor   string     `json:"soft_descriptor,omitempty"`
}

Transaction maps to transaction object

type VaultRequest

type VaultRequest struct {
	CreditCard
	MerchantID     string `json:"merchant_id,omitempty"`
	ExternalCardID string `json:"external_card_id,omitempty"`
}

VaultRequest maps to vault_request object

type VaultResponse

type 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"`
}

VaultResponse maps to vault_response object

Jump to

Keyboard shortcuts

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