PHP code example of aotearoait / laravel-paytm-wallet
1. Go to this page and download the library: Download aotearoait/laravel-paytm-wallet library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
aotearoait / laravel-paytm-wallet example snippets
'providers' => [
// Other service providers...
Anand\LaravelPaytmWallet\PaytmWalletServiceProvider::class,
],
'aliases' => [
// Other aliases
'PaytmWallet' => Anand\LaravelPaytmWallet\Facades\PaytmWallet::class,
],
namespace App\Http\Controllers;
use PaytmWallet;
class OrderController extends Controller
{
/**
* Redirect the user to the Payment Gateway.
*
* @return Response
*/
public function order()
{
$payment = PaytmWallet::with('receive');
$payment->prepare([
'order' => $order->id,
'user' => $user->id,
'mobile_number' => $user->phonenumber,
'email' => $user->email,
'amount' => $order->amount,
'callback_url' => 'http://example.com/payment/status'
]);
return $payment->receive();
}
/**
* Obtain the payment information.
*
* @return Object
*/
public function paymentCallback()
{
$transaction = PaytmWallet::with('receive');
$response = $transaction->response() // To get raw response as object
//Check out response parameters sent by paytm here -> http://paywithpaytm.com/developer/paytm_api_doc?target=interpreting-response-sent-by-paytm
if($transaction->isSuccessful()){
//Transaction Successful
}else if($transaction->isFailed()){
//Transaction Failed
}else if($transaction->isOpen()){
//Transaction Open/Processing
}
$transaction->getResponseMessage(); //Get Response Message If Available
//get important parameters via public methods
$transaction->getOrderId(); // Get order id
$transaction->getTransactionId(); // Get transaction id
}
}
namespace App\Http\Controllers;
use PaytmWallet;
class OrderController extends Controller
{
/**
* Obtain the transaction status/information.
*
* @return Object
*/
public function statusCheck(){
$status = PaytmWallet::with('status');
$status->prepare(['order' => $order->id]);
$status->check();
$response = $status->response() // To get raw response as object
//Check out response parameters sent by paytm here -> http://paywithpaytm.com/developer/paytm_api_doc?target=txn-status-api-description
if($status->isSuccessful()){
//Transaction Successful
}else if($status->isFailed()){
//Transaction Failed
}else if($status->isOpen()){
//Transaction Open/Processing
}
$status->getResponseMessage(); //Get Response Message If Available
//get important parameters via public methods
$status->getOrderId(); // Get order id
$status->getTransactionId(); // Get transaction id
}
}
namespace App\Http\Controllers;
use PaytmWallet;
class OrderController extends Controller
{
/**
* Initiate refund.
*
* @return Object
*/
public function refund(){
$refund = PaytmWallet::with('refund');
$refund->prepare([
'order' => $order->id,
'reference' => "refund-order-4", // provide refund reference for your future reference (should be unique for each order)
'amount' => 300, // refund amount
'transaction' => $order->transaction_id // provide paytm transaction id referring to this order
]);
$refund->initiate();
$response = $refund->response() // To get raw response as object
if($refund->isSuccessful()){
//Refund Successful
}else if($refund->isFailed()){
//Refund Failed
}else if($refund->isOpen()){
//Refund Open/Processing
}else if($refund->isPending()){
//Refund Pending
}
}
}
namespace App\Http\Controllers;
use PaytmWallet;
class OrderController extends Controller
{
/**
* Initiate refund.
*
* @return Object
*/
public function refund(){
$refundStatus = PaytmWallet::with('refund_status');
$refundStatus->prepare([
'order' => $order->id,
'reference' => "refund-order-4", // provide reference number (the same which you have entered for initiating refund)
]);
$refundStatus->check();
$response = $refundStatus->response() // To get raw response as object
if($refundStatus->isSuccessful()){
//Refund Successful
}else if($refundStatus->isFailed()){
//Refund Failed
}else if($refundStatus->isOpen()){
//Refund Open/Processing
}else if($refundStatus->isPending()){
//Refund Pending
}
}
}
namespace App\Http\Controllers;
use PaytmWallet;
class OrderController extends Controller
{
/**
* Redirect the user to the Payment Gateway.
*
* @return Response
*/
public function order()
{
$payment = PaytmWallet::with('receive');
$payment->prepare([
'order' => $order->id,
'user' => $user->id,
'mobile_number' => $user->phonenumber,
'email' => $user->email,
'amount' => $order->amount,
'callback_url' => 'http://example.com/payment/status'
]);
return $payment->view('your_custom_view')->receive();
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.