Documentation
¶
Index ¶
- type CreateSubscriptionRequest
- type FailInvoiceRequest
- type GenerateInvoiceRequest
- type Interface
- type InvoiceEventFunc
- type Manager
- func (m *Manager) CreateSubscription(ctx context.Context, csr *CreateSubscriptionRequest) (*subscription.Subscription, error)
- 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) MustInvoiceCreatedEventFunc(fn InvoiceEventFunc)
- func (m *Manager) MustInvoiceFailedEventFunc(fn InvoiceEventFunc)
- func (m *Manager) MustInvoicePaidEventFunc(fn InvoiceEventFunc)
- func (m *Manager) MustInvoiceProcessedEventFunc(fn InvoiceEventFunc)
- func (m *Manager) MustInvoiceRepository(repo datastore.InvoiceRepository)
- func (m *Manager) MustMidtransTransactionStatusRepository(repo datastore.MidtransTransactionStatusRepository)
- func (m *Manager) MustPaymentConfigReader(repo datastore.PaymentConfigReader)
- func (m *Manager) MustSubscriptionRepository(repo datastore.SubscriptionRepository)
- func (m *Manager) PauseSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, error)
- 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 *coreapi.TransactionStatusResponse) error
- func (m *Manager) ProcessOVOCallback(ctx context.Context, ops *xendit.OVOPaymentStatus) error
- func (m *Manager) ProcessXenditEWalletCallback(ctx context.Context, status *xendit.EWalletPaymentStatus) error
- func (m *Manager) ProcessXenditInvoicesCallback(ctx context.Context, ips *xendit.InvoicePaymentStatus) error
- func (m *Manager) ResumeSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, error)
- func (m *Manager) StopSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, 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 CreateSubscriptionRequest ¶ added in v0.5.0
type CreateSubscriptionRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Amount float64 `json:"amount"`
UserID string `json:"user_id"`
Currency string `json:"currency"`
TotalReccurence int `json:"total_recurrence"`
CardToken string `json:"card_token"`
ChargeImmediately bool `json:"charge_immediately"`
Schedule struct {
Interval int `json:"interval"`
IntervalUnit string `json:"interval_unit"`
StartAt *time.Time `json:"start_at"`
} `json:"schedule"`
}
CreateSubscriptionRequest contains data for creating subscription
func (CreateSubscriptionRequest) StartAt ¶ added in v0.5.0
func (csr CreateSubscriptionRequest) StartAt() *time.Time
StartAt return the first time for generating the invoice. If it is charged immediately, start at will be now, otherwise it will be the start at send by user
func (CreateSubscriptionRequest) ToSubscription ¶ added in v0.5.0
func (csr CreateSubscriptionRequest) ToSubscription() *subscription.Subscription
ToSubscription creates new subscription instance
func (*CreateSubscriptionRequest) UnmarshalJSON ¶ added in v0.5.0
func (csr *CreateSubscriptionRequest) UnmarshalJSON(data []byte) error
UnmarshalJSON validates some data
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 {
Duration time.Duration `json:"duration"`
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"`
Items []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:"items"`
Callback *struct {
SuccessRedirectURL string `json:"success_redirect_url"`
FailureRedirectURL string `json:"failure_redirect_url"`
} `json:"callback"`
}
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)
// contains filtered or unexported methods
}
Interface payment management interface
type InvoiceEventFunc ¶ added in v1.3.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handle business logic related to payment gateway
func NewManager ¶
func NewManager( config localconfig.Config, secret localconfig.PaymentSecret, ) *Manager
NewManager creates a new payment manager
func (*Manager) CreateSubscription ¶ added in v0.5.0
func (m *Manager) CreateSubscription(ctx context.Context, csr *CreateSubscriptionRequest) (*subscription.Subscription, error)
CreateSubscription creates new subscription
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) MustInvoiceCreatedEventFunc ¶ added in v1.3.0
func (m *Manager) MustInvoiceCreatedEventFunc(fn InvoiceEventFunc)
MustInvoiceCreatedEventFunc set event handler for emitting invoice created event
func (*Manager) MustInvoiceFailedEventFunc ¶ added in v1.3.0
func (m *Manager) MustInvoiceFailedEventFunc(fn InvoiceEventFunc)
MustInvoiceFailedEventFunc set event handler for emitting invoice failed event
func (*Manager) MustInvoicePaidEventFunc ¶ added in v1.3.0
func (m *Manager) MustInvoicePaidEventFunc(fn InvoiceEventFunc)
MustInvoicePaidEventFunc set event handler for emitting invoice processed event
func (*Manager) MustInvoiceProcessedEventFunc ¶ added in v1.3.0
func (m *Manager) MustInvoiceProcessedEventFunc(fn InvoiceEventFunc)
MustInvoiceProcessedEventFunc set event handler for emitting invoice processed event
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) MustSubscriptionRepository ¶ added in v0.5.0
func (m *Manager) MustSubscriptionRepository(repo datastore.SubscriptionRepository)
MustSubscriptionRepository mandatory mapping the subscription repository
func (*Manager) PauseSubscription ¶ added in v0.5.0
func (m *Manager) PauseSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, error)
PauseSubscription pause active subscription
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 ¶
func (m *Manager) ProcessMidtransCallback(ctx context.Context, mr *coreapi.TransactionStatusResponse) error
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) ProcessXenditEWalletCallback ¶ added in v1.2.0
func (*Manager) ProcessXenditInvoicesCallback ¶
func (m *Manager) ProcessXenditInvoicesCallback(ctx context.Context, ips *xendit.InvoicePaymentStatus) error
ProcessXenditInvoicesCallback process xendit invoice payment notification from xendit
func (*Manager) ResumeSubscription ¶ added in v0.5.0
func (m *Manager) ResumeSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, error)
ResumeSubscription resume paused subscription
func (*Manager) StopSubscription ¶ added in v0.5.0
func (m *Manager) StopSubscription(ctx context.Context, subsNumber string) (*subscription.Subscription, error)
StopSubscription stop subscription
type MidtransProcessor ¶
type MidtransProcessor interface {
ProcessMidtransCallback(ctx context.Context, mr *coreapi.TransactionStatusResponse) 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
ProcessXenditEWalletCallback(ctx context.Context, status *xendit.EWalletPaymentStatus) error
}
XenditProcessor callback handler for xendit