Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

A Python library to consume the RavePay API

Project description

Build Status Scrutinizer Code Quality Coverage Status

The RavePay Python SDK provides APIs to create, process and manage payments on the RavePay platform. The SDK fully supports the API

Installation

pip install ravepaypysdk

Configuring RavePay SDK

import ravepaypysdk

my_api = ravepaypysdk.Api(
          secret_key='ravepay_secret_key'
          public_key='ravepay_public_key'
          production=False # sandbox # or True # Live
        )

Usage

To start using the SDK ensure you have your public key and secret key instantiated with the Api object

Payments (RavePay Direct Charge)

Import the RavePay Payment module

from ravepaypysdk import Payment

There are 5 different ways to utilize RavePay’s direct charge for payment:

  • Card direct charge

    Usage

     payload = {
       “cardno”: “5438898014560229”,
       “cvv”: “789”,
       “expirymonth”: “07”,
       “expiryyear”: “18”,
       “currency”: “NGN”,
       “pin”:“7552”,
       “country”: “GH”,
       “amount”: “10”,
       “email”: “user@example.com”,
       “phonenumber”: “1234555”,
       “suggested_auth”: “PIN”,
       “firstname”:“user1”,
       “lastname”: “user2”, “IP”: “355426087298442”, “txRef”:
       “MC-7663-YU”, “device_fingerprint”:
       “69e6b7f0b72037aa8428b70fbe03986c”
     }
    card_payment = Payment.card(payload, api=my_api)
    
    if card_payment:
       return card_payment
    
  • Bank account payment

    Usage

    payload = {
      "accountnumber": "0690000004",
      "accountbank": "044",
      "currency": "NGN",
      "country": "NG",
      "amount": "10",
      "email": "user@example.com",
      "phonenumber": "1234555",
      "firstname": "first name",
      "lastname": "last name",
      "IP": "355426087298442",
      "txRef": "",
      "device_fingerprint": "69e6b7f0b72037aa8428b70fbe03986c"
    }
    bank_payment = Payment.bank_account(payload, api=my_api)
    
    if bank_payment:
       return bank_payment
    
  • Tokenize Card

    Usage

    payload = {
      "token":{
          “chargeToken”:{
               “user_token”:“f0209”,
               “embed_token”:“flw-t0-9f3aa69a806f6440fbb78cc9e8b2f135-k3n”
           }
      },
      "currency": "NGN",
      "country": "NG",
      "amount": "10",
      "email": "user@example.com",
      "phonenumber": "1234555",
      "firstname": "user1",
      "lastname": "user2",
      "IP": "355426087298442",
      "txRef": "MC-7663-YU",
      "narration":"tokenize my card"
      "meta": [{"metaname": "flightId"}, {"metavalue": "1002"}]
      "device_fingerprint": "69e6b7f0b72037aa8428b70fbe03986c"
    }
    
    tokenize_card = Payment.tokenize_card(payload, api=my_api)
    
  • USSD Payment

    Usage

    ussd_payment = Payment.ussd(payload, api=my_api)
    
  • MPESA Payment

    Usage

    mpesa_payment = Payment.mpesa(payload, api=my_api)
    
  • Ghana Mobile Money

    Usage

    gh_mobile_payment = Payment.ghana_mobile(payload, api=my_api)
    
  • The same payload format goes for the USSD, MPESA and Ghana Mobile Money. Kindly review the API documentation to get the required field for each transaction

Transaction

This module retrieves all transactions and verifies transactions.

Usage

Import the transaction module

from ravepaypysdk import Transaction
  • Verify your transaction

    Usage

     payload = {
      “flw_ref”:“FLW-MOCK-6f52518a2ecca2b6b090f9593eb390ce”, # unique reference
      “tx_ref”:“dummy”, # merchants unique reference number
      “normalize”: “1”
    }
    verify_transaction = Transaction.verify(payload, api=my_api)
    
  • verify transaction with xquery

Usage

 payload = {
   “flwref”: “FLW-MOCK-6f52518a2ecca2b6b090f9593eb390ce”, # unique reference
   “txref”:“dummy”, # merchants unique reference number
   “last_attempt”:“1”, # retrieves the last transaction
   “only_successful”: “1” # retrieves only successful transaction
 }
