Durianpay is a Payment Gateway that can be used in Indonesia with the support of many payment methods such as VA, Bank Transfer, EWallet, Bank Transfer, Credit Card, and of course PayLater. Not only that, to get to Go Live the process is very easy.
But it's a shame, besides the API that can be used but there is no Official SDK that has been created and supported by Durianpay, this greatly adds to the workload when you want to use Golang as a language that will be integrated with Durianpay
All of API Documentation is on the Official Website of Durian Pay https://durianpay.id/docs/api/.
$ go get github.com/ayatmaulana/durianpay-go-sdk
package main
import (
"github.com/ayatmaulana/durianpay-go-sdk"
"github.com/ayatmaulana/durianpay-go-sdk/common"
)
...
func main() {
dp = durianpay.NewClient(&common.ClientConfig{
Mode: common.SANDBOX, // SANBOX or LIVE
ApiKey: "xxx",
EnableLogging: true,
})
}
Here's a brief high-level overview of the Library uses:
- This project uses pure
"net/http"
Golang package for requesting Durianpay API - For Logging purpose we use Logrus - https://github.com/sirupsen/logrus
- We use Testify - https://github.com/stretchr/testify for test our code
- And also using httpmock - https://github.com/jarcoal/httpmock to mocking http request in test
import (
"time"
"github.com/ayatmaulana/durianpay-go-sdk"
"github.com/ayatmaulana/durianpay-go-sdk/common"
"github.com/ayatmaulana/durianpay-go-sdk/modules/order"
)
...
payload := &order.CreateOrderRequestPayload{
Amount: "100000",
Currency: "IDR",
ExpiryDate: time.Now().Add(time.Hour + time.Duration(24)),
OrderRefID: "INV/ORDER/xxxxx1",
PaymentOption: "full_payment",
Metadata: order.Metadata{},
Items: []order.Items{
{
Name: "Soap",
Qty: 1,
Price: "100000",
Logo: "",
},
},
Customer: order.Customer{
CustomerRefID: "CUS/xx1" ,
GivenName: "Ayat Maulana",
Email: "myemail@example.com",
Mobile: "0812345678",
Address: order.Address{
ReceiverName: "Hehe",
ReceiverPhone: "0812345678",
},
},
}
res, err := dp.Order.CreateOrder(context.TODO(), payload)
if err != nil {
// handle error
log.Println(err)
}
ctx := context.TODO()
res, err := dp.Payment.ChargePaymentVA(ctx, &payment.ChargePaymentVARequestPayload{
OrderID: orderId,
Amount: "100000",
BankCode: payment.BCA,
Name: "Ayat Maulana",
}, &payment.SandboxOption{
ForceFail: true,
})
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(time.Millisecond * 10))
defer cancel()
res, err := dp.Disbursement.FetchBankList(ctx)
if err != nil {
log.Println(err)
}
log.Println(res)
- API Integration
- Order
- Payment
- Virtual Account
- Online Bank
- EWallet
- QRIS
- EWallet
- Retail Store (ALFAMART/INDOMARET)
- Online Card
- Buy Now Pay Later (BNPL)
- BCA Aggregator
- Promo
- Disbursement
- Settlement
- Refund
- Subscription
- EWallet Account
- Customer
- Static VA
- Testing
- Documentation per module
Interested in contributing to this project? Thanks so much for your interest! We are always looking for improvements to the project and contributions from open-source developers are greatly appreciated.
If you have a contribution in mind, just fork this repository, follow code guide and make pull request in main repository.
The Well app is free and open-source software licensed under the GNU General Public License v3.0.