Documentation
¶
Index ¶
- type Handler
- func (hdlr *Handler) AssociateMembershipFeeForDisplay() string
- func (hdlr *Handler) Cancel(w http.ResponseWriter, r *http.Request)
- func (hdlr *Handler) Checkout(w http.ResponseWriter, r *http.Request)
- func (h *Handler) CreateCheckoutSession(w http.ResponseWriter, r *http.Request)
- func (hdlr *Handler) FriendFeeForDisplay() string
- func (hdlr *Handler) GetPaymentData(w http.ResponseWriter, r *http.Request)
- func (hdlr *Handler) OrdinaryMembershipFeeForDisplay() string
- func (hdlr *Handler) Success(w http.ResponseWriter, r *http.Request)
- type PaymentFormData
- func (form *PaymentFormData) AssociateMembershipFeeForDisplay() string
- func (form *PaymentFormData) DonationToMuseumForDisplay() string
- func (form *PaymentFormData) DonationToSocietyForDisplay() string
- func (form *PaymentFormData) FriendMembershipFeeForDisplay() string
- func (f *PaymentFormData) MarkMandatoryFields()
- func (form *PaymentFormData) OrdinaryMembershipFeeForDisplay() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { Conf *config.Config // The config. PaymentYear int // The membership year we are currently selling. OrdinaryMembershipFee float64 AssociateMembershipFee float64 FriendMembershipFee float64 Protocol string // "http" or "https" }
func (*Handler) AssociateMembershipFeeForDisplay ¶
AssociateMembershipFeeForDisplay gets the associate membership fee for display - a number to two decimal places. If there is no associate, it returns "0.0".
func (*Handler) Cancel ¶
func (hdlr *Handler) Cancel(w http.ResponseWriter, r *http.Request)
Cancel is the handler for the /cancel request. Stripe makes that request when the payment is cancelled.
func (*Handler) CreateCheckoutSession ¶
func (h *Handler) CreateCheckoutSession(w http.ResponseWriter, r *http.Request)
CreateCheckoutSession is the handler for the /create-checkout-session request. It prepares the Stripe session and invokes
func (*Handler) FriendFeeForDisplay ¶
OrdinaryMemberFriendFeeForDisplay gets the ordinary member's museum friend fee for display - a number to two decimal places. If the member is not a friend, it returns "0.0".
func (*Handler) GetPaymentData ¶
func (hdlr *Handler) GetPaymentData(w http.ResponseWriter, r *http.Request)
GetPaymentData handles the /displayPaymentForm request. It validates the incoming payment data form. If the data is valid it displays the cost breakdown, otherwise it displays the payment data form again with error messages.
func (*Handler) OrdinaryMembershipFeeForDisplay ¶
OrdinaryMembershipFeeForDisplay gets the ordinary membership fee for a display - a number to two decimal places.
func (*Handler) Success ¶
func (hdlr *Handler) Success(w http.ResponseWriter, r *http.Request)
Success is the handler for the /success request. On a successful payment, the Stripe system issues that request, filling in the {CHECKOUT_SESSION_ID} placeholder with the session ID. The handler uses that to retrieve the checkout session, extract the client reference and complete the sale.
type PaymentFormData ¶
type PaymentFormData struct { // Valid is set false during validation if the form data is invalid. Valid bool // Reference Data. PaymentYear int // The payment year displayed in the title. OrdinaryMembershipFee float64 // The ordinary member fee AssociateMembershipFee float64 // The associate member fee. (0 if no associate.) FriendMembershipFee float64 // The friend fee. (0 if no associate or not friend). // Data for validation. FirstName string LastName string Email string FriendInput string // tickbox - "on", "off", "checked" or "unchecked" DonationToSocietyInput string // number DonationToMuseumInput string // number GiftaidInput string // tickbox - "on", "off", "checked" or "unchecked" AssocFirstName string AssocLastName string AssocEmail string AssociateIsFriendInput string // tickbox - "on", "off", "checked" or "unchecked" Friend bool // True if the ordinary member's Friend tickbox is valid and true. FriendOutput string // Checkbox setting - "checked" or "unchecked" DonationToSociety float64 // Donation to the society. DonationToMuseum float64 // Donation to the museum. Giftaid bool // True if the giftaid tickbox is valid and true. GiftaidOutput string // Checkbox setting - "checked" or "unchecked" AssociateIsFriend bool // True if the associate member's friend tickbox is valid and true. AssociateIsFriendOutput string // Checkbox setting - "checked" or "unchecked" UserID int // The ID of the ordinary member in the database (> zero). AssocUserID int // The ID of the associate member in the database (zero if no associate). // Error messages set if the form data is invalid. GeneralErrorMessage string // Set on a fatal error, eg database connection failure. FirstNameErrorMessage string LastNameErrorMessage string EmailErrorMessage string DonationToSocietyErrorMessage string DonationToMuseumErrorMessage string AssocFirstNameErrorMessage string AssocLastNameErrorMessage string }
PaymentFormData holds the submitted form data for validation and display.
func NewPaymentForm ¶
func NewPaymentForm() *PaymentFormData
NewPaymentForm finds the membership year we are currently selling and creates a payment form.
func (*PaymentFormData) AssociateMembershipFeeForDisplay ¶
func (form *PaymentFormData) AssociateMembershipFeeForDisplay() string
AssociateMembershipFeeForDisplay gets the associate membership fee for a display - a number to two decimal places.
func (*PaymentFormData) DonationToMuseumForDisplay ¶
func (form *PaymentFormData) DonationToMuseumForDisplay() string
DonationToMuseumForDisplay gets the donation to museum for a display - a number to two decimal places.
func (*PaymentFormData) DonationToSocietyForDisplay ¶
func (form *PaymentFormData) DonationToSocietyForDisplay() string
DonationToSocietyForDisplay gets the donation to the society for a display - a number to two decimal places.
func (*PaymentFormData) FriendMembershipFeeForDisplay ¶
func (form *PaymentFormData) FriendMembershipFeeForDisplay() string
FriendMembershipFeeForDisplay gets the friend membership fee for display - a number to two decimal places.
func (*PaymentFormData) MarkMandatoryFields ¶
func (f *PaymentFormData) MarkMandatoryFields()
MarkMandatoryFields marks the mandatory parameters in a payment form by setting error messages containing asterisks. This drives the first view of the payment page.
func (*PaymentFormData) OrdinaryMembershipFeeForDisplay ¶
func (form *PaymentFormData) OrdinaryMembershipFeeForDisplay() string
OrdinaryMembershipFeeForDisplay gets the ordinary membership fee for a display - a number to two decimal places.