Skip to content

Commit

Permalink
Enable retail outlet by using xendit invoice
Browse files Browse the repository at this point in the history
Signed-off-by: Imre Nagi <imre.nagi@go-jek.com>
  • Loading branch information
Imre Nagi committed May 27, 2020
1 parent 011d457 commit 9f6f3e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
24 changes: 24 additions & 0 deletions gateway/xendit/alfamart.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package xendit

import (
xinvoice "github.com/xendit/xendit-go/invoice"
)

func NewAlfamartInvoice(rb *InvoiceRequestBuilder) (*AlfamartInvoice, error) {
return &AlfamartInvoice{
rb: rb,
}, nil
}

type AlfamartInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *AlfamartInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("ALFAMART")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
2 changes: 2 additions & 0 deletions gateway/xendit/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ func NewInvoiceRequestFromInvoice(inv *invoice.Invoice) (*xinvoice.CreateParams,
switch inv.Payment.PaymentType {
case payment.SourceOvo:
reqBuilder, err = NewOVOInvoice(req)
case payment.SourceAlfamart:
reqBuilder, err = NewAlfamartInvoice(req)
}
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion manage/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ func (c xenditCharger) Create(ctx context.Context, inv *invoice.Invoice) (*invoi
PaymentURL: xres.CheckoutURL,
TransactionID: xres.EWalletTransactionID,
}, nil
case payment.SourceOvo:
case payment.SourceOvo,
payment.SourceAlfamart:
invoiceRequest, err := factory.NewInvoiceRequestFromInvoice(inv)
if err != nil {
return nil, err
Expand Down

0 comments on commit 9f6f3e9

Please sign in to comment.