Skip to main content

Paypal Payment API

/*******************/
$payment_type = 'Sale';

$amount = $invoice->price + $invoice->due_price + $invoice->service_charge;





$send = 'VERSION=51.0';

$send.= '&USER=' . urlencode('Credit card Username');

$send.= '&PWD=' . urlencode('Credit Card Password');

$send.= '&SIGNATURE=' . urlencode('Credit Card Signature');

$send.= '&METHOD=DoDirectPayment';

$send.= '&PAYMENTACTION=' . $payment_type;

$send.= '&IPADDRESS=' . urlencode($_SERVER['REMOTE_ADDR']);

$send.= '&AMT=' . $amount;

$send.= '&CREDITCARDTYPE=' . $request->cc_type;

$send.= '&ACCT=' . urlencode(str_replace(' ', '', $request->cc_number));

$send.= '&EXPDATE=' . urlencode($request->cc_expire_date_month . $request->cc_expire_date_year);

$send.= '&CVV2=' . urlencode($request->cvv);

$send.= '&FIRSTNAME=' . urlencode('Rupak');

$send.= '&LASTNAME=' . urlencode('s');

$send.= '&EMAIL=' . urlencode('rupak@avainfotech.com');

$send.= '&PHONENUM=' . urlencode('1234567890');

$send.= '&STREET=' . urlencode('Chandigarh');

$send.= '&CITY=' . urlencode('Chandigarh');

$send.= '&STATE=' . urlencode('Panjab');

$send.= '&ZIP=' . urlencode('160047');

$send.= '&COUNTRYCODE=' . urlencode('IND');

$send.= '&CUSTREF=' . (int)$id;



$curl = curl_init('https://api-3t.sandbox.paypal.com/nvp');

curl_setopt($curl, CURLOPT_PORT, 443);

curl_setopt($curl, CURLOPT_HEADER, 0);

curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);

curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);

curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);

curl_setopt($curl, CURLOPT_POST, 1);

curl_setopt($curl, CURLOPT_POSTFIELDS, $send);

$response = curl_exec($curl);

curl_close($curl);

if (!$response) {

    $json['DoDirectPayment failed'] = curl_error($curl);

}



$response_info = array();

parse_str($response, $response_info);



$json = array();

if (($response_info['ACK'] == 'Success') || ($response_info['ACK'] == 'SuccessWithWarning')) {



    // $post = [

    //     'cc_number'         =>  $request->cc_number,

    //     'transaction_id'    =>  $response_info['TRANSACTIONID'],

    //     'payment_status'    =>  $response_info['ACK'],

    //     'payment_gateway'   =>  'Credit card - Paypal',

    //     'payment_date'      =>  \Carbon\Carbon::now()->toDateTimeString(),

    //     'status'            =>  1,

    //     'updated_at'        =>  \Carbon\Carbon::now()->toDateTimeString()

    // ];



    $invoice = Invoice::find($id);

    $invoice->cc_number         = $request->cc_number;

    $invoice->transaction_id    = $response_info['TRANSACTIONID'];

    $invoice->amount_paid       = $response_info['AMT'];

    $invoice->payment_status    = $response_info['ACK'];

    $invoice->payment_gateway   = 'Credit card - Paypal';

    $invoice->payment_date      = \Carbon\Carbon::now()->toDateTimeString();

    $invoice->status            = '1';

    $invoice->updated_at        = \Carbon\Carbon::now()->toDateTimeString();



    if($invoice->save()){

        $json['isSuccess']      =   'true';

        $json['transaction_id'] =   $response_info['TRANSACTIONID'];

    }else{

        $json['isSuccess']      =   'false';

        $json['error']          =   'Unable to update Data';

    }

}else{

    $json['isSuccess']      =   'false';

    $json['error']          =   $response_info['L_LONGMESSAGE0'];





echo json_encode($json);



exit;


/******************/ 

Comments

Popular posts from this blog

Issue - Laravel Socialite: Legacy People API has not been used in project

If you have an issue with Google Login in Laravel Socialite, Follow these instructions. Change this file ./vendor/laravel/socialite/src/Two/GoogleProvider.php with this: <?php namespace Laravel\Socialite\Two; use Illuminate\Support\Arr; class GoogleProvider extends AbstractProvider implements ProviderInterface {     protected $scopeSeparator = ' ';     /**      * The scopes being requested.      *      * @var array      */     protected $scopes = [         'openid',         'profile',         'email',     ];     /**      * {@inheritdoc}      */     protected function getAuthUrl($state)     {         return $this->buildAuthUrlFromBase('https://accounts.google.com/o/oauth2/auth', $state); ...

get records using location by dynamic radius from database.

$postads = PostAds::with('userInfo')                             ->has('userInfo')                             ->where('user_id','!=',Auth::id())                             ->whereRaw('(ST_Distance_Sphere(POINT('.$lng.','.$lat.'), POINT(longitude,latitude))/1000) <= radius')                             ->paginate(10);