Help us shape the future of Go! Take the 2026 Go Developer Survey

paymentwall

package module
v0.0.0-...-271b248 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: MIT Imports: 13 Imported by: 0

README

Paymentwall Go Library

Unofficial Paymentwall Go Library

TODO
  • Pingback Processing
    • Digital Goods
    • Virtual Currency
    • Cart
  • Widget Call
  • Coverage test
Reference

Code Samples

Digital Goods API

Pingback Processing
import (
	"fmt"
	
	"github.com/sanae10001/paymentwall-go"
)

pingback := paymentwall.NewPingback(values, ip, paymentwall.API_GOODS, PaymentwallSecretKey)

if pingback.Validate(false) {
	if pingback.IsDeliverable() { 
		// deliver the product
	} else if pingback.IsCancelable() {
		// withdraw the product
	}
} else {
	fmt.Println(pingback.GetError())
}

Documentation

Index

Constants

View Source
const (
	// https://docs.paymentwall.com/reference/signature-calculation
	DefaultSignVersion = "3" // sha256
	SignVersion2       = "2" // md5
	SignVersion3       = "3" // sha256
)
View Source
const (
	// https://docs.paymentwall.com/#chargeback-pingback
	PingbackChargebackReason1  = "1"  // Chargeback
	PingbackChargebackReason2  = "2"  // Credit Card fraud. Recommendation: Ban User
	PingbackChargebackReason3  = "3"  // Other fraud. Recommendation: Ban User
	PingbackChargebackReason4  = "4"  // Bad data entry
	PingbackChargebackReason5  = "5"  // Fake / Proxy user
	PingbackChargebackReason6  = "6"  // Rejected by advertiser
	PingbackChargebackReason7  = "7"  // Duplicate conversions
	PingbackChargebackReason8  = "8"  // Goodwill credit taken back
	PingbackChargebackReason9  = "9"  // Canceled order, e.g. refund
	PingbackChargebackReason10 = "10" // Partially reversed transaction
)
View Source
const (
	VC_CONTROLLER    = "ps"
	GOODS_CONTROLLER = "subscription"
	CART_CONTROLLER  = "cart"
)

Variables

View Source
var (
	ErrorOnlyOneProductAllowed = errors.New("only one product is allowed when ApiType is API_GOODS")
)

Functions

This section is empty.

Types

type ApiType

type ApiType uint
const (
	API_VC    ApiType = 1 // Virtual Currency API
	API_GOODS ApiType = 2 // Digital Goods API
	API_CART  ApiType = 3 // Cart API
)

type PeriodType

type PeriodType string
const (
	PeriodTypeDay   PeriodType = "day"
	PeriodTypeWeek  PeriodType = "week"
	PeriodTypeMonth PeriodType = "month"
	PeriodTypeYear  PeriodType = "year"
)

type Pingback

type Pingback struct {
	IsTest bool
	// contains filtered or unexported fields
}

func (*Pingback) Get

func (p *Pingback) Get(key string) string

func (*Pingback) GetError

func (p *Pingback) GetError() error

func (*Pingback) GetErrors

func (p *Pingback) GetErrors() []error

func (*Pingback) GetProductID

func (p *Pingback) GetProductID() string

func (*Pingback) GetProductPeriod

func (p *Pingback) GetProductPeriod() (length string, period string)

func (*Pingback) GetReferenceID

func (p *Pingback) GetReferenceID() string

func (*Pingback) GetType

func (p *Pingback) GetType() PingbackType

func (*Pingback) GetUID

func (p *Pingback) GetUID() string

Unique identifier of the user. The value of parameter “uid” from Widget call.

func (*Pingback) GetVCAmount

func (p *Pingback) GetVCAmount() string

func (*Pingback) IsCancelable

func (p *Pingback) IsCancelable() bool

func (*Pingback) IsDeliverable

func (p *Pingback) IsDeliverable() bool

func (*Pingback) IsIPValid

func (p *Pingback) IsIPValid() bool

IsIPValid checks to ensure the IP from which the pingback was received is within the allowed range of whitelisted IPs provided by Paymentwall. @see: https://docs.paymentwall.com/reference/pingback-new-ip-subnet

func (*Pingback) IsParametersValid

func (p *Pingback) IsParametersValid() bool

func (*Pingback) IsSignatureValid

func (p *Pingback) IsSignatureValid() bool

func (*Pingback) IsUnderReview

func (p *Pingback) IsUnderReview() bool

func (*Pingback) Validate

func (p *Pingback) Validate(skipIPCheck bool) bool

type PingbackType

type PingbackType string
const (
	PingbackTypeRegular  PingbackType = "0" // When product is purchased. Please check whether the reference ID is unique and deliver the goods.
	PingbackTypeGoodwill PingbackType = "1"
	PingbackTypeNegative PingbackType = "2" // When user issued chargeback or refund. Please take the delivered goods out from user’s account.

	PingbackTypeRiskUnderReview      PingbackType = "200" // Pending status. In case a payment is currently under risk review by Paymentwall. Please do not deliver the goods yet.
	PingbackTypeRiskReviewedAccepted PingbackType = "201" // Review is done and payment is accepted. Please check whether the reference ID is unique and deliver the goods.
	PingbackTypeRiskReviewedDeclined PingbackType = "202" // Review is done and payment is declined. Please do not deliver the goods since the user will get his money back.

	PingbackTypeRiskAuthorizationVoided PingbackType = "203" // Authorization has been voided due to no capture request received on time.

	PingbackTypeSubscriptionCancelled     PingbackType = "12" // When user cancels subscription plan. Sent immediately upon cancellation, e.g. in the middle of current premium month.
	PingbackTypeSubscriptionExpired       PingbackType = "13" // When subscription expired.
	PingbackTypeSubscriptionPaymentFailed PingbackType = "14" // When renewal subscription payment failed. Subscription stopped due to failing payments e.g. due to insufficient funds.
)

type Product

type Product struct {
	Name     string
	Identity string

	Amount   float64
	Currency string

	Type ProductType

	Recurring    bool
	PeriodLength uint
	PeriodType   PeriodType
}

func NewProduct

func NewProduct(
	name, id string,
	amount float64, currency string,
	pType ProductType) *Product

func (*Product) DisplayAmount

func (p *Product) DisplayAmount() string

func (*Product) DisplayPeriodLength

func (p *Product) DisplayPeriodLength() string

func (*Product) SetSubscription

func (p *Product) SetSubscription(
	periodLength uint,
	periodType PeriodType,
	isRecurring bool)

type ProductType

type ProductType string
const (
	ProductTypeSubscription ProductType = "subscription"
	ProductTypeFixed        ProductType = "fixed"
)

type Widget

type Widget struct {
	// contains filtered or unexported fields
}

func NewWidget

func NewWidget(
	appKey, secretKey string,
	apiType ApiType,
	uid, widgetCode, email string,
	skipSignature bool) *Widget

func (*Widget) AppendProduct

func (w *Widget) AppendProduct(products ...Product) error

func (*Widget) GetHtmlCode

func (w *Widget) GetHtmlCode(attributes map[string]string) string

func (*Widget) GetUrl

func (w *Widget) GetUrl() string

func (*Widget) SetCallbackUrl

func (w *Widget) SetCallbackUrl(successUrl, failureUrl string)

func (*Widget) SetExtraParam

func (w *Widget) SetExtraParam(k, v string)

func (*Widget) SetExtraParams

func (w *Widget) SetExtraParams(m map[string]string)

func (*Widget) SetPS

func (w *Widget) SetPS(ps string)

Jump to

Keyboard shortcuts

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