pymtproto

package
v0.0.0-...-0e95005 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: ISC Imports: 16 Imported by: 0

README

pymtproto

[Build Status] (https://travis-ci.org/gcash/bchwallet)

Package pymtproto provides functions for downloading Bip0070 payment requests and POSTing payments back to the merchant server.

Example Usage:

client := NewPaymentProtocolClient(&chaincfg.MainnetParams, nil)
paymentRequest, err := client.DownloadBip0070PaymentRequest("bitcoincash:?r=https://test.bitpay.com/i/KqSWvRBKC58CgdpfsttzBC")

Package pymtproto is licensed under the copyfree ISC License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Output

type Output struct {
	Address bchutil.Address
	Amount  bchutil.Amount
}

Output represents an address and amount to be paid.

type Payment

type Payment struct {
	PaymentURL   string
	MerchantData []byte
	Transactions []*wire.MsgTx
	RefundOutput Output
	Memo         string
}

Payment is an object that holds all information needed to POST a payment back to the merchant server. All fields except memo are required.

type PaymentProtocolClient

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

PaymentProtocolClient is used to download payment requests and make payments. We use an object for this to make testing a little easier.

func NewPaymentProtocolClient

func NewPaymentProtocolClient(params *chaincfg.Params, proxyDialer proxy.Dialer) *PaymentProtocolClient

NewPaymentProtocolClient returns a PaymentRequestDownloader that can be used to get the payment request.

func (*PaymentProtocolClient) DownloadBip0070PaymentRequest

func (c *PaymentProtocolClient) DownloadBip0070PaymentRequest(uri string) (*PaymentRequest, error)

DownloadBip0070PaymentRequest will download a Bip70 (protobuf) payment request from the provided bitcoincash URI. Upon download it will validate the request is formatted correctly and signed with a valid X509 certificate. The cert will be checked against the OS's certificate store. A PaymentRequest object with the relevant data extracted is returned.

func (*PaymentProtocolClient) PostPayment

func (c *PaymentProtocolClient) PostPayment(payment *Payment) (memo string, err error)

PostPayment sends a payment response back to the merchant's server. Any errors that are encountered in the process are returned along with an optional "memo" that the merchant can include in the ACK.

type PaymentRequest

type PaymentRequest struct {
	PayToName    string
	Outputs      []Output
	Expires      time.Time
	Memo         string
	PaymentURL   string
	MerchantData []byte
}

PaymentRequest is returned by the DownloadBip0070PaymentRequest method. It contains all the relevant information from the downloaded payment request.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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