Skip to content

Commit

Permalink
Merge pull request #4 from fanchann/development
Browse files Browse the repository at this point in the history
development
  • Loading branch information
zakirkun authored May 11, 2024
2 parents cbb60c4 + 6eec099 commit 8509ffc
Show file tree
Hide file tree
Showing 20 changed files with 820 additions and 178 deletions.
88 changes: 88 additions & 0 deletions _examples/close_payment.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"
)

func Example_close_payment_req_transaction() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

signStr := utils.Signature{
Amount: 50000,
PrivateKey: "your_private_key_here",
MerchantCode: "T14302",
MerchanReff: "INV345675",
}

c.SetSignature(signStr)

bodyReq := client.ClosePaymentBodyRequest{
Method: utils.CHANNEL_QRIS_SHOPEEPAY,
MerchantRef: "INV345675",
Amount: 50000,
CustomerName: "Farda Ayu Nurfatika",
CustomerEmail: "fardaayu@gmail.com",
CustomerPhone: "6285111990223",
ReturnURL: "https://thisisreturnurl.com/redirect",
ExpiredTime: client.SetTripayExpiredTime(24), // 24 Hour
Signature: c.GetSignature(),
OrderItems: []client.OrderItemClosePaymentRequest{
{
SKU: "Produk1",
Name: "nama produk 1",
Price: 50000,
Quantity: 1,
ProductURL: "https://producturl.com",
ImageURL: "https://imageurl.com",
},
},
}

response, err := c.ClosePaymentRequestTransaction(bodyReq)
if err != nil {
panic(err)
}

fmt.Printf("response: %v\n", response)
/*
response :
&{true {DEV-T14302154834TY1ML INV345675 static QRIS_SHOPEEPAY QRIS Custom by ShopeePay Farda Ayu Nurfatika fardaayu@gmail.com https://thisisreturnurl.com/redirect 50000 1100 0 1100 48900 <nil> https://tripay.co.id/checkout/DEV-T14302154834TY1ML UNPAID 1715343068 [{Produk1 nama produk 1 50000 1 50000 https://producturl.com https://imageurl.com}] [{Pembayaran via QRIS [Masuk ke aplikasi dompet digital Anda yang telah mendukung QRIS Pindai/Scan QR Code yang tersedia Akan muncul detail transaksi. Pastikan data transaksi sudah sesuai Selesaikan proses pembayaran Anda Transaksi selesai. Simpan bukti pembayaran Anda]} {Pembayaran via QRIS (Mobile) [Download QR Code pada invoice Masuk ke aplikasi dompet digital Anda yang telah mendukung QRIS Upload QR Code yang telah di download tadi Akan muncul detail transaksi. Pastikan data transaksi sudah sesuai Selesaikan proses pembayaran Anda Transaksi selesai. Simpan bukti pembayaran Anda]}] SANDBOX MODE https://tripay.co.id/qr/DEV-T14302154834TY1ML}}
*/
}

func Example_close_payment_get_detail_transaction() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

signStr := utils.Signature{
Amount: 50000,
PrivateKey: "your_private_key_here",
MerchantCode: "T14302",
MerchanReff: "INV345675",
}

c.SetSignature(signStr)

referenceId := "DEV-T14302154834TY1ML"
response, err := c.ClosePaymentTransactionGetDetail(referenceId)
if err != nil {
panic(err)
}
fmt.Printf("response: %v\n", response)
/*
response :
&{true Transaction found {DEV-T14302154834TY1ML INV345675 static QRIS_SHOPEEPAY QRIS Custom by ShopeePay Farda Ayu Nurfatika fardaayu@gmail.com https://thisisreturnurl.com/redirect 50000 1100 0 1100 48900 <nil> https://tripay.co.id/checkout/DEV-T14302154834TY1ML UNPAID 1715343068 [{Produk1 nama produk 1 50000 1 50000 https://producturl.com https://imageurl.com}] [{Pembayaran via QRIS [Masuk ke aplikasi dompet digital Anda yang telah mendukung QRIS Pindai/Scan QR Code yang tersedia Akan muncul detail transaksi. Pastikan data transaksi sudah sesuai Selesaikan proses pembayaran Anda Transaksi selesai. Simpan bukti pembayaran Anda]} {Pembayaran via QRIS (Mobile) [Download QR Code pada invoice Masuk ke aplikasi dompet digital Anda yang telah mendukung QRIS Upload QR Code yang telah di download tadi Akan muncul detail transaksi. Pastikan data transaksi sudah sesuai Selesaikan proses pembayaran Anda Transaksi selesai. Simpan bukti pembayaran Anda]}] SANDBOX MODE https://tripay.co.id/qr/DEV-T14302154834TY1ML}}
*/
}
33 changes: 33 additions & 0 deletions _examples/merchant_fee_calc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"
)

