Codeigniter localhost htaccess rule

RewriteEngine On
RewriteBase /localhost-folder-name
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|js|uploads|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Advertisements

Paypal parallal payment in php

I tried this code. It is working fine.

paypalplatform.php
<?php
/********************************************
PayPal Adaptive Payments API Module

Defines all the global variables and the wrapper functions
********************************************/
$PROXY_HOST = ‘127.0.0.1’;
$PROXY_PORT = ‘808’;

$Env = “sandbox”;

//————————————
// PayPal API Credentials
// Replace <API_USERNAME> with your API Username
// Replace <API_PASSWORD> with your API Password
// Replace <API_SIGNATURE> with your Signature
//————————————
$API_UserName = “<API_USERNAME>”;
$API_Password = “<API_PASSWORD>”;
$API_Signature = “<API_SIGNATURE>”;
// AppID is preset for sandbox use
// If your application goes live, you will be assigned a value for the live
// environment by PayPal as part of the live onboarding process.
$API_AppID = “APP-80W284485P519543T”;
$API_Endpoint = “”;

if ($Env == “sandbox”)
{
$API_Endpoint = “https://svcs.sandbox.paypal.com/AdaptivePayments&#8221;;
}
else
{
$API_Endpoint = “https://svcs.paypal.com/AdaptivePayments&#8221;;
}

$USE_PROXY = false;

if (session_id() == “”)
session_start();

function generateCharacter () {
$possible = “1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ”;
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
return $char;
}

function generateTrackingID () {
$GUID = generateCharacter().generateCharacter().generateCharacter();
$GUID .=generateCharacter().generateCharacter().generateCharacter();
$GUID .=generateCharacter().generateCharacter().generateCharacter();
return $GUID;
}

/*
‘——————————————————————————-
‘ Purpose: Prepares the parameters for the Refund API Call.
‘ The API credentials used in a Pay call can make the Refund call
‘ against a payKey, or a tracking id, or to specific receivers of a payKey or
‘ a tracking id that resulted from the Pay call.

‘ A receiver itself with its own API credentials can make a Refund call against
‘ the transactionId corresponding to their transaction.
‘ The API credentials used in a Pay call cannot use transactionId to issue a refund
‘ for a transaction for which they themselves were not the receiver.

‘ If you do specify specific receivers, you must provide the amounts as well.
‘ If you specify a transactionId, then only the receiver of that transactionId
‘ is affected. Therefore the receiverEmailArray and receiverAmountArray should
‘ have 1 entry each if you do want to give a partial refund.
‘ Inputs:

‘ Conditionally Required:
‘ One of the following: payKey or trackingId or trasactionId or
‘ (payKey and receiverEmailArray and receiverAmountArray) or
‘ (trackingId and receiverEmailArray and receiverAmountArray)
‘ or (transactionId and receiverEmailArray
‘ and receiverAmountArray)
‘ Returns:
‘ The NVP Collection object of the Refund call response.
‘————————————————————————————
*/
function CallRefund( $payKey, $transactionId, $trackingId,
$receiverEmailArray, $receiverAmountArray )
{
/* Gather the information to make the Refund call.
The variable nvpstr holds the name-value pairs.
*/

$nvpstr = “”;

// conditionally required fields
if (“” != $payKey)
{
$nvpstr = “payKey=” . urlencode($payKey);
if (0 != count($receiverEmailArray))
{
reset($receiverEmailArray);
while (list($key, $value) = each($receiverEmailArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).email=” . urlencode($value);
}
}
}
if (0 != count($receiverAmountArray))
{
reset($receiverAmountArray);
while (list($key, $value) = each($receiverAmountArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).amount=” . urlencode($value);
}
}
}
}
elseif (“” != $trackingId)
{
$nvpstr = “trackingId=” . urlencode($trackingId);
if (0 != count($receiverEmailArray))
{
reset($receiverEmailArray);
while (list($key, $value) = each($receiverEmailArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).email=” . urlencode($value);
}
}
}
if (0 != count($receiverAmountArray))
{
reset($receiverAmountArray);
while (list($key, $value) = each($receiverAmountArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).amount=” . urlencode($value);
}
}
}
}
elseif (“” != $transactionId)
{
$nvpstr = “transactionId=” . urlencode($transactionId);
// the caller should only have 1 entry in the email and amount arrays
if (0 != count($receiverEmailArray))
{
reset($receiverEmailArray);
while (list($key, $value) = each($receiverEmailArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).email=” . urlencode($value);
}
}
}
if (0 != count($receiverAmountArray))
{
reset($receiverAmountArray);
while (list($key, $value) = each($receiverAmountArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).amount=” . urlencode($value);
}
}
}
}

