|
| 1 | +# GO SDK for ZoodPay API |
| 2 | + |
| 3 | +[](LICENSE.md) |
| 4 | + |
| 5 | +### ZoodPay API |
| 6 | + |
| 7 | +ZoodPay wants to provide its payment solution to every online business who may be interested in it. ZoodPay API v0 is |
| 8 | +the latest version which offers our latest features. |
| 9 | + |
| 10 | +[ZoodPay API Documentation](https://apidocs.zoodpay.com/) |
| 11 | + |
| 12 | +[ZoodPay API API Simulator](https://apidocs.zoodpay.com/docs) |
| 13 | + |
| 14 | +zoodpay-api-sdk is a Go SDK library for accessing [ZoodPay API][]. |
| 15 | + |
| 16 | +Currently, zoodpay-api-sdk requires Go version 1.13 or greater. |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +zoodpay-api-sdk is compatible with modern Go releases in module mode, with Go installed: |
| 21 | + |
| 22 | +```bash |
| 23 | +$ go get github.com/orientswiss/zoodpay-api-go-sdk |
| 24 | +``` |
| 25 | + |
| 26 | +Alternatively the same can be achieved if you use import in a package: |
| 27 | + |
| 28 | +```go |
| 29 | +import "github.com/orientswiss/zoodpay-api-go-sdk" |
| 30 | +``` |
| 31 | + |
| 32 | +## Usage |
| 33 | +The application configuration is represented in `./config/config.go`. When the package imported before execution of each request, |
| 34 | +it loads the configuration from a configuration file. The path to the configuration |
| 35 | +file is specified via the `-config` command line argument which defaults to `config.yml`. (Copy config.yml.sample to config.yml and fill with necessary information) |
| 36 | + |
| 37 | + |
| 38 | +```go |
| 39 | +import "github.com/orientswiss/zoodpay-api-go-sdk/requests" // with go modules disabled |
| 40 | + |
| 41 | +func main() { |
| 42 | + |
| 43 | +//Init Merchant |
| 44 | +merchant = requests.NewClient() |
| 45 | + |
| 46 | +//Health-check Endpoint |
| 47 | +healthCheckResponse, err := merchant.Healthcheck() |
| 48 | + |
| 49 | +//Configuration Endpoint |
| 50 | +configurationsResponse, err := merchant.GetConfiguration(requests.ConfigurationRequest{ |
| 51 | +MarketCode: merchant.MarketCode, |
| 52 | +}) |
| 53 | + |
| 54 | +configurations := configurationsResponse.Configurations |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +//Order Type |
| 59 | +or := requests.OrderRequest{ |
| 60 | + |
| 61 | + ServiceCode: "", |
| 62 | + Amount: 0, |
| 63 | + MarketCode: "", |
| 64 | + Currency: "", |
| 65 | + MerchantReferenceNo: "", |
| 66 | + DiscountAmount: 0, |
| 67 | + ShippingAmount: 0, |
| 68 | + TaxAmount: 0, |
| 69 | + Language: "", |
| 70 | + Signature: "", |
| 71 | + |
| 72 | +} |
| 73 | +//Create Signature for Transaction |
| 74 | +or.Signature = merchant.GenerateSignatureCreateTransaction(or) |
| 75 | +//Transaction Endpoint |
| 76 | +transaction, err := merchant.CreateTransaction(requests.TransactionRequest{ |
| 77 | + //Customer Type |
| 78 | + Customer: requests.CustomerRequest{ |
| 79 | + FirstName: "", |
| 80 | + LastName: "", |
| 81 | + CustomerEmail: "", |
| 82 | + CustomerPhone: "", |
| 83 | + CustomerDOB: "", |
| 84 | + CustomerPID: 0, |
| 85 | +}, |
| 86 | + //Billing Type |
| 87 | + Billing: requests.ContactRequest{ |
| 88 | + Name: "", |
| 89 | + AddressLine1: "", |
| 90 | + AddressLine2: "", |
| 91 | + City: "", |
| 92 | + State: "", |
| 93 | + Zipcode: "", |
| 94 | + CountryCode: "", |
| 95 | + PhoneNumber: "", |
| 96 | +}, |
| 97 | + //Shipping |
| 98 | + Shipping: requests.ContactRequest{ |
| 99 | + Name: "", |
| 100 | + AddressLine1: "", |
| 101 | + AddressLine2: "", |
| 102 | + City: "", |
| 103 | + State: "", |
| 104 | + Zipcode: "", |
| 105 | + CountryCode: "", |
| 106 | + PhoneNumber: "", |
| 107 | +}, |
| 108 | + // ShippingService Type |
| 109 | + ShippingService: requests.ShippingServiceRequest{{ |
| 110 | + Name: "", |
| 111 | + ShippedAt: "", |
| 112 | + Tracking: "", |
| 113 | + Priority: "", |
| 114 | +}, |
| 115 | + //Items Type |
| 116 | + Items: []requests.ItemRequest{ |
| 117 | + { |
| 118 | + Name: "", |
| 119 | + Sku: "", |
| 120 | + Price: 0, |
| 121 | + Quantity: 0, |
| 122 | + DiscountAmount: 0, |
| 123 | + TaxAmount: 0, |
| 124 | + CurrencyCode: "", |
| 125 | + Categories: [][]string{ |
| 126 | + { |
| 127 | + "", |
| 128 | + }, |
| 129 | + }, |
| 130 | + }, |
| 131 | +}, |
| 132 | + Order: or, |
| 133 | +}) |
| 134 | + |
| 135 | + |
| 136 | +//Get transaction Status from API |
| 137 | +transactionStatus, err := merchant.GetTransactionStatus(requests.TransactionStatusRequest{ |
| 138 | +TransactionID: "", |
| 139 | +}) |
| 140 | + |
| 141 | +//Set Delivery Date |
| 142 | +delivery, err := merchant.AddDelivery( |
| 143 | +requests.TransactionStatusRequest{ |
| 144 | +TransactionID: "", |
| 145 | +}, |
| 146 | +requests.DeliveryRequest{ |
| 147 | +DeliveredAt: "", |
| 148 | +FinalCaptureAmount: 0, |
| 149 | +}, |
| 150 | + |
| 151 | +//Create Refund for Paid Transaction |
| 152 | +refund, err := merchant.CreateRefund(requests.RefundRequest{ |
| 153 | +TransactionID: "", |
| 154 | +Amount: 0, |
| 155 | +Reason: "", |
| 156 | +RequestID: "", |
| 157 | +MerchantRefundReference: randomTransRefNo, |
| 158 | +}) |
| 159 | + |
| 160 | +//Get Customer Credit Balance |
| 161 | +balance, err := merchant.GetCreditBalance("") |
| 162 | + |
| 163 | + |
| 164 | +} |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | +``` |
| 169 | +
|
| 170 | +## Changelog |
| 171 | +
|
| 172 | +Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. |
| 173 | +
|
| 174 | +## Contributing |
| 175 | +
|
| 176 | +Please see [CONTRIBUTING](CONTRIBUTING.md) for details. |
| 177 | +
|
| 178 | +## Support |
| 179 | +
|
| 180 | +For any inquiry write to [email protected] with a detailed description of the issue. |
| 181 | +
|
| 182 | +## Credits |
| 183 | +
|
| 184 | +- [ZoodPay](https://github.com/orientswiss) |
| 185 | +
|
| 186 | +## License |
| 187 | +
|
| 188 | +The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
| 189 | +
|
| 190 | +
|
| 191 | +[ZoodPay API]: https://apidocs.zoodpay.com/ |
0 commit comments