Documentation
¶
Index ¶
- type FailInvoiceRequest
- type GenerateInvoiceRequest
- type Interface
- type Manager
- func (m *Manager) FailInvoice(ctx context.Context, fir *FailInvoiceRequest) (*invoice.Invoice, error)
- func (m *Manager) GenerateInvoice(ctx context.Context, gir *GenerateInvoiceRequest) (*invoice.Invoice, error)
- func (m *Manager) GetInvoice(ctx context.Context, number string) (*invoice.Invoice, error)
- func (m *Manager) GetPaymentMethods(ctx context.Context, opts ...payment.Option) (*PaymentMethodList, error)
- func (m *Manager) MapMidtransTransactionStatusRepository(repo datastore.MidtransTransactionStatusRepository) error
- func (m *Manager) MustInvoiceRepository(repo datastore.InvoiceRepository)
- func (m *Manager) MustMidtransTransactionStatusRepository(repo datastore.MidtransTransactionStatusRepository)
- func (m *Manager) MustPaymentConfigReader(repo datastore.PaymentConfigReader)
- func (m *Manager) PayInvoice(ctx context.Context, pir *PayInvoiceRequest) (*invoice.Invoice, error)
- func (m *Manager) ProcessDANACallback(ctx context.Context, dps *xendit.DANAPaymentStatus) error
- func (m *Manager) ProcessInvoice(ctx context.Context, invoiceNumber string) (*invoice.Invoice, error)
- func (m *Manager) ProcessLinkAjaCallback(ctx context.Context, lps *xendit.LinkAjaPaymentStatus) error
- func (m *Manager) ProcessMidtransCallback(ctx context.Context, mr midgo.Response) error
- func (m *Manager) ProcessOVOCallback(ctx context.Context, ops *xendit.OVOPaymentStatus) error
- func (m *Manager) ProcessXenditInvoicesCallback(ctx context.Context, ips *xendit.InvoicePaymentStatus) error
- type MidtransProcessor
- type PayInvoiceRequest
- type Payment
- type PaymentMethodList
- type XenditProcessor
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FailInvoiceRequest ¶
type FailInvoiceRequest struct {
InvoiceNumber string `json:"invoice_number"`
TransactionID string `json:"transaction_id"`
Reason string `json:"reason"`
}
FailInvoiceRequest provide which invoice that is failed and its reason
type GenerateInvoiceRequest ¶
type GenerateInvoiceRequest struct {
Payment struct {
PaymentType payment.PaymentType `json:"payment_type"`
CreditCardDetail *invoice.CreditCardDetail `json:"credit_card,omitempty"`
} `json:"payment"`
Customer struct {
Name string `json:"name"`
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
} `json:"customer"`
Item struct {
Name string `json:"name"`
Category string `json:"category"`
MerchantName string `json:"merchant"`
Description string `json:"description"`
Qty int `json:"qty"`
Price float64 `json:"price"`
Currency string `json:"currency"`
} `json:"item"`
}
GenerateInvoiceRequest provide to generate new invoice
type Interface ¶
type Interface interface {
// return the payment methods available in payment service
GetPaymentMethods(ctx context.Context, opts ...payment.Option) (*PaymentMethodList, error)
// return invoice given its invoice number
GetInvoice(ctx context.Context, number string) (*invoice.Invoice, error)
// generate new invoice
GenerateInvoice(ctx context.Context, gir *GenerateInvoiceRequest) (*invoice.Invoice, error)
// PayInvoice pays an invoice
PayInvoice(ctx context.Context, pir *PayInvoiceRequest) (*invoice.Invoice, error)
// ProcessInvoice ...
ProcessInvoice(ctx context.Context, invoiceNumber string) (*invoice.Invoice, error)
// FailInvoice make the invoice failed
FailInvoice(ctx context.Context, fir *FailInvoiceRequest) (*invoice.Invoice, error)
}
Interface payment management interface
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handle business logic related to payment gateway
func NewManager ¶
func NewManager( secret localconfig.PaymentSecret, ) *Manager
NewManager creates a new payment manager
func (*Manager) FailInvoice ¶
func (m *Manager) FailInvoice(ctx context.Context, fir *FailInvoiceRequest) (*invoice.Invoice, error)
FailInvoice fails an invoice if the payment is either failed or expired
func (*Manager) GenerateInvoice ¶
func (m *Manager) GenerateInvoice(ctx context.Context, gir *GenerateInvoiceRequest) (*invoice.Invoice, error)
GenerateInvoice generates new invoice
func (*Manager) GetInvoice ¶
GetInvoice return invoice given its invoice number
func (*Manager) GetPaymentMethods ¶
func (m *Manager) GetPaymentMethods(ctx context.Context, opts ...payment.Option) (*PaymentMethodList, error)
GetPaymentMethods return the payment methods available in payment service
func (*Manager) MapMidtransTransactionStatusRepository ¶
func (m *Manager) MapMidtransTransactionStatusRepository(repo datastore.MidtransTransactionStatusRepository) error
MapMidtransTransactionStatusRepository mapping the midtrans transaction status repository
func (*Manager) MustInvoiceRepository ¶
func (m *Manager) MustInvoiceRepository(repo datastore.InvoiceRepository)
MustInvoiceRepository mandatory mapping the invoice repository
func (*Manager) MustMidtransTransactionStatusRepository ¶
func (m *Manager) MustMidtransTransactionStatusRepository(repo datastore.MidtransTransactionStatusRepository)
MustMidtransTransactionStatusRepository mandatory mapping the midtrans transaction status repo interface
func (*Manager) MustPaymentConfigReader ¶
func (m *Manager) MustPaymentConfigReader(repo datastore.PaymentConfigReader)
MustPaymentConfigReader mandatory mapping for payment config repository
func (*Manager) PayInvoice ¶
PayInvoice pays an invoice. Invoice can only be paid if it is in right state
func (*Manager) ProcessDANACallback ¶
ProcessDANACallback process dana payment notification from xendit
func (*Manager) ProcessInvoice ¶
func (m *Manager) ProcessInvoice(ctx context.Context, invoiceNumber string) (*invoice.Invoice, error)
ProcessInvoice used if payment is initiated from user's end. It's either because they are using VA or any payment methods that requires payment action from the user after they choose a payment method/see payment instruction
func (*Manager) ProcessLinkAjaCallback ¶
func (m *Manager) ProcessLinkAjaCallback(ctx context.Context, lps *xendit.LinkAjaPaymentStatus) error
ProcessLinkAjaCallback process linkaja payment notification from xendit
func (*Manager) ProcessMidtransCallback ¶
ProcessMidtransCallback takes care of notification sent by midtrans. This checks the validity of the sign key and the similarity between the notification and transaction satus.
func (*Manager) ProcessOVOCallback ¶
ProcessOVOCallback process ovo payment notification from xendit
func (*Manager) ProcessXenditInvoicesCallback ¶
func (m *Manager) ProcessXenditInvoicesCallback(ctx context.Context, ips *xendit.InvoicePaymentStatus) error
ProcessXenditInvoicesCallback process xendit invoice payment notification from xendit
type MidtransProcessor ¶
type MidtransProcessor interface {
ProcessMidtransCallback(ctx context.Context, mr mgo.Response) error
}
MidtransProcessor callback handler for midtrans
type PayInvoiceRequest ¶
type PayInvoiceRequest struct {
InvoiceNumber string `json:"invoice_number"`
TransactionID string `json:"transaction_id"`
}
PayInvoiceRequest provide information which invoice to pay and by using what transactionID
type Payment ¶
type Payment interface {
Interface
XenditProcessor
MidtransProcessor
}
Payment combines all interface used for payment manager
type PaymentMethodList ¶
type PaymentMethodList struct {
CardPayment *config.CardPayment `json:"card_payment"`
BankTransfers []config.NonCardPayment `json:"bank_transfers"`
EWallets []config.NonCardPayment `json:"ewallets"`
CStores []config.NonCardPayment `json:"cstores"`
CardlessCredits []config.NonCardPayment `json:"cardless_credits"`
}
PaymentMethodList is the payment method list showed to the user
type XenditProcessor ¶
type XenditProcessor interface {
ProcessDANACallback(ctx context.Context, dps *xendit.DANAPaymentStatus) error
ProcessLinkAjaCallback(ctx context.Context, lps *xendit.LinkAjaPaymentStatus) error
ProcessOVOCallback(ctx context.Context, ops *xendit.OVOPaymentStatus) error
ProcessXenditInvoicesCallback(ctx context.Context, ips *xendit.InvoicePaymentStatus) error
}
XenditProcessor callback handler for xendit