/* Make the Refund call to PayPal */
$resArray = hash_call(“Refund”, $nvpstr);

/* Return the response array */
return $resArray;
}

/*
‘————————————————————————————
‘ Purpose: Prepares the parameters for the PaymentDetails API Call.
‘ The PaymentDetails call can be made with either
‘ a payKey, a trackingId, or a transactionId of a previously successful Pay call.
‘ Inputs:

‘ Conditionally Required:
‘ One of the following: payKey or transactionId or trackingId
‘ Returns:
‘ The NVP Collection object of the PaymentDetails call response.
‘————————————————————————————
*/
function CallPaymentDetails( $payKey, $transactionId, $trackingId )
{
/* Gather the information to make the PaymentDetails call.
The variable nvpstr holds the name-value pairs.
*/

$nvpstr = “”;

// conditionally required fields
if (“” != $payKey)
{
$nvpstr = “payKey=” . urlencode($payKey);
}
elseif (“” != $transactionId)
{
$nvpstr = “transactionId=” . urlencode($transactionId);
}
elseif (“” != $trackingId)
{
$nvpstr = “trackingId=” . urlencode($trackingId);
}

/* Make the PaymentDetails call to PayPal */
$resArray = hash_call(“PaymentDetails”, $nvpstr);

/* Return the response array */
return $resArray;
}

/*
‘————————————————————————————
‘ Purpose: Prepares the parameters for the Pay API Call.
‘ Inputs:

‘ Required:

‘ Optional:

‘ Returns:
‘ The NVP Collection object of the Pay call response.
‘————————————————————————————
*/
function CallPay( $actionType, $cancelUrl, $returnUrl, $currencyCode,
$receiverEmailArray, $receiverAmountArray, $receiverPrimaryArray,
$receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl, $memo,
$pin, $preapprovalKey, $reverseAllParallelPaymentsOnError,
$senderEmail, $trackingId )
{
/* Gather the information to make the Pay call.
The variable nvpstr holds the name-value pairs.
*/

// required fields
$nvpstr = “actionType=” . urlencode($actionType) . “&currencyCode=”;
$nvpstr .= urlencode($currencyCode) . “&returnUrl=”;
$nvpstr .= urlencode($returnUrl) . “&cancelUrl=” . urlencode($cancelUrl);

if (0 != count($receiverAmountArray))
{
reset($receiverAmountArray);
while (list($key, $value) = each($receiverAmountArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).amount=” . urlencode($value);
}
}
}

if (0 != count($receiverEmailArray))
{
reset($receiverEmailArray);
while (list($key, $value) = each($receiverEmailArray))
{
if (“” != $value)
{
$nvpstr .= “&receiverList.receiver(” . $key . “).email=” . urlencode($value);
}
}
}

if (0 != count($receiverPrimaryArray))
{
reset($receiverPrimaryArray);
while (list($key, $value) = each($receiverPrimaryArray))
{
if (“” != $value)
{
$nvpstr = $nvpstr . “&receiverList.receiver(” . $key . “).primary=” .
urlencode($value);
}
}
}

if (0 != count($receiverInvoiceIdArray))
{
reset($receiverInvoiceIdArray);
while (list($key, $value) = each($receiverInvoiceIdArray))
{
if (“” != $value)
{
$nvpstr = $nvpstr . “&receiverList.receiver(” . $key . “).invoiceId=” .
urlencode($value);
}
}
}

// optional fields
if (“” != $feesPayer)
{
$nvpstr .= “&feesPayer=” . urlencode($feesPayer);
}