xquery_verify = Transaction.verify_query(payload, api=my_api)
  • List all recurring transactions

    Usage

    list_transactions  = Transaction.list_all_recurring(api=my_api)
    
  • List single recurring transactions

    Usage

    payload = {
        "txId":"dummy" #add the required value for txId
    }
    list_single_transaction = Transaction.list_single_recurring(payload, api=my_api)
    

PreAuthorization

This module performs preauthorization transactions on the RavePay platform

Usage

Import the PreAuthorization module

from ravepaypysdk import PreAuthorization -

Preauthorization Capture

*Usage*
::
  payload = {
      "flwRef":"39448fhdhhfdhshshf" # add the required value
  }
  preauthorize_capture = PreAuthorization.capture(payload, api=my_api)
  • Preauthorize Card transaction

    Usage

    Payload is the same as direct charge card payment payload
    
    preauthorize_card = PreAuthorization.card(payload, api=my_api)
    
  • Preauthorize void or refund transactions

    Usage

    payload = {
        "flwRef":"dummy" # add the value from the capture response
        "action": "refund or void" # select what action i.e refund or void
    }
    preauth_void_refund = PreAuthorization.void_or_refund(payload, api=my_api)
    

Validate Ravepay charges

This module validates RavePay payment transactions.

Usage

Import the ValidateCharge module

from ravepaypysdk import ValidateCharge
payload = {
     "transaction_reference": "222334304",
     "otp": "12345"
 }
  • Validate card transactions

    Usage

    validate_card_transac = ValidateCharge.card(payload, api=my_api)
    
  • Validate bank account transaction

    Usage

    validate_bank_account_transac = ValidateCharge.account(payload, api=my_api)
    

Subscriptions

This module retrieves, cancels and activates subscriptions on the RavePay Platform

Usage

Import the subscriptions module

from ravepaypysdk import Subscriptions
  • Activate Subscription

    Usage

    #sub_id is the subscription id
    activate_subscription = Subscriptions.activate(sub_id=50, api=my_api)
    
  • Cancel Subscription

    Usage

    #sub_id is the subscription id
    cancel_subscription = Subscriptions.cancel(sub_id=50, api=my_api)
    
  • Fetch Single Subscription

    Usage

     #params is the subscription id
    single_subscription = Subscriptions.fetch_single(params=70, api=my_api)
    
  • Fetch All Subscriptions

    Usage

    all_subscriptions = Subscriptions.fetch_all(api=my_api)
    

Payment Plan

This module creates, retrieves, edit and cancel payment plans on the platform

Usage

Import the Payment plan module

from ravepaypysdk import PaymentPlan

#plan_id is the payment plan identifier
  • Create Payment Plan

    Usage

    payload = {
      "amount": 3000,
      "name": 'New User',
      "intervals": "daily",
      "duration": 0
    }
    create_plan = PaymentPlan.create(payload, api=my_api)
    
  • Edit Payment Plan

    Usage

    payload = {
      "amount": 1000,
      "name": 'New User',
      "intervals": "monthly",
      "duration": 0
    }
    
    edit_plan = PaymentPlan.edit_plan(payload, plan_id=60, api=my_api)
    
  • Cancel Payment

    Usage

    cancel_plan = PaymentPlan.cancel_plan(plan_id=60, api=my_api)
    
  • Fetch Single Payment Plan

    Usage

    fetch_single_plan = PaymentPlan.fetch_single_plan(params=40, api=my_api)
    
  • Fetch All Payment Plans

    Usage

    fetch_all_plans = PaymentPlan.fetch_all_plan(api=my_api)
    

Miscellanous

This module gets the bank list and current forex rates

Usage

Import the bank module

from ravepaypysdk import Bank
  • Get List of Banks

    Usage

    get_banks = Bank.list_all(api=my_api)
    
  • Get Forex Rates

    Usage

    payload = {
     'origin_currency': 'USD',
     'destination_currency': 'NGN',
     'amount': '200'
     }
    get_forex = Bank.get_forex(payload, api=my_api)
    

Documentation

API documentation for RavePay can be found here

Contributing

Contributions are always welcomed to the project. Use Github Issue for requests.

  • Fork the project to your repository then clone it to your local machine.
  • Create a new branch and make the necessary enhancement to the features.
  • If the you wish to update an existing enhancement submit a pull request.
  • If you are unsure about certain areas in the project feel to ask for assistance.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ravepaypysdk, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size ravepaypysdk-1.0.2-py2-none-any.whl (10.2 kB) File type Wheel Python version py2 Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page