Durianpay SDK for Golang (Unofficial)
๐ง Project Philosophy
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
๐ Official Documentation
All of API Documentation is on the Official Website of Durian Pay https://durianpay.id/docs/api/.
โ ๏ธ API documentation is subject to change without notice, so this SDK may not work properly.
๐ Installation
$ go get github.com/iqbal-maxiapp/durianpay-go-sdk
Usage
package main
import (
"github.com/iqbal-maxiapp/durianpay-go-sdk"
"github.com/iqbal-maxiapp/durianpay-go-sdk/common"
)
...
func main() {
dp = durianpay.NewClient(&common.ClientConfig{
Mode: common.SANDBOX, // SANBOX or LIVE
ApiKey: "xxx",
EnableLogging: true,
})
}
๐จโ๐ป Library Usage
Here's a brief high-level overview of the Library uses:
๐ด Example
Create Order
import (
"time"
"github.com/iqbal-maxiapp/durianpay-go-sdk"
"github.com/iqbal-maxiapp/durianpay-go-sdk/common"
"github.com/iqbal-maxiapp/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)
}
Create Payment
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,
})
Use with Context
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)
๐ Todo
- 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
โ๏ธ Contributing
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.
๐ License
The Well app is free and open-source software licensed under the GNU General Public License v3.0.