if (“” != $ipnNotificationUrl)
{
$nvpstr .= “&ipnNotificationUrl=” . urlencode($ipnNotificationUrl);
}

if (“” != $memo)
{
$nvpstr .= “&memo=” . urlencode($memo);
}

if (“” != $pin)
{
$nvpstr .= “&pin=” . urlencode($pin);
}

if (“” != $preapprovalKey)
{
$nvpstr .= “&preapprovalKey=” . urlencode($preapprovalKey);
}

if (“” != $reverseAllParallelPaymentsOnError)
{
$nvpstr .= “&reverseAllParallelPaymentsOnError=”;
$nvpstr .= urlencode($reverseAllParallelPaymentsOnError);
}

if (“” != $senderEmail)
{
$nvpstr .= “&senderEmail=” . urlencode($senderEmail);
}

if (“” != $trackingId)
{
$nvpstr .= “&trackingId=” . urlencode($trackingId);
}

/* Make the Pay call to PayPal */
$resArray = hash_call(“Pay”, $nvpstr);

/* Return the response array */
return $resArray;
}

/*
‘—————————————————————————
‘ Purpose: Prepares the parameters for the PreapprovalDetails API Call.
‘ Inputs:

‘ Required:
‘ preapprovalKey:A preapproval key that identifies the agreement
‘ resulting from a previously successful Preapproval call.
‘ Returns:
‘ The NVP Collection object of the PreapprovalDetails call response.
‘—————————————————————————
*/
function CallPreapprovalDetails( $preapprovalKey )
{
/* Gather the information to make the PreapprovalDetails call.
The variable nvpstr holds the name-value pairs.
*/

// required fields
$nvpstr = “preapprovalKey=” . urlencode($preapprovalKey);

/* Make the PreapprovalDetails call to PayPal */
$resArray = hash_call(“PreapprovalDetails”, $nvpstr);

/* Return the response array */
return $resArray;
}

/*
‘—————————————————————————
‘ Purpose: Prepares the parameters for the Preapproval API Call.
‘ Inputs:

‘ Required:

‘ Optional:

‘ Returns:
‘ The NVP Collection object of the Preapproval call response.
‘—————————————————————————
*/
function CallPreapproval( $returnUrl, $cancelUrl, $currencyCode,
$startingDate, $endingDate, $maxTotalAmountOfAllPayments,
$senderEmail, $maxNumberOfPayments, $paymentPeriod, $dateOfMonth,
$dayOfWeek, $maxAmountPerPayment, $maxNumberOfPaymentsPerPeriod, $pinType )
{
/* Gather the information to make the Preapproval call.
The variable nvpstr holds the name-value pairs.
*/

// required fields
$nvpstr = “returnUrl=” . urlencode($returnUrl) . “&cancelUrl=” . urlencode($cancelUrl);
$nvpstr .= “&currencyCode=” . urlencode($currencyCode) . “&startingDate=”;
$nvpstr .= urlencode($startingDate) . “&endingDate=” . urlencode($endingDate);
$nvpstr .= “&maxTotalAmountOfAllPayments=” . urlencode($maxTotalAmountOfAllPayments);

// optional fields
if (“” != $senderEmail)
{
$nvpstr .= “&senderEmail=” . urlencode($senderEmail);
}

if (“” != $maxNumberOfPayments)
{
$nvpstr .= “&maxNumberOfPayments=” . urlencode($maxNumberOfPayments);
}

if (“” != $paymentPeriod)
{
$nvpstr .= “&paymentPeriod=” . urlencode($paymentPeriod);
}

if (“” != $dateOfMonth)
{
$nvpstr .= “&dateOfMonth=” . urlencode($dateOfMonth);
}

if (“” != $dayOfWeek)
{
$nvpstr .= “&dayOfWeek=” . urlencode($dayOfWeek);
}

if (“” != $maxAmountPerPayment)
{
$nvpstr .= “&maxAmountPerPayment=” . urlencode($maxAmountPerPayment);
}

if (“” != $maxNumberOfPaymentsPerPeriod)
{
$nvpstr .= “&maxNumberOfPaymentsPerPeriod=” . urlencode($maxNumberOfPaymentsPerPeriod);
}

if (“” != $pinType)
{
$nvpstr .= “&pinType=” . urlencode($pinType);
}

/* Make the Preapproval call to PayPal */
$resArray = hash_call(“Preapproval”, $nvpstr);

/* Return the response array */
return $resArray;
}

