Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Readme.md

Grails Paystack Plugin

A Grails plugin to allow communication to paystack API

Installation

Add the below line to your build.gradle file

compile 'org.grails.plugins:paystack-grails:1.0.5'

Configuration

Include Paystack keys(in application.yml) gotten from your dashboard as follows
paystack: 
    liveSecretKey: '${PAYSTACK_LIVE_SECRET_KEY}'
    testSecretKey: '${PAYSTACK_TEST_SECRET_KEY}'
    livePublicKey: '${PAYSTACK_LIVE_PUBLIC_KEY}'
    testPublicKey: '${PAYSTACK_TEST_PUBLIC_KEY}'
    endpoint:      'https://api.paystack.co'

Usage

  • Make Payment Request
  • params
    • email (required)
    • amount (required)
    • plan
    • first_name
    • last_name
    • metadata
    • callback_url
class TestController {

    PaystackService paystackService

    def index() { }

    def makePaymentRequest(){
        String authUrl =  paystackService.getAuthUrl(params)
        redirect(url:authUrl)
    }
  }
  • Handle Paystack callback
  • params(paystack calls ur method with a reference parameter)
    def handlePaystackCallback(){
       final String reference = params.get('reference') // reference from paystack webhook
        Map<String, String> paymentDetails =  paystackService.getPaymentData(reference)
         println($paymentDetails)
        // Now you have the payment details,
        // you can store the authorization_code in your db to allow for recurrent subscriptions
        // you can then redirect or do whatever you want
    }
  • Other useful methods that implement Paystack endpoints can be found below
  • NB: Methods not listed below can be found in the PaystackService Class
    // Injecting PaystackService 
    PaystackService paystackService
    
    /**
     * Return all customers on your Paystack account
     * @returns Map
     */
    paystackService.getAllCustomers()
    
     /**
     * Return all transactions on Your Paystack account
     * @returns Map
     */
    paystackService.listTransactions()

     /**
     * Fetch a particular transaction
     * @param  int id : identifier of transaction to fetch
     * @return Map
     */
    paystackService.fetchTransaction(id)
    
    /**
     * Return a single customer given its id
     * @param customerId
     * @return Map
     */
    paystackService.fetchCustomer(customerId)
    
    /**
     * Return all plans on your paystack account
     * @return Map
     */
    paystackService.getAllPlans()
        
    /**
     * Get a particular plan given the plan id
     * @param planId
     * @return Map
     */
    paystackService.fetchPlan(planId)
    

TODO

  • Complete All Api calls
  • Write Unit tests

CONTRIBUTING

  • Fork the repository, make necessary changes and send the PR.

About

Paystack Payment API Implementation in Groovy/Grails

Topics

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.