Documentation ¶
Index ¶
- Constants
- type API
- type APICredentials
- type AccessTokeResp
- type Client
- func (c *Client) DoExpressCheckoutPayment(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error)
- func (c *Client) FiltrateUserRefundDispute(ctx context.Context, disputes []DisputeItem) (userRefundDisputes []DisputeItem)
- func (c *Client) GetAccessToken(ctx context.Context) (string, error)
- func (c *Client) GetExpressCheckoutDetails(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error)
- func (c *Client) GetRefundTransaction(ctx context.Context, startTime, endTime time.Time) (transactions []TransactionInfo, err error)
- func (c *Client) GetTransaction(ctx context.Context, transactionID string, startTime, endTime time.Time) (transaction TransactionInfo, err error)
- func (c *Client) GetUserRefundDispute(ctx context.Context, disputeID string) (detail ShowDisputeDetailsResp, isUserRefund bool)
- func (c *Client) GetUserRefundDisputedDetails(ctx context.Context, disputes []DisputeItem) (userRefundDisputeDetailByInvoiceID map[string]ShowDisputeDetailsResp, ...)
- func (c *Client) ListDisputes(ctx context.Context) (disputeItems []DisputeItem, error error)
- func (c *Client) ListOnePageDisputes(ctx context.Context, pagePageToken string) (disputeItems []DisputeItem, nextPageToken string, error error)
- func (c *Client) ListOnePageDisputesV2(ctx context.Context, pagePageToken string, startTime, endTime time.Time) (disputeItems []DisputeItem, nextPageToken string, error error)
- func (c *Client) NvpBase(method NVPMethod) NVPBase
- func (c *Client) SetExpressCheckout(ctx context.Context, req SetExpressCheckoutReq) (SetExpressCheckoutResp, error)
- func (c *Client) ShowDisputeDetails(ctx context.Context, disputeID string) (detail ShowDisputeDetailsResp, error error)
- type Config
- type DisputeItem
- type DisputedTransaction
- type ErrorResp
- type GetExpressCheckoutDetailsReq
- type GetExpressCheckoutDetailsResp
- type HATEOASLink
- type ListDisputesReq
- type ListDisputesResp
- type NVPBase
- type NVPMethod
- type NVPVersion
- type SetExpressCheckoutReq
- type SetExpressCheckoutResp
- type ShowDisputeDetailsResp
- type TransactionInfo
- type TransactionSearchReq
- type TransactionSearchResp
- type TransactionStatus
Constants ¶
const ( SetExpressCheckout NVPMethod = "SetExpressCheckout" GetExpressCheckoutDetails NVPMethod = "GetExpressCheckoutDetails" DoExpressCheckoutPayment NVPMethod = "DoExpressCheckoutPayment" Version124 NVPVersion = "124.0" )
const ( // App const name App string = "paypal_app" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // GetAccessToken AccessToken ... GetAccessToken(ctx context.Context) (string, error) // 争议查询 ListDisputes(ctx context.Context) (disputeItems []DisputeItem, error error) ShowDisputeDetails(ctx context.Context, disputeID string) (detail ShowDisputeDetailsResp, error error) // 交易查询 //https://developer.paypal.com/docs/api/transaction-search/v1/#transactions_get GetTransaction(ctx context.Context, transactionID string, startTime, endTime time.Time) (transaction TransactionInfo, err error) GetRefundTransaction(ctx context.Context, startTime, endTime time.Time) (transactions []TransactionInfo, err error) //NVP SetExpressCheckout(ctx context.Context, req SetExpressCheckoutReq) (SetExpressCheckoutResp, error) GetExpressCheckoutDetails(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error) DoExpressCheckoutPayment(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error) }
API is an interface for paypal REST APIs https://developer.paypal.com/docs/integration/direct/customer-disputes/
type APICredentials ¶
APICredentials https://developer.paypal.com/docs/nvp-soap-api/apiCredentials/#api-signatures
type AccessTokeResp ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) DoExpressCheckoutPayment ¶
func (c *Client) DoExpressCheckoutPayment(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error)
func (*Client) FiltrateUserRefundDispute ¶
func (c *Client) FiltrateUserRefundDispute(ctx context.Context, disputes []DisputeItem) (userRefundDisputes []DisputeItem)
FiltrateUserRefundDispute filters user refund disputes.
func (*Client) GetAccessToken ¶
GetAccessToken always get a token without expire.
func (*Client) GetExpressCheckoutDetails ¶
func (c *Client) GetExpressCheckoutDetails(ctx context.Context, req GetExpressCheckoutDetailsReq) (GetExpressCheckoutDetailsResp, error)
func (*Client) GetRefundTransaction ¶
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(ctx context.Context, transactionID string, startTime, endTime time.Time) (transaction TransactionInfo, err error)
GetTransaction get first transaction by transactionID time range between startTime and endTime must less than 31 days. https://developer.paypal.com/docs/integration/direct/transaction-search/#list-transactions
curl example
curl -v -X GET https://api-m.sandbox.paypal.com/v1/reporting/transactions?transaction_id=5TY05013RG002845M&fields=all&page_size=100&page=1 \ -H "Content-Type: application/json" \ -H "Authorization: Bearer <Access-Token>"
func (*Client) GetUserRefundDispute ¶
func (c *Client) GetUserRefundDispute(ctx context.Context, disputeID string) (detail ShowDisputeDetailsResp, isUserRefund bool)
GetUserRefundDispute get user refund dispute if this dispute refunded by user.
func (*Client) GetUserRefundDisputedDetails ¶
func (c *Client) GetUserRefundDisputedDetails(ctx context.Context, disputes []DisputeItem) (userRefundDisputeDetailByInvoiceID map[string]ShowDisputeDetailsResp, noInvoiceIDUserRefundDisputeDetails []ShowDisputeDetailsResp)
GetUserRefundDisputedDetails get user refund disputes transaction details. userRefundDisputes is a map where key is invoiceID and value is disputeDetails invoiceID is SDK orderNumber sent to PayPal, details: https://developer.paypal.com/docs/nvp-soap-api/set-express-checkout-nvp
func (*Client) ListDisputes ¶
func (c *Client) ListDisputes(ctx context.Context) (disputeItems []DisputeItem, error error)
ListDisputes list all resolve dispute.
func (*Client) ListOnePageDisputes ¶
func (c *Client) ListOnePageDisputes(ctx context.Context, pagePageToken string) (disputeItems []DisputeItem, nextPageToken string, error error)
ListDisputes list all resolve dispute.
func (*Client) ListOnePageDisputesV2 ¶
func (*Client) SetExpressCheckout ¶
func (c *Client) SetExpressCheckout(ctx context.Context, req SetExpressCheckoutReq) (SetExpressCheckoutResp, error)
func (*Client) ShowDisputeDetails ¶
func (c *Client) ShowDisputeDetails(ctx context.Context, disputeID string) (detail ShowDisputeDetailsResp, error error)
ShowDisputeDetails get dispute detail by disputeID.
type Config ¶
type Config struct { Host string `yaml:"host"` ClientID string `yaml:"client_id"` Secret string `yaml:"secret"` NVPAndSOAPAPICredentials APICredentials `yaml:"api_credentials"` }
type DisputeItem ¶
type DisputeItem struct { DisputeID string `json:"dispute_id"` CreateTime time.Time `json:"create_time"` UpdateTime time.Time `json:"update_time"` Status string `json:"status"` Reason string `json:"reason"` DisputeState string `json:"dispute_state"` DisputeAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"dispute_amount"` Links []HATEOASLink `json:"links"` }
type DisputedTransaction ¶
type DisputedTransaction struct { SellerTransactionID string `json:"seller_transaction_id"` CreateTime time.Time `json:"create_time"` TransactionStatus string `json:"transaction_status"` GrossAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"gross_amount"` Buyer struct { Name string `json:"name"` } `json:"buyer"` Seller struct { Email string `json:"email"` MerchantID string `json:"merchant_id"` Name string `json:"name"` } `json:"seller"` }
type GetExpressCheckoutDetailsReq ¶
type GetExpressCheckoutDetailsReq struct {
Token string `url:"TOKEN"`
}
type HATEOASLink ¶
type ListDisputesReq ¶
type ListDisputesResp ¶
type ListDisputesResp struct { Items []DisputeItem `json:"items"` Links []HATEOASLink `json:"links"` }
type NVPVersion ¶
type NVPVersion string
type SetExpressCheckoutReq ¶
type SetExpressCheckoutReq struct { ReturnURL string `url:"RETURNURL"` Amount string `url:"PAYMENTREQUEST_0_AMT"` NoShipping string `url:"NOSHIPPING"` CurrencyCode string `url:"PAYMENTREQUEST_0_CURRENCYCODE"` Desc string `url:"PAYMENTREQUEST_0_DESC"` Customer string `url:"PAYMENTREQUEST_0_CUSTOM"` Invoice string `url:"PAYMENTREQUEST_0_INVNUM"` CancelURL string `url:"CANCELURL"` }
type SetExpressCheckoutResp ¶
type ShowDisputeDetailsResp ¶
type ShowDisputeDetailsResp struct { DisputeID string `json:"dispute_id"` CreateTime time.Time `json:"create_time"` UpdateTime time.Time `json:"update_time"` DisputedTransactions []DisputedTransaction `json:"disputed_transactions"` Reason string `json:"reason"` Status string `json:"status"` DisputeAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"dispute_amount"` DisputeOutcome struct { OutcomeCode string `json:"outcome_code"` AmountRefunded struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"amount_refunded"` } `json:"dispute_outcome"` }
func (ShowDisputeDetailsResp) GetDisputeIDAndTransactionID ¶
func (s ShowDisputeDetailsResp) GetDisputeIDAndTransactionID() string
type TransactionInfo ¶
type TransactionInfo struct { PaypalAccountId string `json:"paypal_account_id"` TransactionId string `json:"transaction_id"` TransactionEventCode string `json:"transaction_event_code"` TransactionInitiationDate string `json:"transaction_initiation_date"` TransactionUpdatedDate string `json:"transaction_updated_date"` TransactionAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"transaction_amount"` FeeAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"fee_amount"` InsuranceAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"insurance_amount"` ShippingAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"shipping_amount"` ShippingDiscountAmount struct { CurrencyCode string `json:"currency_code"` Value string `json:"value"` } `json:"shipping_discount_amount"` TransactionStatus string `json:"transaction_status"` TransactionSubject string `json:"transaction_subject"` TransactionNote string `json:"transaction_note"` InvoiceId string `json:"invoice_id"` CustomField string `json:"custom_field"` ProtectionEligibility string `json:"protection_eligibility"` }
func (*TransactionInfo) GetInvoiceID ¶
func (t *TransactionInfo) GetInvoiceID() string
GetInvoiceID get invoiceID sent to PapPal by method SetExpressCheckout
type TransactionSearchReq ¶
type TransactionSearchReq struct { TransactionID string `url:"transaction_id,omitempty"` Fields string `url:"fields"` PageSize int `url:"page_size"` Page int `url:"page"` StartDate string `url:"start_date"` EndDate string `url:"end_date"` TransactionStatus TransactionStatus `url:"transaction_status,omitempty"` }
https://developer.paypal.com/docs/integration/direct/transaction-search/#list-transactions
type TransactionSearchResp ¶
type TransactionSearchResp struct { TransactionDetails []struct { TransactionInfo TransactionInfo `json:"transaction_info"` } `json:"transaction_details"` AccountNumber string `json:"account_number"` LastRefreshedDatetime string `json:"last_refreshed_datetime"` Page int `json:"page"` TotalItems int `json:"total_items"` TotalPages int `json:"total_pages"` Links []struct { Href string `json:"href"` Rel string `json:"rel"` Method string `json:"method"` } `json:"links"` }
type TransactionStatus ¶
type TransactionStatus string
const ( // https://developer.paypal.com/docs/api/transaction-search/v1/ TransactionDeny TransactionStatus = "D" TransactionPending TransactionStatus = "P" TransactionSuccess TransactionStatus = "S" TransactionRefund TransactionStatus = "V" )