func Example_merchant_fee_calculator() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

feeCalcParam := client.FeeCalcParam{
Amount: 100000,
Code: utils.CHANNEL_ALFAMIDI,
}

response, err := c.FeeCalc(feeCalcParam)
if err != nil {
panic(err)
}

fmt.Printf("response: %v\n", response)
/*
response:
&{true [{ALFAMIDI Alfamidi {3500 0.00 <nil> <nil>} {3500 0}}]}
*/
}
27 changes: 27 additions & 0 deletions _examples/merchant_payment_channel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"
)

func Example_merchant_payment_channel() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

response, err := c.MerchantPay()
if err != nil {
panic(err)
}
fmt.Printf("response: %v\n", response)
/*
response:
&{true Success [{Virtual Account MYBVA Maybank Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/ZT91lrOEad1582929126.png true} {Virtual Account PERMATAVA Permata Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/szezRhAALB1583408731.png true} {Virtual Account BNIVA BNI Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/n22Qsh8jMa1583433577.png true} {Virtual Account BRIVA BRI Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/8WQ3APST5s1579461828.png true} {Virtual Account MANDIRIVA Mandiri Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/T9Z012UE331583531536.png true} {Virtual Account BCAVA BCA Virtual Account direct {5500 0} {0 0} {5500 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/ytBKvaleGy1605201833.png true} {Virtual Account MUAMALATVA Muamalat Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/GGwwcgdYaG1611929720.png true} {Virtual Account CIMBVA CIMB Niaga Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/WtEJwfuphn1614003973.png true} {Virtual Account BSIVA BSI Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/tEclz5Assb1643375216.png true} {Virtual Account OCBCVA OCBC NISP Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/ysiSToLvKl1644244798.png true} {Virtual Account DANAMONVA Danamon Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/F3pGzDOLUz1644245546.png true} {Virtual Account OTHERBANKVA Other Bank Virtual Account direct {4250 0} {0 0} {4250 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/qQYo61sIDa1702995837.png true} {Convenience Store ALFAMART Alfamart direct {3500 0} {0 0} {3500 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/jiGZMKp2RD1583433506.png true} {Convenience Store INDOMARET Indomaret direct {3500 0} {0 0} {3500 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/zNzuO5AuLw1583513974.png true} {Convenience Store ALFAMIDI Alfamidi direct {3500 0} {0 0} {3500 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/aQTdaUC2GO1593660384.png true} {E-Wallet OVO OVO redirect {0 3} {0 0} {0 0} 1000 0 https://assets.tripay.co.id/upload/payment-icon/fH6Y7wDT171586199243.png true} {E-Wallet QRIS QRIS by ShopeePay direct {750 0} {0 0} {750 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/BpE4BPVyIw1605597490.png true} {E-Wallet QRISC QRIS (Customizable) direct {750 0} {0 0} {750 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/m9FtFwaBCg1623157494.png true} {E-Wallet QRIS2 QRIS direct {750 0} {0 0} {750 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/8ewGzP6SWe1649667701.png true} {E-Wallet DANA DANA redirect {0 3} {0 0} {0 0} 1000 0 https://assets.tripay.co.id/upload/payment-icon/sj3UHLu8Tu1655719621.png true} {E-Wallet SHOPEEPAY ShopeePay redirect {0 3} {0 0} {0 0} 1000 0 https://assets.tripay.co.id/upload/payment-icon/d204uajhlS1655719774.png true} {E-Wallet QRIS_SHOPEEPAY QRIS Custom by ShopeePay direct {750 0} {0 0} {750 0} 0 0 https://assets.tripay.co.id/upload/payment-icon/DM8sBd1i9y1681718593.png true}]}
*/
}
52 changes: 52 additions & 0 deletions _examples/merchant_transactions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"
)

func Example_merchant_transactions() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}
response, err := c.MerchantTransactions()
if err != nil {
panic(err)
}

