Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why money not transferred through Paypal MassApi while getting success in response

Hi i am integrating MassPay Api in my project i want to sent bulk payments through masspay api i am integrating on codeigniter. i have created two function for this and get correlation id and success message but when i see my sandbox paypal account money not transfer and no transaction in my sandbox account.

This my code please guide how can i setup

public function PPHttpPost($methodName_, $nvpStr_) {

    $environment = 'sandbox';
    // Set up your API credentials, PayPal end point, and API version.
    $API_UserName = urlencode('sufyan_api1.xcluesiv.com');
    $API_Password = urlencode('FQP8TTSXK8QHRCTM');
    $API_Signature = urlencode('Ap7D643r8OUdvdzrOomgF0ATl.qSAygx3ERPaDvqm0umQ6aZwiX3t3r5');


    $API_Endpoint = "https://api-3t.paypal.com/nvp";
    if("sandbox" === $environment || "beta-sandbox" === $environment) {
        $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
    }
    $version = urlencode('51.0');

    // Set the curl parameters.
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $API_Endpoint);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);

    // Turn 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 API operation, version, and API signature in the request.
    $nvpreq = "METHOD=$methodName_&VERSION=$version&PWD=$API_Password&USER=$API_UserName&SIGNATURE=$API_Signature$nvpStr_";

    // Set the request as a POST FIELD for curl.
    curl_setopt($ch, CURLOPT_POSTFIELDS, $nvpreq);

    // Get response from the server.
    $httpResponse = curl_exec($ch);

    if(!$httpResponse) {
        exit("$methodName_ failed: ".curl_error($ch).'('.curl_errno($ch).')');
    }

    // Extract the response details.
    $httpResponseAr = explode("&", $httpResponse);

    $httpParsedResponseAr = array();
    foreach ($httpResponseAr as $i => $value) {
        $tmpAr = explode("=", $value);
        if(sizeof($tmpAr) > 1) {
            $httpParsedResponseAr[$tmpAr[0]] = $tmpAr[1];
        }
    }

    if((0 == sizeof($httpParsedResponseAr)) || !array_key_exists('ACK', $httpParsedResponseAr)) {
        exit("Invalid HTTP Response for POST request($nvpreq) to $API_Endpoint.");
    }

    return $httpParsedResponseAr;
}

public function paymultiple() {

// Set request-specific fields.
$emailSubject =urlencode('This is created by sufyan');
$receiverType = urlencode('EmailAddress');
$currency = urlencode('USD');                           // or other currency ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')

// Add request-specific fields to the request string.
$nvpStr="&EMAILSUBJECT=$emailSubject&RECEIVERTYPE=$receiverType&CURRENCYCODE=$currency";

$receiversArray = array();

for($i = 0; $i < 3; $i++) {
    $receiverData = array(  'receiverEmail' => "[email protected]",
                            'amount' => "26.00",
                            'uniqueID' => "12",
                            'note' => "this is gift for you");
    $receiversArray[$i] = $receiverData;
}

foreach($receiversArray as $i => $receiverData) {
    $receiverEmail = urlencode($receiverData['receiverEmail']);
    $amount = urlencode($receiverData['amount']);
    $uniqueID = urlencode($receiverData['uniqueID']);
    $note = urlencode($receiverData['note']);
    $nvpStr .= "&L_EMAIL$i=$receiverEmail&L_Amt$i=$amount&L_UNIQUEID$i=$uniqueID&L_NOTE$i=$note";
}

// Execute the API operation; see the PPHttpPost function above.
$httpParsedResponseAr = $this->PPHttpPost('MassPay', $nvpStr);

if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
    echo $email   = $httpParsedResponseAr["receiver_email"];  
    echo $amount  = $httpParsedResponseAr["mc_currency_x"];
    exit('MassPay Completed Successfully: '.print_r($httpParsedResponseAr, true));


} else  {
    exit('MassPay failed: ' . print_r($httpParsedResponseAr, true));
}

}

And i am also enable ipn and i give the url this in ipn this is my ipn url: http://xxxx.com/paypal/PPHttpPost

Please help me how can money transfer through masspay api

like image 233
Ayaz Shah Avatar asked Aug 22 '14 08:08

Ayaz Shah


1 Answers

I have used https://github.com/paypal/merchant-sdk-php

//Paypal Mass Pay integration
            $massPayRequest = new MassPayRequestType();
            $massPayRequest->MassPayItem = array();
            $masspayItem = new MassPayRequestItemType();
            $masspayItem->Amount = new BasicAmountType(PAYPAL_CURRENCY, $input['amount']);
            $masspayItem->ReceiverEmail = $input['email'];  
            $massPayRequest->MassPayItem[] = $masspayItem;
            $massPayReq = new MassPayReq();
            $massPayReq->MassPayRequest = $massPayRequest;
            $paypalService = new PayPalAPIInterfaceServiceService();
            $massPayResponse = $paypalService->MassPay($massPayReq); // Call paypal mass pay

It works for me it requires user amount, currency and email to whom you need to transfer amount.

If you created sandbox account with [email protected] then paypal create account with new email e.g [email protected] you need to check with new email id. Paypal will transfer amount to that email id in case of sandbox

On live if receiver paypal account is not available with the specified email. Then also paypal transfer amount to that email. for access that amount user need to create account with that email id.

like image 179
Satish Shinde Avatar answered Oct 22 '22 05:10

Satish Shinde