Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


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

devtools::install_url(url="", 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

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

  • Don't upload .Rhistory or .RData files to github public repos
  • If you're building a Shiny app, you could save them in .rda files and read from them. This could be done locally or internationally(lol), I mean on a secure server but you'll most likely have to do that manually.
set_keys("pk_test_pub1ickey", "")$public %>% saveRDS(file = "path_to_file")
  • 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

_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
  • ... are for you to pass in any other body parameters you might want to use, however, required parameters must be passed in so as to avoid "status": false

eg of how to enter them is

_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.

  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

Would you like to contribute?

  • Fork the project & clone locally.
  • Create an upstream remote and sync your local copy before you branch.
  • Branch for each separate piece of work.
  • Do the work, write good commit messages, and send me a mail at (would be nice if you mail me first)
  • Push to your origin repository.
  • Create a new PR in GitHub.

You could read details on this post at


Reference :

Managing Secrets :

Keyring :


Wrapper functions for the Paystack API






No releases published


No packages published