-
Notifications
You must be signed in to change notification settings - Fork 1
/
azampay.go
60 lines (53 loc) · 1.89 KB
/
azampay.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package azampay
import (
"github.com/elirehema/azampay/clients"
"github.com/elirehema/azampay/datas"
)
/**
* Checkout and make payment to requested MNO provider
* Ref: https://developerdocs.azampay.co.tz/redoc#tag/Checkout-API/operation/Mno%20Checkout
*/
func MNOCheckout(request datas.CheckoutRequest) datas.ResponseData {
result := datas.TransactionResponse{}
body := request.CreateMnoRequest()
_, err := clients.AzamClient.R().SetResult(&result).SetBody(body).Post("/azampay/mno/checkout")
if err != nil {
return datas.ReturnErrorMessage(err.Error())
}
return &result
}
/**
* Checkout and make payment to requested bank provider
* Ref: https://developerdocs.azampay.co.tz/redoc#tag/Checkout-API/operation/Bank%20Checkout
*/
func BankCheckout(request datas.CheckoutRequest) datas.ResponseData {
result := datas.TransactionResponse{}
body := request.CreateBankRequest()
_, err := clients.AzamClient.R().SetResult(&result).SetBody(body).Post("/azampay/bank/checkout")
if err != nil {
return datas.ReturnErrorMessage(err.Error())
}
return &result
}
/**
* This end point will respond back with the URL of your payments.
* Merchant Application can open this url in a new window to continue with the checkout process of the transaction
* Ref: https://developerdocs.azampay.co.tz/redoc#tag/Checkout-API/operation/Bank%20Checkout
**/
func PostCheckout(request datas.PostCheckoutRequest) string {
result := ""
res, err := clients.AzamClient.R().SetResult(&result).SetBody(request).Post("/Partner/PostCheckout")
if err != nil {
print("STATUS CODE {}:", res.StatusCode(), res.Request.URL)
return ""
}
return result
}
func GetPaymentPartners() []datas.PaymentPartner {
results := []datas.PaymentPartner{}
res, err := clients.AzamClient.R().SetResult(&results).Get("/api/v1/Partner/GetPaymentPartners")
if err != nil {
print("STATUS CODE {}:", res.StatusCode(), res.Request.URL)
}
return results
}