Giter Club home page Giter Club logo

instamojo-php's Introduction

Instamojo PHP API

Assists you to programmatically create, edit and delete Links on Instamojo in PHP.

Usage

Create a Link

<?php
require "instamojo.php";

$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]');

try {
    $response = $api->linkCreate(array(
        'title'=>'Hello API',
        'description'=>'Create a new Link easily',
        'base_price'=>100,
        'cover_image'=>'/path/to/photo.jpg'
        ));
    print_r($response);
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}
?>

This will give you JSON object containing details of the Link that was just created.

Edit a Link

<?php
require "instamojo.php";

$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]');

try {
    $response = $api->linkEdit(
        'hello-api', // You must specify the slug of the Link
        array(
        'title'=>'A New Title',
        ));
    print_r($response);
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}
?>

List all Links

<?php
require "instamojo.php";

$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]');

try {
    $response = $api->linksList();
    print_r($response);
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}
?>

List all Payments

<?php
require "instamojo.php";

$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]');

try {
    $response = $api->paymentsList();
    print_r($response);
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}
?>

Get Details of a Payment using Payment ID

<?php
require "instamojo.php";

$api = new Instamojo('[API_KEY]', '[AUTH_TOKEN]');

try {
    $response = $api->paymentDetail('[PAYMENT ID]');
    print_r($response);
}
catch (Exception $e) {
    print('Error: ' . $e->getMessage());
}
?>

Available Functions

You have these functions to interact with the API:

  • linksList() List all Links created by authenticated User.
  • linkDetail($slug) Get details of Link specified by its unique slug.
  • linkCreate(array $link) Create a new Link.
  • linkEdit($slug, array $link) Edit an existing Link.
  • linkDelete($slug) Archvive a Link - Archived Links cannot be generally accessed by the API. User can still view them on the Dashboard at instamojo.com.
  • paymentsList() List all Payments linked to User's account.
  • paymentDetail($payment_id) Get details of a Payment specified by its unique Payment ID. You may receive the Payment ID via paymentsList() or via URL Redirect function or as a part of Webhook data.

Link Creation Parameters

Required

  • title - Title of the Link, be concise.
  • description - Describe what your customers will get, you can add terms and conditions and any other relevant information here. Markdown is supported, popular media URLs like Youtube, Flickr are auto-embedded.
  • base_price - Price of the Link. This may be 0, if you want to offer it for free.

File and Cover Image

  • file_upload - Full path to the file you want to sell. This file will be available only after successful payment.
  • cover_image - Full path to the IMAGE you want to upload as a cover image.

Quantity

  • quantity - Set to 0 for unlimited sales. If you set it to say 10, a total of 10 sales will be allowed after which the Link will be made unavailable.

Post Purchase Note

  • note - A post-purchase note, will only displayed after successful payment. Will also be included in the ticket/ receipt that is sent as attachment to the email sent to buyer. This will not be shown if the payment fails.

Event

  • start_date - Date-time when the event is beginning. Format: YYYY-MM-DD HH:mm
  • end_date - Date-time when the event is ending. Format: YYYY-MM-DD HH:mm
  • venue - Address of the place where the event will be held.
  • timezone - Timezone of the venue. Example: Asia/Kolkata

Redirects and Webhooks

  • redirect_url - This can be a Thank-You page on your website. Buyers will be redirected to this page after successful payment.
  • webhook_url - Set this to a URL that can accept POST requests made by Instamojo server after successful payment.
  • enable_pwyw - set this to True, if you want to enable Pay What You Want. Default is False.
  • enable_sign - set this to True, if you want to enable Link Signing. Default is False. For more information regarding this, and to avail this feature write to support at instamojo.com.



Further documentation is available at https://www.instamojo.com/developers/

instamojo-php's People

Contributors

ashwch avatar chaudhariamolsopan avatar hiway avatar rishimukherjee avatar saich avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.