fmt.Printf("response: %v\n", response)
/*
response:
&{true Success [{DEV-T14302154789W4DPV INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154789W4DPV [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715263201 1715349367 <nil>} {DEV-T14302154790HPMWS INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154790HPMWS [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715263347 1715349514 <nil>} {DEV-T14302154794FZ2ZT INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154794FZ2ZT [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715265393 1715351557 <nil>} {DEV-T14302154796GC64X INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154796GC64X [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715266465 1715352865 <nil>} {DEV-T14302154833B5XYD INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154833B5XYD [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715333695 1715420094 <nil>} {DEV-T14302154834TY1ML INV345675 QRIS_SHOPEEPAY QRIS Custom by ShopeePay Farda Ayu Nurfatika fardaayu@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 1100 0 1100 48900 0 <nil> https://tripay.co.id/checkout/DEV-T14302154834TY1ML [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715339528 1715343068 <nil>}] {asc {1 6} 1 <nil> <nil> 1 50 6}}
*/
}

func Example_merchant_transactions_with_param() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}
merchanTransactionParam := client.MerchantTransactionsParam{
Page: 1,
PerPage: 10,
Sort: "asc", // asc or desc
}

response, err := c.MerchantTransactions(merchanTransactionParam)
if err != nil {
panic(err)
}

fmt.Printf("response: %v\n", response)
/*
response:
&{true Success [{DEV-T14302154789W4DPV INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154789W4DPV [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715263201 1715349367 <nil>} {DEV-T14302154790HPMWS INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154790HPMWS [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715263347 1715349514 <nil>} {DEV-T14302154794FZ2ZT INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154794FZ2ZT [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715265393 1715351557 <nil>} {DEV-T14302154796GC64X INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154796GC64X [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715266465 1715352865 <nil>} {DEV-T14302154833B5XYD INV345675 BCAVA BCA Virtual Account John Doe johndoe@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 5500 0 5500 44500 0 <nil> https://tripay.co.id/checkout/DEV-T14302154833B5XYD [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715333695 1715420094 <nil>} {DEV-T14302154834TY1ML INV345675 QRIS_SHOPEEPAY QRIS Custom by ShopeePay Farda Ayu Nurfatika fardaayu@gmail.com <nil> <nil> https://thisisreturnurl.com/redirect 50000 1100 0 1100 48900 0 <nil> https://tripay.co.id/checkout/DEV-T14302154834TY1ML [{Produk1 nama produk 1 50000 1 50000}] UNPAID <nil> 1715339528 1715343068 <nil>}] {asc {1 6} 1 <nil> <nil> 1 10 6}}
*/
}
16 changes: 8 additions & 8 deletions _examples/open_payment.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"

"fmt"
)

func Example_open_payment_create() {

client := client.Client{
c := client.Client{
MerchantCode: "T14302",
ApiKey: "DEV-ZKIDl5gE3AsCDThj7mWX6yvQ8f42NZWJWlZ7TSzS",
PrivateKey: "J2WTm-93avv-w0PZV-ur1t4-4TCjd",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

client.SetSignature(utils.Signature{
c.SetSignature(utils.Signature{
MerchantCode: "T14302",
Channel: "BCAVA",
MerchanReff: "INV345675",
Expand All @@ -26,10 +26,10 @@ func Example_open_payment_create() {
Method: "BCAVA",
MerchatReff: "INV345675",
CustomerName: "Fulan Fulan",
Signature: client.GetSignature(),
Signature: c.GetSignature(),
}

responseOk, responseBad := client.OpenPaymentTransaction(payment)
responseOk, responseBad := c.OpenPaymentTransaction(payment)
if responseBad != nil {
fmt.Errorf("ERROR: %v", responseBad)
}
Expand Down
30 changes: 30 additions & 0 deletions _examples/payment_instructions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package examples

import (
"fmt"

"github.com/zakirkun/go-tripay/client"
"github.com/zakirkun/go-tripay/utils"
)

func Example_payment_instructions() {
c := client.Client{
MerchantCode: "T14302",
ApiKey: "your_api_key_here",
PrivateKey: "your_private_key_here",
Mode: utils.MODE_DEVELOPMENT,
}

ip := client.InstructionRequestParam{
ChannelCode: utils.CHANNEL_BRIVA,
PayCode: "",
Amount: "10000",
AllowHtml: "",
}

response, err := c.Instruction(ip)
if err != nil {
panic(err)
}
fmt.Printf("response: %v\n", response)
}
Loading

0 comments on commit 8509ffc

Please sign in to comment.