/**
‘———————————————————————————-
* hash_call: Function to perform the API call to PayPal using API signature
* @methodName is name of API method.
* @nvpStr is nvp string.
* returns an associative array containing the response from the server.
‘———————————————————————————-
*/
function hash_call($methodName, $nvpStr)
{ //declaring of global variables
global $API_Endpoint, $API_UserName, $API_Password, $API_Signature, $API_AppID;
global $USE_PROXY, $PROXY_HOST, $PROXY_PORT;

$API_Endpoint .= “/” . $methodName;
//setting the curl parameters.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$API_Endpoint);
curl_setopt($ch, CURLOPT_VERBOSE, 1);

//turning off the server and peer verification(TrustManager Concept).
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);

// Set the HTTP Headers
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
‘X-PAYPAL-REQUEST-DATA-FORMAT: NV’,
‘X-PAYPAL-RESPONSE-DATA-FORMAT: NV’,
‘X-PAYPAL-SECURITY-USERID: ‘ . $API_UserName,
‘X-PAYPAL-SECURITY-PASSWORD: ‘ .$API_Password,
‘X-PAYPAL-SECURITY-SIGNATURE: ‘ . $API_Signature,
‘X-PAYPAL-SERVICE-VERSION: 1.3.0’,
‘X-PAYPAL-APPLICATION-ID: ‘ . $API_AppID
));

//if USE_PROXY constant set to TRUE in Constants.php,
//then only proxy will be enabled.
//Set proxy name to PROXY_HOST and port number to PROXY_PORT in constants.php
if($USE_PROXY)
curl_setopt ($ch, CURLOPT_PROXY, $PROXY_HOST. “:” . $PROXY_PORT);

// RequestEnvelope fields
$detailLevel = urlencode(“ReturnAll”); // See DetailLevelCode in the WSDL
// for valid enumerations
$errorLanguage = urlencode(“en_US”); // This should be the standard RFC
// 3066 language identification tag,
// e.g., en_US

// NVPRequest for submitting to server
$nvpreq = “requestEnvelope.errorLanguage=$errorLanguage&requestEnvelope”;
$nvpreq .= “detailLevel=$detailLevel&$nvpStr”;

//setting the nvpreq as POST FIELD to curl
curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

//getting response from server
$response = curl_exec($ch);

//converting NVPResponse to an Associative Array
$nvpResArray=deformatNVP($response);
$nvpReqArray=deformatNVP($nvpreq);
$_SESSION[‘nvpReqArray’]=$nvpReqArray;

if (curl_errno($ch))
{
// moving to display page to display curl errors
$_SESSION[‘curl_error_no’]=curl_errno($ch) ;
$_SESSION[‘curl_error_msg’]=curl_error($ch);

//Execute the Error handling module to display errors.
}
else
{
//closing the curl
curl_close($ch);
}

return $nvpResArray;
}

/*’—————————————————————————-
Purpose: Redirects to PayPal.com site.
Inputs: $cmd is the querystring
Returns:
——————————————————————————-
*/
function RedirectToPayPal ( $cmd )
{
// Redirect to paypal.com here
global $Env;

$payPalURL = “”;

if ($Env == “sandbox”)
{
$payPalURL = “https://www.sandbox.paypal.com/webscr?&#8221; . $cmd;
}
else
{
$payPalURL = “https://www.paypal.com/webscr?&#8221; . $cmd;
}

header(“Location: “.$payPalURL);
}
/*’—————————————————————————-
* This function will take NVPString and convert it to an Associative Array
* and then will decode the response.
* It is useful to search for a particular key and display arrays.
* @nvpstr is NVPString.
* @nvpArray is Associative Array.
—————————————————————————-
*/
function deformatNVP($nvpstr)
{
$intial=0;
$nvpArray = array();

while(strlen($nvpstr))
{
//postion of Key
$keypos= strpos($nvpstr,’=’);
//position of value
$valuepos = strpos($nvpstr,’&’) ? strpos($nvpstr,’&’): strlen($nvpstr);

/*getting the Key and Value values and storing in a Associative Array*/
$keyval=substr($nvpstr,$intial,$keypos);
$valval=substr($nvpstr,$keypos+1,$valuepos-$keypos-1);
//decoding the respose
$nvpArray[urldecode($keyval)] =urldecode( $valval);
$nvpstr=substr($nvpstr,$valuepos+1,strlen($nvpstr));
}
return $nvpArray;
}
?>

