Skip to content

Commit

Permalink
Add qris and shopeepay in xendit
Browse files Browse the repository at this point in the history
Signed-off-by: Imre Nagi <imre.nagi2812@gmail.com>
  • Loading branch information
imrenagi committed Jul 12, 2021
1 parent d75d344 commit f62d58f
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 68 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ In general, this payment proxy can support payment through this following channe
1. For simplify the query creation for database join, I use [gorm.io](https://gorm.io/) as the ORM library.
1. This proxy is not made for supporting all use cases available out there. It's hard requirement is just so that people can accept payment with as low effort as possible without need to worry about custom UI flow.
1. No callback trigger at least of now once the payment manager is done procesing this request. This will be the next priority of the next release. This issue is documented [here](https://github.com/imrenagi/go-payment/issues/5)
1. Callback or redirect URL is globally configured. This means, you cant configure callback for each request differently on the fly.

## Implemented Channels

Expand All @@ -79,24 +80,25 @@ This tables shows which payment channels that has been implemented by this proxy

:x: : not yet supported natively by payment gateway

| Channels | Midtrans | Xendit |
| ------------------------------- | ----------------------------------- | ------------------------ |
| Credit Card without installment | :white_check_mark: | :white_check_mark: |
| Credit Card with installment | :white_check_mark: | :x: |
| 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: | n/a |
| Gopay | :white_check_mark: | :x: |
| OVO | :x: | :white_check_mark: |
| DANA | :x: | :white_check_mark: |
| LinkAja | :x: | :white_check_mark: |
| Akulaku | :white_check_mark: | :x: |
| Kredivo | :x: | :heavy_exclamation_mark: |
| Channels | Midtrans (Snap) | Xendit (ewallet/XenInvoice) |
| ------------------------------- | ----------------------------------- | --------------------------- |
| Credit Card without installment | :white_check_mark: | :white_check_mark: |
| Credit Card with installment | :white_check_mark: | :x: |
| 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 | :heavy_exclamation_mark: | :white_check_mark: |
| Alfamart, Alfamidi, Dan+Dan | :white_check_mark: | :white_check_mark: |
| QRIS | :white_check_mark: | :white_check_mark: |
| Gopay | :white_check_mark: | :x: |
| OVO | :x: | :white_check_mark: |
| DANA | :x: | :white_check_mark: |
| LinkAja | :x: | :white_check_mark: |
| ShopeePay | :white_check_mark: | :white_check_mark: |
| Akulaku | :white_check_mark: | :x: |
| Kredivo | :x: | :heavy_exclamation_mark: |

## Getting Started

Expand Down
1 change: 1 addition & 0 deletions datastore/inmemory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func (r PaymentConfigRepository) FindByPaymentType(ctx context.Context, paymentT
payment.SourceOvo,
payment.SourceLinkAja,
payment.SourceShopeePay,
payment.SourceQRIS,
payment.SourceDana:
for _, ewallet := range r.config.EWallets {
if ewallet.PaymentType == paymentType {
Expand Down
11 changes: 11 additions & 0 deletions example/server/payment-methods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ ewallets:
waiting_time:
duration: 15
unit: minute
- gateway: xendit
payment_type: "qris"
display_name: "QRIS"
admin_fee:
IDR:
val_percentage: 0
val_currency: 0
currency: "IDR"
waiting_time:
duration: 15
unit: minute
cstores:
- gateway: midtrans
payment_type: alfamart
Expand Down
2 changes: 2 additions & 0 deletions gateway/midtrans/facade.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func NewSnapFromInvoice(inv *invoice.Invoice) (*midsnap.Request, error) {
return snap.NewCreditCard(inv)
case payment.SourceShopeePay:
return snap.NewShopeePay(inv)
case payment.SourceQRIS:
return snap.NewGopay(inv)
default:
return nil, fmt.Errorf("payment type not known")
}
Expand Down
104 changes: 54 additions & 50 deletions gateway/xendit/facade.go
Original file line number Diff line number Diff line change
@@ -1,69 +1,73 @@
package xendit

import (
"fmt"
"fmt"

"github.com/xendit/xendit-go/ewallet"
xinvoice "github.com/xendit/xendit-go/invoice"
"github.com/xendit/xendit-go/ewallet"
xinvoice "github.com/xendit/xendit-go/invoice"

"github.com/imrenagi/go-payment"
v1 "github.com/imrenagi/go-payment/gateway/xendit/ewallet/v1"
v2 "github.com/imrenagi/go-payment/gateway/xendit/ewallet/v2"
"github.com/imrenagi/go-payment"
v1 "github.com/imrenagi/go-payment/gateway/xendit/ewallet/v1"
v2 "github.com/imrenagi/go-payment/gateway/xendit/ewallet/v2"
"github.com/imrenagi/go-payment/gateway/xendit/xeninvoice"
"github.com/imrenagi/go-payment/invoice"
)

// NewEWalletChargeRequestFromInvoice create ewallet charge params for xendit ewallet API
func NewEWalletChargeRequestFromInvoice(inv *invoice.Invoice) (*ewallet.CreateEWalletChargeParams, error) {
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return v2.NewOVO(inv)
case payment.SourceDana:
return v2.NewDana(inv)
case payment.SourceLinkAja:
return v2.NewLinkAja(inv)
default:
return nil, fmt.Errorf("unsupported payment method")
}
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return v2.NewOVO(inv)
case payment.SourceDana:
return v2.NewDana(inv)
case payment.SourceLinkAja:
return v2.NewLinkAja(inv)
default:
return nil, fmt.Errorf("unsupported payment method")
}
}

// Deprecated: NewEwalletRequestFromInvoice creates ewallet request for xendit
func NewEwalletRequestFromInvoice(inv *invoice.Invoice) (*ewallet.CreatePaymentParams, error) {
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return v1.NewOVO(inv)
case payment.SourceDana:
return v1.NewDana(inv)
case payment.SourceLinkAja:
return v1.NewLinkAja(inv)
default:
return nil, fmt.Errorf("payment type is not known")
}
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return v1.NewOVO(inv)
case payment.SourceDana:
return v1.NewDana(inv)
case payment.SourceLinkAja:
return v1.NewLinkAja(inv)
default:
return nil, fmt.Errorf("payment type is not known")
}
}

func NewInvoiceRequestFromInvoice(inv *invoice.Invoice) (*xinvoice.CreateParams, error) {
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return xeninvoice.NewOVO(inv)
case payment.SourceDana:
return xeninvoice.NewDana(inv)
case payment.SourceLinkAja:
return xeninvoice.NewLinkAja(inv)
case payment.SourceAlfamart:
return xeninvoice.NewAlfamart(inv)
case payment.SourceBCAVA:
return xeninvoice.NewBCAVA(inv)
case payment.SourceBRIVA:
return xeninvoice.NewBRIVA(inv)
case payment.SourceBNIVA:
return xeninvoice.NewBNIVA(inv)
case payment.SourcePermataVA:
return xeninvoice.NewPermataVA(inv)
case payment.SourceMandiriVA:
return xeninvoice.NewMandiriVA(inv)
case payment.SourceCreditCard:
return xeninvoice.NewCreditCard(inv)
default:
return nil, fmt.Errorf("payment type is not known")
}
switch inv.Payment.PaymentType {
case payment.SourceOvo:
return xeninvoice.NewOVO(inv)
case payment.SourceDana:
return xeninvoice.NewDana(inv)
case payment.SourceLinkAja:
return xeninvoice.NewLinkAja(inv)
case payment.SourceAlfamart:
return xeninvoice.NewAlfamart(inv)
case payment.SourceBCAVA:
return xeninvoice.NewBCAVA(inv)
case payment.SourceBRIVA:
return xeninvoice.NewBRIVA(inv)
case payment.SourceBNIVA:
return xeninvoice.NewBNIVA(inv)
case payment.SourcePermataVA:
return xeninvoice.NewPermataVA(inv)
case payment.SourceMandiriVA:
return xeninvoice.NewMandiriVA(inv)
case payment.SourceCreditCard:
return xeninvoice.NewCreditCard(inv)
case payment.SourceShopeePay:
return xeninvoice.NewShopeePay(inv)
case payment.SourceQRIS:
return xeninvoice.NewQRIS(inv)
default:
return nil, fmt.Errorf("payment type is not known")
}
}
15 changes: 15 additions & 0 deletions gateway/xendit/xeninvoice/qris.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package xeninvoice

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

"github.com/imrenagi/go-payment/invoice"
)

func NewQRIS(inv *invoice.Invoice) (*xinvoice.CreateParams, error) {
return newBuilder(inv).
AddPaymentMethod("LINKAJA").
AddPaymentMethod("DANA").
AddPaymentMethod("OVO").
Build()
}
13 changes: 13 additions & 0 deletions gateway/xendit/xeninvoice/shoopepay.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package xeninvoice

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

"github.com/imrenagi/go-payment/invoice"
)

func NewShopeePay(inv *invoice.Invoice) (*xinvoice.CreateParams, error) {
return newBuilder(inv).
AddPaymentMethod("SHOPEEPAY").
Build()
}
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
SourceDana PaymentType = "dana"
SourceLinkAja PaymentType = "linkaja"
SourceShopeePay PaymentType = "shopeepay"
SourceQRIS PaymentType = "qris"
SourceBRIVA PaymentType = "bri_va"
SourceMandiriVA PaymentType = "mandiri_va"
)
Expand Down

0 comments on commit f62d58f

Please sign in to comment.