Wrapper functions for the Paystack API. A more thorough documentation would be constantly updated here where you'll be able to see the expected outputs.
Help pages, containing the functions and the params they receieve can be found here
To install this package run ```{r eval=FALSE} devtools::install_url(url="https://github.com/ebinabo/paystack/archive/master.zip", INSTALL_opt= "--no-multiarch")
I understand newer versions of RStudio don't handle downloading from github properly so I've included a manual_installation script as well.
All the lines are commented by default so Ctrl + A, Ctrl + C, Ctrl + Enter. After it's done, delete that script and go to tabs -> Build -> Install and Restart
Please unzip the file to your downloads or anywhere but the reserved folder in ~Documents/R/win-lib/version folder
Set Keys
=========================================================
```{r}
set_keys("", "sk_test_s3cr3tk3y")$secret
equivalent to -H "Authorization: Bearer SECRET_KEY"
Notice how the commented line has an empty chr string and $
to subset the secret key. The first arg is the public key and could be accessed by filling the first arg and subset by replacing secret with public.
Please keep your keys secure
- Using the keyring package, you could read and write your keys to a secure location on your computer and still lock them with passwords, cool right?
General Function Structure
========================================================
```{r eval=FALSE}
_function_name(authorization, path_param, ...)
The general function structure is shown above,
most of the functions require authorization which is the result of running set_keys() from the previous slides
path_param is any string that should be concatenated with the root api
paste(urls$transaction$base, "19822", sep = "/") # to request a transaction with id 19822
eg of how to enter them is
```{r eval=FALSE} _function_name(authorization, path_param, reference = "28374", amount = 500000)
for as many query parameters you might want to include.
if you would need a nested json file returned, just wrap the inner details in a list.
```{r eval=FALSE}
list(
a = "this",
b = "that",
c = data.frame(
these = c("first", "second", NA),
those = c("third", "fourth", "fifth"),
stringsAsFactors = F
)
) %>% jsonlite::toJSON(pretty = T)
would return
{
"a": ["this"],
"b": ["that"],
"c": [
{
"these": "first",
"those": "third"
},
{
"these": "second",
"those": "fourth"
},
{
"those": "fifth"
}
]
}
This would be useful in cases where you might want to include metadata = list(...)
as an arg to any of the functions,
you might not need to include %>% jsonlite::toJSON(pretty = T)
as the functions should parse the list to the same structure
for c, which is a data.frame, each row is stored as an array of objects i.e the n-th element of each column, these and those
are wrapped in curly braces {"these":"first","those":"third"}
and a situation where a value is Not Available(NA
), include it where appropriate to get a situation where {"those":"fifth"}
and nothing is assinged to these
You could read details on this post at https://akrabat.com/the-beginners-guide-to-contributing-to-a-github-project/
Reference : https://developers.paystack.co/v1.0/reference
Managing Secrets : https://httr.r-lib.org/articles/secrets.html
Keyring : https://github.com/r-lib/keyring
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.