Documentation
¶
Index ¶
- Constants
- Variables
- type Alert
- type Client
- func (c *Client) Audience(ctx context.Context, email string, marketingConsent bool) (userID int, err error)
- func (c *Client) GeneratePayLink(ctx context.Context, request GeneratePayLinkRequest) (url string, err error)
- func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}, ...) (*http.Request, error)
- type ErrorCode
- type GeneratePayLinkRequest
- type InvoiceOverdue
- type InvoicePaid
- type InvoiceSent
- type PausedReason
- type PaymentMethod
- type PaymentSucceeded
- type RefundType
- type Settings
- type Status
- type SubscriptionCancelled
- type SubscriptionCreated
- type SubscriptionPaymentFailed
- type SubscriptionPaymentRefunded
- type SubscriptionPaymentSucceeded
- type SubscriptionUpdated
- type TransferCreated
- type TransferPaid
- type WebhookClient
- func (c *WebhookClient) ParseInvoiceOverdueWebhook(form url.Values) (InvoiceOverdue, error)
- func (c *WebhookClient) ParseInvoicePaidWebhook(form url.Values) (InvoicePaid, error)
- func (c *WebhookClient) ParseInvoiceSentWebhook(form url.Values) (InvoiceSent, error)
- func (c *WebhookClient) ParsePaymentSucceededWebhook(form url.Values) (PaymentSucceeded, error)
- func (c *WebhookClient) ParseSubscriptionCancelledWebhook(form url.Values) (SubscriptionCancelled, error)
- func (c *WebhookClient) ParseSubscriptionCreatedWebhook(form url.Values) (SubscriptionCreated, error)
- func (c *WebhookClient) ParseSubscriptionPaymentFailedWebhook(form url.Values) (SubscriptionPaymentFailed, error)
- func (c *WebhookClient) ParseSubscriptionPaymentRefundedWebhook(form url.Values) (SubscriptionPaymentRefunded, error)
- func (c *WebhookClient) ParseSubscriptionPaymentSucceededWebhook(form url.Values) (SubscriptionPaymentSucceeded, error)
- func (c *WebhookClient) ParseSubscriptionUpdatedWebhook(form url.Values) (SubscriptionUpdated, error)
- func (c *WebhookClient) ParseTransferCreatedWebhook(form url.Values) (TransferCreated, error)
- func (c *WebhookClient) ParseTransferPaidWebhook(form url.Values) (TransferPaid, error)
- func (c *WebhookClient) SetVerification(b bool)
Examples ¶
Constants ¶
View Source
const ( DefaultBaseURL = "https://vendors.paddle.com/api/" DefaultCheckoutBaseURL = "https://checkout.paddle.com/api/" SandboxBaseURL = "https://sandbox-vendors.paddle.com/api/" SandboxCheckoutBaseURL = "https://sandbox-checkout.paddle.com/api/" )
Variables ¶
View Source
var (
ErrInvalidSignature = errors.New("paddle: invalid signature")
)
Functions ¶
This section is empty.
Types ¶
type Alert ¶
type Alert string
const ( AlertSubscriptionCreated Alert = "subscription_created" AlertSubscriptionUpdated Alert = "subscription_updated" AlertSubscriptionCancelled Alert = "subscription_cancelled" AlertSubscriptionPaymentSucceeded Alert = "subscription_payment_succeeded" AlertSubscriptionPaymentFailed Alert = "subscription_payment_failed" AlertSubscriptionPaymentRefunded Alert = "subscription_payment_refunded" AlertPaymentSucceeded Alert = "payment_succeeded" AlertPaymentRefunded Alert = "payment_refunded" AlertLockerProcessed Alert = "locker_processed" AlertPaymentDisputeCreated Alert = "payment_dispute_created" AlertPaymentDisputeClosed Alert = "payment_dispute_closed" AlertHighRiskTransactionCreated Alert = "high_risk_transaction_created" AlertHighRiskTransactionUpdated Alert = "high_risk_transaction_updated" AlertTransferCreated Alert = "transfer_created" AlertTransferPaid Alert = "transfer_paid" AlertNewAudienceMember Alert = "new_audience_member" AlertUpdateAudienceMember Alert = "update_audience_member" AlertInvoicePaid Alert = "invoice_paid" AlertInvoiceSent Alert = "invoice_sent" AlertInvoiceOverdue Alert = "invoice_overdue" )
type Client ¶
type Client struct { BaseURL *url.URL CheckoutBaseURL *url.URL UserAgent string // contains filtered or unexported fields }
func NewClient ¶
Example ¶
client, err := NewClient(Settings{ VendorID: "123", VendorAuthCode: "123ab", }) if err != nil { panic(err) } url, err := client.GeneratePayLink(context.Background(), GeneratePayLinkRequest{ ProductID: 25, Prices: map[string]string{ "USD": "25.45", "EUR": "21.39", "RUB": "999", }, Affiliates: map[string]string{ "1234": "0.50", "1235": "0.25", }, CustomerEmail: "user@example.com", MarketingConsent: true, }) if err != nil { panic(err) } fmt.Println(url)
Output:
func (*Client) GeneratePayLink ¶
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, urlStr string, body interface{}, checkoutURL, authenticate bool) (*http.Request, error)
NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the BaseURL of the Client. Relative URLs should always be specified without a preceding slash. If specified, the value pointed to by body is JSON encoded and included as the request body.
type ErrorCode ¶
type ErrorCode int
const ( ErrorCodeLicenseNotFound ErrorCode = 100 ErrorCodeBadMethodCall ErrorCode = 101 ErrorCodeBadAPIKey ErrorCode = 102 ErrorCodeTimestampInvalid ErrorCode = 103 ErrorCodeLicenseAlreadyUtilized ErrorCode = 104 ErrorCodeLicenseIsNotActive ErrorCode = 105 ErrorCodeActivationNotFound ErrorCode = 106 ErrorCodePermissionError ErrorCode = 107 ErrorCodeProductNotFound ErrorCode = 108 ErrorCodeCurrencyInvalid ErrorCode = 109 ErrorCodePurchaseNotFound ErrorCode = 110 ErrorCodeAuthenticationTokenInvalid ErrorCode = 111 ErrorCodeVerificationTokenInvalid ErrorCode = 112 ErrorCodePaddingInvalid ErrorCode = 113 ErrorCodeAffiliateInvalid ErrorCode = 114 ErrorCodeAffiliateCommissionInvalid ErrorCode = 115 ErrorCodeArgumentsMissing ErrorCode = 116 ErrorCodeExpirationTimeInvalid ErrorCode = 117 ErrorCodePriceIsTooLow ErrorCode = 118 ErrorCodeSubscriptionNotFound ErrorCode = 119 ErrorCodeInternalError ErrorCode = 120 ErrorCodePaymentNotFound ErrorCode = 121 ErrorCodeDateInvalid ErrorCode = 122 ErrorCodeModifierNotFound ErrorCode = 123 ErrorCodeModifierAlreadyPaid ErrorCode = 124 ErrorCodeNoMainCurrencyPrice ErrorCode = 125 ErrorCodeEmailInvalid ErrorCode = 126 ErrorCodeCouponTypeInvalid ErrorCode = 127 ErrorCodePercentageInvalid ErrorCode = 128 ErrorCodeAmountInvalid ErrorCode = 129 )
type GeneratePayLinkRequest ¶
type GeneratePayLinkRequest struct { // ProductID is The Paddle Product ID/Plan ID that you want to base this custom checkout on. // Required if not using custom products. // If no ProductID is set, custom non-subscription product checkouts can be generated instead by specifying the required fields: Title, WebhookURL and prices. // Note that CouponCode cannot be used with custom products. ProductID int // Title is the name of the product/title of the checkout. Required if ProductID is not set. Title string // WebhookURL is an endpoint that we will call with transaction information upon successful checkout, to allow you to fulfill the purchase. // Only valid (and required) if ProductID is not set. Not valid for subscription plans. // Note: testing on localhost is not supported. Please use an internet-accessible URL. WebhookURL string // Prices is price (s) of the checkout for a one-time purchase or the initial payment of a subscription. // If ProductID is set, you must also provide the price for the product’s default currency.If a given currency is enabled in the dashboard, it will default to a conversion of the product’s default currency price set in this field unless specified here as well. // If the currency specified is not enabled in the dashboard and the ProductID is a subscription, the currency’s RecurringPrices must be set as well. Prices map[string]string // RecurringPrices is recurring price(s) of the checkout (excluding the initial payment) only if the ProductID specified is a subscription. // To override the initial payment and all recurring payment amounts, both Prices and RecurringPrices must be set. // You must also provide the price for the subscription’s default currency. // If a given currency is enabled in the dashboard, it will default to a conversion of the subscription’s default currency price set in this field unless specified here as well. // If the currency specified is not enabled in the dashboard, the currency’s prices must be set as well. RecurringPrices map[string]string // TrialDays is for subscription plans only. // The number of days for the initial billing cycle. // If you leave this field empty, the default trial days of the plan will be used. // Note: The prices might additionally need to be set in order to achieve the desired behaviour (free trial/paid trial), // depending on whether the plan had a trial period set originally. TrialDays int // CustomMessage is a short message displayed below the product name on the checkout. CustomMessage string // CouponCode is a coupon to be applied to the checkout. // Note that this cannot be used with custom products, and is only valid if a ProductID is set. CouponCode string // Discountable specifies if a coupon can be applied to the checkout. // “Add Coupon” button on the checkout will be hidden as well if set to false. Discountable *bool // ImageURL is a URL for the product image/icon displayed on the checkout. ImageURL string // ReturnURL is a URL to redirect to once the checkout is completed. // If the variable {checkout_hash} is included within the URL // (e.g.https://example.com/thanks?checkout={checkout_hash}), the API will automatically populate the Paddle checkout ID in the redirected URL. ReturnURL string // QuantityVariable specifies if the user is allowed to alter the quantity of the checkout. QuantityVariable *bool // Quantity pre-fills the quantity selector on the checkout.Please note that free products/subscription plans are fixed to a quantity of 1. // Any quantity over the maximum value will default to a quantity of 1. Quantity int // Expires specifies if the checkout link should expire. // The generated checkout URL will be accessible until 23:59:59 (UTC) on the date specified. // If this is not specified, the checkout link will automatically expire 60 days after it has been first opened. Expires time.Time // Affiliates contains other Paddle vendor IDs whom you would like to split the funds from this checkout with. Affiliates map[string]string // RecurringAffiliateLimit limits the number of times other Paddle vendors will receive funds from the recurring payments (for subscription products). // The initial checkout payment is included in the limit. // If you leave this field empty, the limit will not be applied. // Note: if your plan has a trial period, set this to 2 or greater in order for your affiliates to correctly receive their commission on paid payments after the trial. RecurringAffiliateLimit int // MarketingConsent specifies whether you have gathered consent to market to the customer. // CustomerEmail is required if this property is set, and you want to opt the customer into marketing. MarketingConsent bool // CustomerEmail pre-fills the customer email field on the checkout. CustomerEmail string // CustomerCountry pre-fills the customer country field on the checkout. // List of supported ISO country codes - https://developer.paddle.com/reference/platform-parameters/supported-countries // Only pre-filled if CustomerEmail is set. CustomerCountry string // CustomerPostcode pre-fills the customer postcode field on the checkout. // This field is required if the CustomerCountry requires postcode. // List of the countries requiring this field - https://developer.paddle.com/reference/platform-parameters/supported-countries#countries-requiring-postcode CustomerPostcode string // IsRecoverable Specifies if checkout recovery emails can be sent to users who abandon the checkout process after entering their email address. // An additional 10% transaction fee applies to checkouts we recover. // This will override the checkout recovery setting specified in your page. IsRecoverable *bool // Passthrough is a string of metadata you wish to store with the checkout. // Will be sent alongside all webhooks associated with the order. // See the documentation for more information. Passthrough string // VatNumber pre-fills the sales tax identifier (VAT number) field on the checkout. VatNumber string // VatCompanyName pre-fills the Company Name field on the checkout. // Required if VatNumber is set. VatCompanyName string // VatStreet pre-fills the Street field on the checkout. // Required if VatNumber is set. VatStreet string // VatCity pre-fills the Town/City field on the checkout. // Required if VatNumber is set. VatCity string // VatState pre-fills the State field on the checkout. VatState string // VatCountry pre-fills the Country field on the checkout. // Required if VatNumber is set. // List of the list of supported ISO country codes - https://developer.paddle.com/reference/platform-parameters/supported-countries VatCountry string // VatPostcode pre-fills the Postcode field on the checkout. VatPostcode string }
type InvoiceOverdue ¶
type InvoiceOverdue struct { AlertName Alert AlertID string PaymentID string Amount string SaleGross string TermDays string Status Status PurchaseOrderNumber string InvoicedAt time.Time Currency string ProductID string ProductName string ProductAdditionalInformation string CustomerID string CustomerName string Email string CustomerVatNumber string CustomerCompanyNumber string CustomerAddress string CustomerCity string CustomerState string CustomerZipcode string Country string ContractID string ContractStartDate time.Time ContractEndDate time.Time Passthrough string DateCreated time.Time BalanceCurrency string PaymentTax string PaymentMethod PaymentMethod Fee string Earnings string EventTime time.Time }
type InvoicePaid ¶
type InvoicePaid struct { AlertName Alert AlertID string PaymentID string Amount string SaleGross string TermDays string Status Status PurchaseOrderNumber string InvoicedAt time.Time Currency string ProductID string ProductName string ProductAdditionalInformation string CustomerID string CustomerName string Email string CustomerVatNumber string CustomerCompanyNumber string CustomerAddress string CustomerCity string CustomerState string CustomerZipcode string Country string ContractID string ContractStartDate time.Time ContractEndDate time.Time Passthrough string DateCreated time.Time BalanceCurrency string PaymentTax string PaymentMethod PaymentMethod Fee string Earnings string BalanceEarnings string BalanceFee string BalanceTax string BalanceGross string DateReconciled time.Time EventTime time.Time }
type InvoiceSent ¶
type InvoiceSent struct { AlertName Alert AlertID string PaymentID string Amount string SaleGross string TermDays string Status Status PurchaseOrderNumber string InvoicedAt time.Time Currency string ProductID string ProductName string ProductAdditionalInformation string CustomerID string CustomerName string Email string CustomerVatNumber string CustomerCompanyNumber string CustomerAddress string CustomerCity string CustomerState string CustomerZipcode string Country string ContractID string ContractStartDate time.Time ContractEndDate time.Time Passthrough string DateCreated time.Time BalanceCurrency string PaymentTax string PaymentMethod PaymentMethod Fee string Earnings string EventTime time.Time }
type PausedReason ¶
type PausedReason string
const ( PausedReasonDelinquent PausedReason = "delinquent" PausedReasonVoluntary PausedReason = "voluntary" )
type PaymentMethod ¶
type PaymentMethod string
PaymentMethod defines possible payment method type.
const ( PaymentMethodCard PaymentMethod = "card" PaymentMethodPayPal PaymentMethod = "paypal" PaymentMethodFree PaymentMethod = "free" PaymentMethodApplePay PaymentMethod = "apple-pay" PaymentMethodWireTransfer PaymentMethod = "wire-transfer" )
type PaymentSucceeded ¶
type PaymentSucceeded struct { AlertName Alert AlertID string BalanceCurrency string BalanceEarnings string BalanceFee string BalanceGross string BalanceTax string CheckoutID string Country string Coupon string Currency string CustomerName string Earnings string Email string EventTime time.Time Fee string MarketingConsent bool OrderID string // IP defines user IP. // Deprecated, see https://developer.paddle.com/webhook-reference/one-off-purchase-alerts/payment-succeeded IP string Passthrough string PaymentMethod PaymentMethod PaymentTax string ProductID string ProductName string Quantity int ReceiptURL string SaleGross string UsedPriceOverride bool }
type RefundType ¶
type RefundType string
RefundType defines possible reason for refund.
const ( RefundTypeFull RefundType = "full" RefundTypeVat RefundType = "vat" RefundTypePartial RefundType = "partial" )
type SubscriptionCancelled ¶
type SubscriptionCancelled struct { AlertName Alert AlertID string CancellationEffectiveDate time.Time CheckoutID string Currency string Email string EventTime time.Time MarketingConsent bool Passthrough string Quantity int Status Status SubscriptionID string SubscriptionPlanID string UnitPrice string UserID string }
type SubscriptionCreated ¶
type SubscriptionCreated struct { AlertName Alert AlertID string CancelURL string CheckoutID string Currency string Email string EventTime time.Time MarketingConsent bool NextBillDate time.Time Passthrough string Quantity int Source string Status Status SubscriptionID string SubscriptionPlanID string UnitPrice string UserID string UpdateURL string }
type SubscriptionPaymentFailed ¶
type SubscriptionPaymentFailed struct { AlertName Alert AlertID string Amount string CancelURL string CheckoutID string Currency string Email string EventTime time.Time MarketingConsent bool NextRetryDate time.Time Passthrough string Quantity int Status Status SubscriptionID string SubscriptionPlanID string UnitPrice string UpdateURL string SubscriptionPaymentID string Installments int OrderID string UserID string AttemptNumber int }
type SubscriptionPaymentRefunded ¶
type SubscriptionPaymentRefunded struct { AlertName Alert AlertID string Amount string BalanceCurrency string BalanceEarningsDecrease string BalanceFeeRefund string BalanceGrossRefund string BalanceTaxRefund string CheckoutID string Currency string EarningsDecrease string Email string EventTime time.Time FeeRefund string GrossRefund string InitialPayment bool Instalments string MarketingConsent bool OrderID string Passthrough string Quantity int RefundReason string RefundType RefundType Status Status SubscriptionID string SubscriptionPaymentID string SubscriptionPlanID string TaxRefund string UnitPrice string UserID string }
type SubscriptionPaymentSucceeded ¶
type SubscriptionPaymentSucceeded struct { AlertName Alert AlertID string BalanceCurrency string BalanceEarnings string BalanceFee string BalanceGross string BalanceTax string CheckoutID string Country string Coupon string Currency string CustomerName string Earnings string Email string EventTime time.Time Fee string InitialPayment bool Instalments string MarketingConsent bool NextBillDate time.Time NextPaymentAmount string OrderID string Passthrough string PaymentMethod PaymentMethod PaymentTax string PlanName string Quantity int ReceiptURL string SaleGross string Status Status SubscriptionID string SubscriptionPaymentID string SubscriptionPlanID string UnitPrice string UserID string }
type SubscriptionUpdated ¶
type SubscriptionUpdated struct { AlertName Alert AlertID string UpdateURL string CancelURL string CheckoutID string Currency string Email string EventTime time.Time MarketingConsent bool NewPrice string NewQuantity int NewUnitPrice string NextBillDate time.Time Passthrough string Status Status SubscriptionID string SubscriptionPlanID string UserID string OldNextBillDate time.Time OldPrice string OldQuantity int OldStatus Status OldSubscriptionPlanID string OldUnitPrice string PausedAt time.Time PausedFrom time.Time PausedReason PausedReason }
type TransferCreated ¶
type TransferPaid ¶
type WebhookClient ¶
type WebhookClient struct {
// contains filtered or unexported fields
}
func NewWebhookClient ¶
func NewWebhookClient(publicKey string) (*WebhookClient, error)
func (*WebhookClient) ParseInvoiceOverdueWebhook ¶
func (c *WebhookClient) ParseInvoiceOverdueWebhook(form url.Values) (InvoiceOverdue, error)
func (*WebhookClient) ParseInvoicePaidWebhook ¶
func (c *WebhookClient) ParseInvoicePaidWebhook(form url.Values) (InvoicePaid, error)
func (*WebhookClient) ParseInvoiceSentWebhook ¶
func (c *WebhookClient) ParseInvoiceSentWebhook(form url.Values) (InvoiceSent, error)
func (*WebhookClient) ParsePaymentSucceededWebhook ¶
func (c *WebhookClient) ParsePaymentSucceededWebhook(form url.Values) (PaymentSucceeded, error)
func (*WebhookClient) ParseSubscriptionCancelledWebhook ¶
func (c *WebhookClient) ParseSubscriptionCancelledWebhook(form url.Values) (SubscriptionCancelled, error)
func (*WebhookClient) ParseSubscriptionCreatedWebhook ¶
func (c *WebhookClient) ParseSubscriptionCreatedWebhook(form url.Values) (SubscriptionCreated, error)
func (*WebhookClient) ParseSubscriptionPaymentFailedWebhook ¶
func (c *WebhookClient) ParseSubscriptionPaymentFailedWebhook(form url.Values) (SubscriptionPaymentFailed, error)
func (*WebhookClient) ParseSubscriptionPaymentRefundedWebhook ¶
func (c *WebhookClient) ParseSubscriptionPaymentRefundedWebhook(form url.Values) (SubscriptionPaymentRefunded, error)
func (*WebhookClient) ParseSubscriptionPaymentSucceededWebhook ¶
func (c *WebhookClient) ParseSubscriptionPaymentSucceededWebhook(form url.Values) (SubscriptionPaymentSucceeded, error)
func (*WebhookClient) ParseSubscriptionUpdatedWebhook ¶
func (c *WebhookClient) ParseSubscriptionUpdatedWebhook(form url.Values) (SubscriptionUpdated, error)
func (*WebhookClient) ParseTransferCreatedWebhook ¶
func (c *WebhookClient) ParseTransferCreatedWebhook(form url.Values) (TransferCreated, error)
func (*WebhookClient) ParseTransferPaidWebhook ¶
func (c *WebhookClient) ParseTransferPaidWebhook(form url.Values) (TransferPaid, error)
func (*WebhookClient) SetVerification ¶
func (c *WebhookClient) SetVerification(b bool)
Source Files
¶
- audience.go
- client.go
- codes.go
- custom_bool.go
- custom_date.go
- custom_time.go
- encoder.go
- generate_pay_link.go
- signature.go
- structs.go
- webhook_invoice_overdue.go
- webhook_invoice_paid.go
- webhook_invoice_sent.go
- webhook_payment_succeeded.go
- webhook_subscription_cancelled.go
- webhook_subscription_created.go
- webhook_subscription_payment_failed.go
- webhook_subscription_payment_refunded.go
- webhook_subscription_payment_succeeded.go
- webhook_subscription_updated.go
- webhook_transfer_created.go
- webhook_transfer_paid.go
- webhooks.go
Click to show internal directories.
Click to hide internal directories.