payment

package
v3.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2019 License: OSL-3.0 Imports: 2 Imported by: 1

README

Payment Package

Uff Payment is a taff topic and this package offers a generic concept to implement payment processing.

Before we start we should clearify some namings:

  • PaymentGateway: Is a digital tool that allows for online (credit card) payment request processing. It accepts PaymentRequest
  • PaymentMethod: Represents the used Payment -Typical payment methods include cash, checks, credit or debit cards, money orders, bank transfers and online payment services such as PayPal.

The main thing this package offers is a WebCartPaymentGateway interface.

WebCartPaymentGateway

This is an interface that supports the processing of cart payments in any possible flow.

The checkout will use this to start a payment of a cart. Since a payment may involve redirects to one or more external hosted payment pages - or the requirement to show some iframes this interface uses a very genric abstraction.

Basically the checkout will at some point call

 result, err := theSelectedWebCartPaymentGateway.StartFlow(ctx, cart, selectedMethod, sessionid, returnUrl) 
 if err != nil {
   return result
 }

This basically forwards the control of what should happen in the browser of the user 100% to the Payment Flow. The only thing it need to make sure is, that at the end the user should be returned to the given "returnUrl". Which will be normally the placeOrder Action of the checkout.

There the checkout will ask the Gateway implementation again to get the result (or an error if payment failed):

 cartPayment, err := theSelectedWebCartPaymentGateway.GetFlowResult(ctx, cart, sessionid)
 ..

Offline Payment

This module also offers a simple implementation of an OfflineWebCartPaymentGateway - that can be used to process cart payments that are not done online but offline. This implementation can be activate with this setting in config.yml:

commerce.payment.enableOfflinePaymentGateway: true

Registering own Payment Providers

You need to implement the secondary port "WebCartPaymentGateway" and register your Gateway implementation in your module.go using Dingo. Since in a project multiple implementations can be active, we use BindMap and use the key (or code) of the gateway as key in the map. For example:

injector.BindMap((*interfaces.WebCartPaymentGateway)(nil), "offlinepayment").To(interfaces.OfflineWebCartPaymentGateway{})

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	EnableOfflinePayment bool `inject:"config:commerce.payment.enableOfflinePaymentGateway,optional"`
}

Module registers our profiler

func (*Module) Configure

func (m *Module) Configure(injector *dingo.Injector)

Configure module

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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