ebinabo
21/02/2019
To install this package run
devtools::install_github("ebinabo/paystack")
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, took me some time to figure that out
set_keys("", "sk_test_s3cr3tk3y")$secret # is equivalent to -H "Authorization: Bearer SECRET_KEY"
<request>
Headers:
* Authorization: Bearer sk_test_s3cr3tk3y
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
set_keys("pk_test_pub1ickey", "")$public %>% saveRDS(file = "path_to_file")
The banks that currently support the pay with bank feature and their codes are shown on the right.
Access dataframe by running:
paystack::pay_with_banks
name | code |
---|---|
Access Bank | 044 |
ALAT by WEMA | 035A |
Fidelity Bank | 070 |
First City Monument Bank | 214 |
Guaranty Trust Bank | 058 |
Sterling Bank | 232 |
Union Bank of Nigeria | 032 |
Unity Bank | 215 |
Zenith Bank | 057 |
_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
[1] "https://api.paystack.co/transaction/19822"
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.
list(email = "customer@email.com", amount = 500000)
Reference : https://developers.paystack.co/v1.0/reference
Pay with Bank : https://developers.paystack.co/docs/pay-with-bank
Managing Secrets : https://httr.r-lib.org/articles/secrets.html
Keyring : https://github.com/r-lib/keyring