Skip to content

Commit

Permalink
Merge branch 'xenVA'
Browse files Browse the repository at this point in the history
  • Loading branch information
imrenagi committed May 28, 2020
2 parents 5686ad1 + b3433ae commit d8e8b45
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 14 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ This tables shows which payment channels that has been implemented by this proxy
| ------------------------------- | ----------------------------------- | ------------------------ |
| Credit Card without installment | :white_check_mark: | :heavy_exclamation_mark: |
| Credit Card with installment | :white_check_mark: | :x: |
| BCA VA | :white_check_mark: | :heavy_exclamation_mark: |
| Mandiri VA | :white_check_mark: | :heavy_exclamation_mark: |
| BNI VA | :white_check_mark: | :heavy_exclamation_mark: |
| Permata VA | :white_check_mark: | :heavy_exclamation_mark: |
| Other VA | :white_check_mark: | :heavy_exclamation_mark: |
| BRI VA | :x: | :heavy_exclamation_mark: |
| Alfamart, Alfamidi, Dan+Dan | :white_check_mark: | :heavy_exclamation_mark: |
| BCA VA | :white_check_mark: | :white_check_mark: |
| Mandiri VA | :white_check_mark: | :white_check_mark: |
| BNI VA | :white_check_mark: | :white_check_mark: |
| Permata VA | :white_check_mark: | :white_check_mark: |
| Other VA | :white_check_mark: | :x: |
| BRI VA | :x: | :white_check_mark: |
| Alfamart, Alfamidi, Dan+Dan | :white_check_mark: | :white_check_mark: |
| QRIS | :white_check_mark: via Gopay Option | :x: |
| Gopay | :white_check_mark: | :x: |
| OVO | :x: | :white_check_mark: |
Expand Down
3 changes: 2 additions & 1 deletion datastore/inmemory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ func (r PaymentConfigRepository) FindByPaymentType(ctx context.Context, paymentT
case payment.SourceBCAVA,
payment.SourcePermataVA,
payment.SourceBNIVA,
payment.SourceBRIVA,
payment.SourceOtherVA,
payment.SourceEchannel:
payment.SourceMandiriVA:
for _, bt := range r.config.BankTransfers {
if bt.PaymentType == paymentType {
return &bt, nil
Expand Down
15 changes: 13 additions & 2 deletions example/server/payment-methods.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ card_payment:
val_currency: 2200
currency: "IDR"
bank_transfers:
- gateway: xendit
payment_type: "bri_va"
display_name: "BRI"
admin_fee:
IDR:
val_percentage: 0
val_currency: 4000
currency: "IDR"
waiting_time:
duration: 1
unit: day
- gateway: midtrans
payment_type: "bca_va"
display_name: "BCA"
Expand All @@ -46,8 +57,8 @@ bank_transfers:
duration: 1
unit: day
- gateway: midtrans
payment_type: "echannel"
display_name: "Mandiri Bill"
payment_type: "mandiri_va"
display_name: "Mandiri"
admin_fee:
IDR:
val_percentage: 0
Expand Down
2 changes: 1 addition & 1 deletion gateway/midtrans/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func NewSnapRequestFromInvoice(inv *invoice.Invoice) (*gomidtrans.SnapReq, error
reqBuilder, err = NewBCAVA(snapRequestBuilder)
case payment.SourcePermataVA:
reqBuilder, err = NewPermataVA(snapRequestBuilder)
case payment.SourceEchannel:
case payment.SourceMandiriVA:
reqBuilder, err = NewMandiriBill(snapRequestBuilder)
case payment.SourceBNIVA:
reqBuilder, err = NewBNIVA(snapRequestBuilder)
Expand Down
24 changes: 24 additions & 0 deletions gateway/xendit/bca.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 NewBCAVAInvoice(rb *InvoiceRequestBuilder) (*BCAVAInvoice, error) {
return &BCAVAInvoice{
rb: rb,
}, nil
}

type BCAVAInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *BCAVAInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("BCA")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
24 changes: 24 additions & 0 deletions gateway/xendit/bni.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 NewBNIVAInvoice(rb *InvoiceRequestBuilder) (*BNIVAInvoice, error) {
return &BNIVAInvoice{
rb: rb,
}, nil
}

type BNIVAInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *BNIVAInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("BNI")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
24 changes: 24 additions & 0 deletions gateway/xendit/bri.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 NewBRIVAInvoice(rb *InvoiceRequestBuilder) (*BRIVAInvoice, error) {
return &BRIVAInvoice{
rb: rb,
}, nil
}

type BRIVAInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *BRIVAInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("BRI")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
10 changes: 10 additions & 0 deletions gateway/xendit/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ func NewInvoiceRequestFromInvoice(inv *invoice.Invoice) (*xinvoice.CreateParams,
reqBuilder, err = NewOVOInvoice(req)
case payment.SourceAlfamart:
reqBuilder, err = NewAlfamartInvoice(req)
case payment.SourceBCAVA:
reqBuilder, err = NewBCAVAInvoice(req)
case payment.SourceBRIVA:
reqBuilder, err = NewBRIVAInvoice(req)
case payment.SourceBNIVA:
reqBuilder, err = NewBNIVAInvoice(req)
case payment.SourcePermataVA:
reqBuilder, err = NewPermataVAInvoice(req)
case payment.SourceMandiriVA:
reqBuilder, err = NewMandiriVAInvoice(req)
}
if err != nil {
return nil, err
Expand Down
24 changes: 24 additions & 0 deletions gateway/xendit/mandiri.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 NewMandiriVAInvoice(rb *InvoiceRequestBuilder) (*MandiriVAInvoice, error) {
return &MandiriVAInvoice{
rb: rb,
}, nil
}

type MandiriVAInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *MandiriVAInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("MANDIRI")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
24 changes: 24 additions & 0 deletions gateway/xendit/permata.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 NewPermataVAInvoice(rb *InvoiceRequestBuilder) (*PermataVAInvoice, error) {
return &PermataVAInvoice{
rb: rb,
}, nil
}

type PermataVAInvoice struct {
rb *InvoiceRequestBuilder
}

func (o *PermataVAInvoice) Build() (*xinvoice.CreateParams, error) {
o.rb.AddPaymentMethod("PERMATA")
req, err := o.rb.Build()
if err != nil {
return nil, err
}
return req, nil
}
3 changes: 1 addition & 2 deletions manage/charger.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ func (c xenditCharger) Create(ctx context.Context, inv *invoice.Invoice) (*invoi
PaymentURL: xres.CheckoutURL,
TransactionID: xres.EWalletTransactionID,
}, nil
case payment.SourceOvo,
payment.SourceAlfamart:
default:
invoiceRequest, err := factory.NewInvoiceRequestFromInvoice(inv)
if err != nil {
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ const (
SourcePermataVA PaymentType = "permata_va"
SourceBCAVA PaymentType = "bca_va"
SourceOtherVA PaymentType = "other_va"
SourceEchannel PaymentType = "echannel"
SourceAlfamart PaymentType = "alfamart"
SourceGopay PaymentType = "gopay"
SourceAkulaku PaymentType = "akulaku"
SourceOvo PaymentType = "ovo"
SourceDana PaymentType = "dana"
SourceLinkAja PaymentType = "linkaja"
SourceBRIVA PaymentType = "bri_va"
SourceMandiriVA PaymentType = "mandiri_va"
)

// Bank is a bank
Expand Down

0 comments on commit d8e8b45

Please sign in to comment.