Include paypalplatform.php in parallelpayment.php

parallelpayment.php

<?php

//————————————————-
// When you integrate this code,
// look for TODO as an indication
// that you may need to provide a value or take
// action before executing this code.
//————————————————-

require_once (“paypalplatform.php”);
// ==================================
// PayPal Platform Parallel Payment Module
// ==================================

// Request specific required fields
$actionType = “PAY”;
$cancelUrl = “https://mycancelurl&#8221;; // TODO – If you are not executing the Pay call
// for a preapproval, then you must set a valid
// cancelUrl for the web approval flow that
// immediately follows this Pay call
$returnUrl = “https://myreturnurl&#8221;; // TODO – If you are not executing the Pay call
// for a preapproval, then you must set a valid
// returnUrl for the web approval flow that
// immediately follows this Pay call
$currencyCode = “USD”;

// A parallel payment can be made among two to six receivers
// TODO – Specify the receiver emails
// Remove or set to an empty string the array entries for receivers that you
// do not have
$receiverEmailArray = array(
‘receiver0email’,
‘receiver1email’,
‘receiver2email’,
‘receiver3email’,
‘receiver4email’,
‘receiver5email’
);

// TODO – Specify the receiver amounts as the amount of money, for example, ‘5’ or ‘5.55’
// Remove or set to an empty string the array entries for receivers that you
// do not have
$receiverAmountArray = array(
‘receiver0amount’,
‘receiver1amount’,
‘receiver2amount’,
‘receiver3amount’,
‘receiver4amount’,
‘receiver5amount’
);

// For parallel payment, no primary indicators are needed, so set empty array.
$receiverPrimaryArray = array();

// TODO – Set invoiceId to uniquely identify the transaction associated with
// each receiver
// Set the array entries with value for receivers that you have
// Each of the array values must be unique
$receiverInvoiceIdArray = array(
”,
”,
”,
”,
”,

);

// Request specific optional fields
// Provide a value for each field that you want to include in the request;
// if left as an empty string, the field will not be passed in the request
$senderEmail = “”; // TODO – If you are executing the Pay call against a
// preapprovalKey, you should set senderEmail
// It is not required if the web approval flow immediately
// follows this Pay call
$feesPayer = “”;
$ipnNotificationUrl = “”;
$memo = “”; // maxlength is 1000 characters
$pin = “”; // TODO – If you are executing the Pay call against an existing
// preapproval that requires a pin, then you must set this
$preapprovalKey = “”; // TODO – If you are executing the Pay call against
// an existing preapproval, set the preapprovalKey here
$reverseAllParallelPaymentsOnError = “”; // TODO – Set this to “true” if you would
// like each parallel payment to be reversed
// if an error occurs
// Defaults to “false” if you don’t specify
$trackingId = generateTrackingID(); // generateTrackingID function is found
// in paypalplatform.php

//————————————————-
// Make the Pay API call
//
// The CallPay function is defined in the paypalplatform.php file,
// which is included at the top of this file.
//————————————————-
$resArray = CallPay ($actionType, $cancelUrl, $returnUrl, $currencyCode,
$receiverEmailArray, $receiverAmountArray, $receiverPrimaryArray,
$receiverInvoiceIdArray, $feesPayer, $ipnNotificationUrl, $memo,
$pin, $preapprovalKey, $reverseAllParallelPaymentsOnError,
$senderEmail, $trackingId
);

$ack = strtoupper($resArray[“responseEnvelope.ack”]);
if($ack==”SUCCESS”)
{
if (“” == $preapprovalKey)
{
// redirect for web approval flow
$cmd = “cmd=_ap-payment&paykey=” . urldecode($resArray[“payKey”]);
RedirectToPayPal ( $cmd );
}
else
{
// payKey is the key that you can use to identify the result from this Pay call
$payKey = urldecode($resArray[“payKey”]);
// paymentExecStatus is the status of the payment
$paymentExecStatus = urldecode($resArray[“paymentExecStatus”]);
}
}
else
{
//Display a user-friendly Error on the page using any of the following error
//information returned by PayPal.
//TODO – There can be more than 1 error, so check for “error(1).errorId”,
// then “error(2).errorId”, and so on until you find no more errors.
$ErrorCode = urldecode($resArray[“error(0).errorId”]);
$ErrorMsg = urldecode($resArray[“error(0).message”]);
$ErrorDomain = urldecode($resArray[“error(0).domain”]);
$ErrorSeverity = urldecode($resArray[“error(0).severity”]);
$ErrorCategory = urldecode($resArray[“error(0).category”]);

echo “Preapproval API call failed. “;
echo “Detailed Error Message: ” . $ErrorMsg;
echo “Error Code: ” . $ErrorCode;
echo “Error Severity: ” . $ErrorSeverity;
echo “Error Domain: ” . $ErrorDomain;
echo “Error Category: ” . $ErrorCategory;
}
?>

Reference https://www.safaribooksonline.com/library/view/paypal-apis-up/9781449397401/ch04.html

The only thing that we have to do is to enter API Credentials in paypalplatform.php and have to enter paypal ID and amount in parallelpayment.php

It will support only for https website.

All The Best

Recurring Payment Using NVP api in paypal

https://developer.paypal.com/docs/classic/api/merchant/TransactionSearch_API_Operation_NVP/

https://developer.paypal.com/docs/classic/api/merchant/GetTransactionDetails_API_Operation_NVP/

https://developer.paypal.com/docs/classic/express-checkout/ht_searchRetrieveTransactionData-curl-etc/

========================================================================================

 

Setexpresscheckout.php
<?php
$curl = curl_init();
 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
    'USER' => 'usuario_da_api',
    'PWD' => '123123123123',
    'SIGNATURE' => 'assinatura.da.api',
 
    'METHOD' => 'SetExpressCheckout',
    'VERSION' => '108',
    'LOCALECODE' => 'pt_BR',
 
    'PAYMENTREQUEST_0_AMT' => 100,
    'PAYMENTREQUEST_0_CURRENCYCODE' => 'BRL',
    'PAYMENTREQUEST_0_PAYMENTACTION' => 'Sale',
    'PAYMENTREQUEST_0_ITEMAMT' => 100,
 
    'L_PAYMENTREQUEST_0_NAME0' => 'Exemplo',
    'L_PAYMENTREQUEST_0_DESC0' => 'Assinatura de exemplo',
    'L_PAYMENTREQUEST_0_QTY0' => 1,
    'L_PAYMENTREQUEST_0_AMT0' => 100,

    'L_BILLINGTYPE0' => 'RecurringPayments',
    'L_BILLINGAGREEMENTDESCRIPTION0' => 'Exemplo',
 
    'CANCELURL' => 'http://localhost/cancel.html',
    'RETURNURL' => 'http://localhost/sucesso.html'
)));
 
$response =    curl_exec($curl);
 
curl_close($curl);
 
$nvp = array();
 
if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
    foreach ($matches['name'] as $offset => $name) {
        $nvp[$name] = urldecode($matches['value'][$offset]);
    }
}

if (isset($nvp['ACK']) && $nvp['ACK'] == 'Success') {
    $query = array(
        'cmd'    => '_express-checkout',
        'token'  => $nvp['TOKEN']
    );

    $redirectURL = sprintf('https://www.sandbox.paypal.com/cgi-bin/webscr?%s', http_build_query($query));

    header('Location: ' . $redirectURL);
} else {
    //Opz, alguma coisa deu errada.
    //Verifique os logs de erro para depuração.
} 

CreatingRecurringProfile.php
<?php
$curl = curl_init();
 
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
    'USER' => 'usuario_da_api',
    'PWD' => '1234123424',
    'SIGNATURE' => 'assinatura.da.api',
 
    'METHOD' => 'CreateRecurringPaymentsProfile',
    'VERSION' => '108',
    'LOCALECODE' => 'pt_BR',
 
    'TOKEN' => 'EC-0A9774676H705661Y',
    'PayerID' => '5KWXTCEDXPFQS',
 
    'PROFILESTARTDATE' => '2012-10-08T16:00:00Z',
    'DESC' => 'Exemplo',
    'BILLINGPERIOD' => 'Month',
    'BILLINGFREQUENCY' => '1',
    'AMT' => 100,
    'CURRENCYCODE' => 'BRL',
    'COUNTRYCODE' => 'BR',
    'MAXFAILEDPAYMENTS' => 3
)));
 
$response =    curl_exec($curl);
 
curl_close($curl);
 
$nvp = array();
 
if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
    foreach ($matches['name'] as $offset => $name) {
        $nvp[$name] = urldecode($matches['value'][$offset]);
    }
}
 
print_r($nvp);

Payment History Details:
<?php 
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_URL, 'https://api-3t.sandbox.paypal.com/nvp');
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array(
 'USER' => 'usuario_da_api',
 'PWD' => '1234123424',
 'SIGNATURE' => 'assinatura.da.api',
 
 'METHOD' => 'TransactionSearch', 
 'STARTDATE' => $gmt_date,
 'VERSION' => '123', 
 //'PROFILEID' => 'I-TWCJ1V9W5JSF'
 'PROFILEID' => $select_for_date['subscription_id']
 //ID I-17PGXW29RBXR
)));
 
$response = curl_exec($curl);
 
curl_close($curl);
 
$nvp = array();
 
if (preg_match_all('/(?<name>[^\=]+)\=(?<value>[^&]+)&?/', $response, $matches)) {
 foreach ($matches['name'] as $offset => $name) {
 $nvp[$name] = urldecode($matches['value'][$offset]);
 }
}
echo "<pre>"; 
print_r($nvp);

?>

Retrieve Comma separated Values in a Table column by Mysql Query

FIND_IN_SET is the function which return result in searching for specific values in a comma separated values in a table column ,

You don’t need to use large set of record and array to filter those records  , use the query below to get records which you needed,

Syntax:

SELECT * FROM Table_name WHERE FIND_IN_SET(‘value’, column_name)

table_clm

Have a look on the table columns i have web_class_id in a commas separated values , i want to retrieve web_class_id with value 63 now i will use the query below

SELECT * FROM Table_name WHERE FIND_IN_SET(’63’, web_class_id)

I got the result below

tbleclm2

 

Get current city name via latitude and longitude using javascript

<p id="city"></p>


$(document).ready( function () {    
    // define lat / long
    var lat = 37.42;
    var long = -122.08;

    $.ajax({
        type: 'GET',
        dataType: "json",
        url: "http://maps.googleapis.com/maps/api/geocode/json?latlng="+lat+","+long+"&sensor=false",
        data: {},
        success: function(data) {
            $('#city').html(data);
            $.each( data['results'],function(i, val) {
                $.each( val['address_components'],function(i, val) {
                    if (val['types'] == "locality,political") {
                        if (val['long_name']!="") {
                            $('#city').html(val['long_name']);
                        }
                        else {
                            $('#city').html("unknown");
                        }
                        console.log(i+", " + val['long_name']);
                        console.log(i+", " + val['types']);
                    }
                });
            });
            console.log('Success');
        },
        error: function () { console.log('error'); } 
    }); 
});

Improve Coding Skills

Great developers have more than just coding skills to offer to an employer. They understand everything from business development to project management. They are self-sufficient and can work well with others. But most importantly, great developers write elegant and effectively tested codes.

The demand for developers is high; employment of software engineers is projected to grow 22 percent from 2012 to 2022, much faster than the average for all occupations. But this high demand shouldn’t allow for low expectation in the quality of hires.

Don’t get me wrong, as someone who can’t code, to me developers are sort of magicians. But like in any profession, sometimes you need to make sure that your skills are polished and that you are offering the best service to a company.

Tech.Co reached out to developers and educators to find out the clear signs a developer needs to improve their skills. There are five obvious signs that it’s time to brush up on your skills:

1. Your Code is Sloppy

Sloppy coding is used to describe a piece of code that isn’t very expandable or versatile. So if someone else tries to add or subtract something to the code, it breaks the whole thing. Poorly constructed code is usually easier upfront, but you end up paying much more in long-term costs when the code is unreliable, difficult to understand, and expensive to debug.

“Whenever a piece of code is written, certain design decisions must be made by the developer (the type of data structure to use, which algorithm to use for a task, API design, etc.). If a developer is not able to coherently defend the choices she made for the implementation then it is often a sign that the developer does not clearly understand something in the implementation. This is why code reviews (a process where another developer on the team goes through code and discusses it with the developer who wrote the code) are beneficial not only for code quality (reducing the number of bugs) but also for professional development, as it forces the developer to think about choices they are making during implementation as they know these must be defended later during code review,” said William Lyon, Software Engineer Datamaglia.
So spend extra time making sure that the code looks good.

2. You’re Afraid of Someone Else’s Code

You shouldn’t be intimated by other developers’ code. By feeling intimated, you send a message that you are insecure about your own skills. Collaboration is key to developing coding skills, so poke around other people’s code and figure out what it does. Open source projects can be a great way to start looking at code that you have not written as a developer.

“If it’s in open source library it means it has been tested and hardened by other people and likely has less bugs than if you were to write it from scratch. If you have a tendency to shy away from code you didn’t write, you’re not leaving your comfort zone and costing your employer money,” Gezim Hoxha, CTO of SynoTrip.
3. You’re Taking Too Long To Come Up With a Solution

If you’re struggling to build a code, you have to ask yourself why. Asking for help is okay, and with so many platforms for coders to share information, your best bet is to learn from others.

“If a developer is constantly taking significantly longer, this is an indication he or she may need more help. This, along with peer code reviews, help identify areas of weakness, and we can then offer targeted training and development by senior developers as needed,” Simon Slade of Doubledot Media.
4. You’re Not Interested in Learning New Languages

General knowledge of languages and systems are more important than specific knowledge of just one language. A good developer knows and is interested in learning different programming languages, especially if languages are constantly changing.

“Software development as an industry is constantly changing. Platforms rise and fall. If you find yourself using the same programming approaches and tools you’ve always used, you probably need to change things up. Go to a user group for your favorite language and learn about new techniques that you haven’t heard about. Keep up with the online software community through sites like Hacker News or the thousands of other programming blogs. Software development isn’t just a career – it’s a community as well. If you are not engaging with the software community, you’ll probably get left behind in your career,” Peter Kananen, Delivery Manager and Partner, Gaslight.
“Developers who continually master their skills are able to direct their own career path, by becoming a respected technical
architect, an empathetic and effective technical manager, or by gaining enough business acumen to be a successful entrepreneur,” Liza Daly, CTO of Safari.
5. You’re Not a Team Player

Communication that flows from the developer to their employers is critical for the relationship and growth of the company. A good developer knows how to explain technical concepts to the non-technical people.

“Professional software engineers need to immerse themselves in the actual business. When a developer receives the business requirements, there will often be details that are ambiguous or simply left out altogether. A mediocre programmer will simply produce what was stated, while an expert will understand the business and ask relevant questions to clarify all the details to ensure that the product will truly meet the business needs,” Jay Wengrow, founder of Anyone Can Learn To Code.
Being part of a team also means communicating your struggles and concerns.

“Most programmers have difficulty expressing the problem or their solution, either to other programmers or especially to manager/product design team. It is incredibly important for programmers to be able to translate our nerd jargon into laymen’s terms,” Adam Wulf of Loose Lea