Skip to content

Commit 7785715

Browse files
committed
add license, add more to readme
1 parent b4ec126 commit 7785715

File tree

2 files changed

+177
-1
lines changed

2 files changed

+177
-1
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Ahmed Shaaban
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 156 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,159 @@
66

77
## Description
88

9-
fawry-go is a Go package interfacing with Fawry's payment gateway API
9+
fawry-go is a Go package interfacing with Fawry's payment gateway API. this package is inspired by Amr Bakry's ruby [gem](https://github.com/fawry-api/fawry "fawry-ruby§")
10+
11+
_**`important note`**_: You need to have a contract with fawry to use their service.
12+
13+
## Requirements
14+
15+
Go 1.8 or above.
16+
17+
## Getting Started
18+
19+
### Installation
20+
21+
Run the following command to install the package:
22+
```
23+
go get github.com/ahmedshaaban/fawry-go
24+
```
25+
26+
### Charge Request
27+
28+
```go
29+
package main
30+
31+
import (
32+
"fmt"
33+
"io/ioutil"
34+
35+
"github.com/ahmedshaaban/fawry-go"
36+
)
37+
38+
func main() {
39+
fc := fawry.Client{
40+
IsSandbox: true,
41+
FawrySecureKey: "SecuredKeyProvidedByFawry",
42+
}
43+
44+
charge := fawry.Charge{
45+
MerchantCode: "is0N+YQzlE4=",
46+
MerchantRefNum: "9990064204",
47+
CustomerProfileID: "9990064204",
48+
CustomerMobile: "01000000200",
49+
CustomerEmail: "77@test.com",
50+
PaymentMethod: "PAYATFAWRY",
51+
Amount: "20.10",
52+
CurrencyCode: "EGP",
53+
Description: "the charge request description",
54+
PaymentExpiry: 1516554874077,
55+
ChargeItems: []fawry.ChargeItem{
56+
fawry.ChargeItem{
57+
ItemID: "897fa8e81be26df25db592e81c31c",
58+
Description: "lorem",
59+
Price: "15.20",
60+
Quantity: 1,
61+
},
62+
},
63+
}
64+
65+
resp, err := fc.ChargeRequest(charge)
66+
if err != nil {
67+
fmt.Println(err)
68+
return
69+
}
70+
71+
defer resp.Body.Close()
72+
73+
fmt.Println("response Status:", resp.Status)
74+
fmt.Println("response Headers:", resp.Header)
75+
body, _ := ioutil.ReadAll(resp.Body)
76+
fmt.Println("response Body:", string(body))
77+
}
78+
79+
```
80+
81+
### Refund Request
82+
83+
```go
84+
package main
85+
86+
import (
87+
"fmt"
88+
"io/ioutil"
89+
90+
"github.com/ahmedshaaban/fawry-go"
91+
)
92+
93+
func main() {
94+
fc := fawry.Client{
95+
IsSandbox: true,
96+
FawrySecureKey: "SecuredKeyProvidedByFawry",
97+
}
98+
99+
refund := fawry.Refund{
100+
MerchantCode: "1013969",
101+
ReferenceNumber: "322818",
102+
RefundAmount: "100.00",
103+
Reason: "Bad Quality ",
104+
}
105+
106+
resp, err := fc.RefundRequest(refund)
107+
if err != nil {
108+
fmt.Println(err)
109+
return
110+
}
111+
112+
defer resp.Body.Close()
113+
114+
fmt.Println("response Status:", resp.Status)
115+
fmt.Println("response Headers:", resp.Header)
116+
body, _ := ioutil.ReadAll(resp.Body)
117+
fmt.Println("response Body:", string(body))
118+
}
119+
120+
```
121+
122+
### Status Request
123+
124+
```go
125+
package main
126+
127+
import (
128+
"fmt"
129+
"io/ioutil"
130+
131+
"github.com/ahmedshaaban/fawry-go"
132+
)
133+
134+
func main() {
135+
fc := fawry.Client{
136+
IsSandbox: true,
137+
FawrySecureKey: "SecuredKeyProvidedByFawry",
138+
}
139+
140+
status := fawry.Status{
141+
MerchantCode: "is0N+YQzlE4=",
142+
MerchantRefNum: "99900642041",
143+
}
144+
145+
resp, err := fc.StatusRequest(refund)
146+
if err != nil {
147+
fmt.Println(err)
148+
return
149+
}
150+
151+
defer resp.Body.Close()
152+
153+
fmt.Println("response Status:", resp.Status)
154+
fmt.Println("response Headers:", resp.Header)
155+
body, _ := ioutil.ReadAll(resp.Body)
156+
fmt.Println("response Body:", string(body))
157+
}
158+
159+
```
160+
161+
## TODO:
162+
- Read configuration keys (merchant code, secure key) from env vars
163+
- Add public API documentation to README
164+
- Increase code coverage

0 commit comments

Comments
 (0)