├── README.md
├── database
└── transaction.sql
├── index.php
├── instamojo
├── Instamojo.php
└── cacert.pem
├── pay.php
└── thankyou.php
/README.md:
--------------------------------------------------------------------------------
1 | # Payment-Gateway-Using-PHP
2 | Instamozo -PaymentGateway-PHP (PHP , Bootstrap 4+ , Css , HTML-5 , Jquery)
3 |
4 | >First you create an account on Instamojo https://test.instamojo.com/
5 |
6 |
7 | >All Details for Testing Purpose Only !
8 | >Select -> Card Payment type
9 |
10 | ``` text
11 | Debit = 4242 4242 4242 4242
12 | Expiry =1221
13 | cvv = 111
14 | security pin = 1221
15 | ```
16 |
17 | Assists you to programmatically create, edit and delete Links on Instamojo in PHP
18 | 
19 | 
20 | 
21 | 
22 | 
23 | 
24 |
25 | 
26 |
27 |
28 | .
29 |
30 | Note: If you're using this wrapper with our sandbox environment https://test.instamojo.com/ then you should pass 'https://test.instamojo.com/api/1.1/' as third argument to the Instamojo class while initializing it. API key and Auth token for the same can be obtained from https://test.instamojo.com/developers/ (Details: Test Or Sandbox Account).
31 |
32 | >$api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN, 'https://test.instamojo.com/api/1.1/');
33 |
34 |
35 | Installing via Composer
36 | $ php composer.phar require instamojo/instamojo-php
37 | Note: If you're not using Composer then directly include the contents of src directory in your project.
38 |
39 | >Usage
40 | ```php
41 | $api = new Instamojo\Instamojo(API_KEY, AUTH_TOKEN);
42 | Create a new Payment Request
43 | try {
44 | $response = $api->paymentRequestCreate(array(
45 | "purpose" => "FIFA 16",
46 | "amount" => "3499",
47 | "send_email" => true,
48 | "email" => "foo@example.com",
49 | "redirect_url" => "http://www.example.com/handle_redirect.php"
50 | ));
51 | print_r($response);
52 | }
53 | catch (Exception $e) {
54 | print('Error: ' . $e->getMessage());
55 | }
56 | ```
57 | This will give you JSON object containing details of the Payment Request that was just created.
58 |
59 | Get the status or details of a Payment Request
60 | ```php
61 | try {
62 | $response = $api->paymentRequestStatus(['PAYMENT REQUEST ID']);
63 | print_r($response);
64 | }
65 | catch (Exception $e) {
66 | print('Error: ' . $e->getMessage());
67 | }
68 | ```
69 | This will give you JSON object containing details of the Payment Request and the payments related to it. Key for payments is 'payments'.
70 |
71 | Here ['PAYMENT REQUEST ID'] is the value of 'id' key returned by the paymentRequestCreate() query.
72 |
73 | >Get the status of a Payment related to a Payment Request
74 | ```php
75 | try {
76 | $response = $api->paymentRequestPaymentStatus(['PAYMENT REQUEST ID'], ['PAYMENT ID']);
77 | print_r($response['purpose']); // print purpose of payment request
78 | print_r($response['payment']['status']); // print status of payment
79 | }
80 | catch (Exception $e) {
81 | print('Error: ' . $e->getMessage());
82 | }
83 | ```
84 |
85 | This will give you JSON object containing details of the Payment Request and the payments related to it. Key for payments is 'payments'.
86 |
87 | Here ['PAYMENT REQUEST ID'] is the value of 'id' key returned by the paymentRequestCreate() query and ['PAYMENT ID'] is the Payment ID received with redirection URL or webhook.
88 |
89 | >Get a list of Payment Requests
90 | ```php
91 | try {
92 | $response = $api->paymentRequestsList();
93 | print_r($response);
94 | }
95 | catch (Exception $e) {
96 | print('Error: ' . $e->getMessage());
97 | }
98 | ```
99 |
100 | This will give you an array containing Payment Requests created so far. Note that the payments related to individual Payment Request are not returned with this query.
101 |
102 | paymentRequestsList() also accepts optional parameters for pagination as well as filtering based on created_at and updated_at fields.
103 |
104 | paymentRequestsList($limit=null, $page=null, $max_created_at=null, $min_created_at=null, $max_modified_at=null, $min_modified_at=null)
105 | For example:
106 |
107 | $response = $api->paymentRequestsList(50, 1, "2015-11-19T10:12:19Z", "2015-10-29T12:51:36Z");
108 | For details related to supported datetime format check the documentation: https://www.instamojo.com/developers/request-a-payment-api/#toc-filtering-payment-requests
109 |
110 | >Available Request a Payment Functions
111 | >You have these functions to interact with the Request a Payment API:
112 |
113 | paymentRequestCreate(array $payment_request) Create a new Payment Request.
114 | paymentRequestStatus($id) Get details of Payment Request specified by its unique id.
115 | paymentRequestsList(array $datetime_limits) Get a list of all Payment Requests. The $datetime_limits argument is optional an can be used to filter Payment Requests by their creation and modification date.
116 | Payment Request Creation Parameters
117 | Required
118 | purpose: Purpose of the payment request. (max-characters: 30)
119 | amount: Amount requested (min-value: 9 ; max-value: 200000)
120 | Optional
121 | buyer_name: Name of the payer. (max-characters: 100)
122 | email: Email of the payer. (max-characters: 75)
123 | phone: Phone number of the payer.
124 | send_email: Set this to true if you want to send email to the payer if email is specified. If email is not specified then an error is raised. (default value: false)
125 | send_sms: Set this to true if you want to send SMS to the payer if phone is specified. If phone is not specified then an error is raised. (default value: false)
126 | redirect_url: set this to a thank-you page on your site. Buyers will be redirected here after successful payment.
127 | webhook: set this to a URL that can accept POST requests made by Instamojo server after successful payment.
128 | allow_repeated_payments: To disallow multiple successful payments on a Payment Request pass false for this field. If this is set to false then the link is not accessible publicly after first successful payment, though you can still access it using API(default value: true).
129 |
130 | >Further documentation is available at https://docs.instamojo.com/v1.1/docs
131 |
--------------------------------------------------------------------------------
/database/transaction.sql:
--------------------------------------------------------------------------------
1 | -- phpMyAdmin SQL Dump
2 | -- version 4.8.5
3 | -- https://www.phpmyadmin.net/
4 | --
5 | -- Host: 127.0.0.1
6 | -- Generation Time: Apr 15, 2020 at 07:43 PM
7 | -- Server version: 10.1.38-MariaDB
8 | -- PHP Version: 7.3.3
9 |
10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11 | SET AUTOCOMMIT = 0;
12 | START TRANSACTION;
13 | SET time_zone = "+00:00";
14 |
15 |
16 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
17 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
18 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
19 | /*!40101 SET NAMES utf8mb4 */;
20 |
21 | --
22 | -- Database: `payment`
23 | --
24 |
25 | -- --------------------------------------------------------
26 |
27 | --
28 | -- Table structure for table `transaction`
29 | --
30 |
31 | CREATE TABLE `transaction` (
32 | `id` int(11) NOT NULL,
33 | `name` varchar(255) NOT NULL,
34 | `email` varchar(255) NOT NULL,
35 | `phone` varchar(10) NOT NULL,
36 | `amount` int(255) DEFAULT NULL,
37 | `pay_to` varchar(255) NOT NULL,
38 | `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
39 | ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
40 |
41 | --
42 | -- Dumping data for table `transaction`
43 | --
44 |
45 | INSERT INTO `transaction` (`id`, `name`, `email`, `phone`, `amount`, `pay_to`, `created_at`) VALUES
46 | (1, 'SHUBHAM SINGH', 'priyadrashansingh@gmail.com', '8400840468', 100, 'Modi Care Releaf fund.', '2020-04-15 06:42:12'),
47 | (2, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 100, 'Modi Care Releaf fund.', '2020-04-15 06:42:16'),
48 | (3, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 100, 'Modi Care Releaf fund.', '2020-04-15 06:45:00'),
49 | (4, 'Prateek Pandey', 'prateekpandey736@gmail.com', '8687767493', 101, 'Modi Care Releaf fund.', '2020-04-15 07:42:15'),
50 | (5, 'Manpreet Singh', 'manpreetsinghmakhija@gmail.com', '7014913728', 500, 'Modi Care Releaf fund.', '2020-04-15 07:44:55'),
51 | (6, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 990, 'Modi Care Releaf fund.', '2020-04-15 14:05:48'),
52 | (7, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 4950, 'Modi Care Releaf fund.', '2020-04-15 14:08:47'),
53 | (8, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 9900, 'Modi Care Releaf fund.', '2020-04-15 14:18:52'),
54 | (9, 'KISHAN MAURYA', 'fullstack49kishan@gmail.com', '9598608579', 1485, 'Modi Care Releaf fund.', '2020-04-15 14:22:03'),
55 | (10, 'Devesh Pandey', 'deveshpandeyy007@gmail.com', '7398683627', 990, 'Modi Care Releaf fund.', '2020-04-15 14:33:46');
56 |
57 | --
58 | -- Indexes for dumped tables
59 | --
60 |
61 | --
62 | -- Indexes for table `transaction`
63 | --
64 | ALTER TABLE `transaction`
65 | ADD PRIMARY KEY (`id`);
66 |
67 | --
68 | -- AUTO_INCREMENT for dumped tables
69 | --
70 |
71 | --
72 | -- AUTO_INCREMENT for table `transaction`
73 | --
74 | ALTER TABLE `transaction`
75 | MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=11;
76 | COMMIT;
77 |
78 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
79 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
80 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
81 |
--------------------------------------------------------------------------------
/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |