Bonjour,
J'ai une erreur de paypal que j'ai du mal à régler,
quand je fais debug($paypal->errors) du paypalcontroller ça donne ça:
array(
'TIMESTAMP' => '2016%2d03%2d15T09%3a03%3a12Z',
'CORRELATIONID' => '19cf2eca21ba8',
'ACK' => 'Failure',
'VERSION' => '122',
'BUILD' => '18316154',
'L_ERRORCODE0' => '10004',
'L_SHORTMESSAGE0' => 'Transaction%20refused%20because%20of%20an%20invalid%20argument%2e%20See%20additional%20error%20messages%20for%20details%2e',
'L_LONGMESSAGE0' => 'You%20are%20not%20signed%20up%20to%20accept%20payment%20for%20digitally%20delivered%20goods%2e',
'L_SEVERITYCODE0' => 'Error'
);
selon l'erreur code :10004, je ne suis pas inscrit pour accepter les paiement des biens numériques, Comment activer les paiments des biens numériques dans mes paramètres?
Merci
paypalcontroller.php

public function abonnement() {
        $this->loadModel('Abonnement');
          $user_id= $this->Auth->user('id');
          if(!$user_id){
            $this->Session->setFlash('Veuillez vous connecter pour pouvoir effectuer votre achat,merci.','notif');
          return $this->redirect('/users/login');
          die();
          }   
        if ($this->request->is('post')) {
        if($d['Abonnement']['price']==''){
            $this->Session->setFlash('Veuillez selectionner votre format photo','notif');
              $this->redirect($this->referer());
              }
            $d=$this->request->data; 
            //debug($d);die();
            $user_id= $this->Auth->User('id');

            $suscribe=$this->Abonnement->find('count',array(
                'conditions'=>array('user_id'=>$user_id)
                ));
            $this->Session->write('price',$d['Abonnement']['price']);
            $this->Session->write('format',$d['Abonnement']['format']);
            $this->Session->write('photo',$d['Abonnement']['photo']);
            $this->Session->write('photo_id',$d['Abonnement']['photo_id']);
            $price=$d['Abonnement']['price'];
            $format=$d['Abonnement']['format'];
            $photo_id=$d['Abonnement']['photo_id'];
            $photo=$d['Abonnement']['photo'];
            $nom=$photo." au format ".$format;
            //build nvp string
            //use your own logic to get and set each variable
            $returnURL = Router::url(array('controller'=>'payment','action'=>'paypal_return'),true);
            $cancelURL = Router::url(array('controller'=>'payment','action'=>'paypal_cancel'),true);
            $nvpStr=
            "RETURNURL=$returnURL&CANCELURL=$cancelURL"
            ."&PAYMENTREQUEST_0_CURRENCYCODE=EUR"
            ."&PAYMENTREQUEST_0_AMT=$price"
            ."&PAYMENTREQUEST_0_ITEMAMT=$price"
            ."&PAYMENTREQUEST_0_PAYMENTACTION=Sale"
            ."&L_PAYMENTREQUEST_0_ITEMCATEGORY0=Digital"  
            ."&L_PAYMENTREQUEST_0_NAME0=$nom" 
            ."&L_PAYMENTREQUEST_0_QTY0=1"
            ."&L_PAYMENTREQUEST_0_AMT0=$price"      
            ;           
            //do paypal setECCheckout
            App::import('Model','Paypal');
            $paypal = new Paypal();
            if($paypal->setExpressCheckout($nvpStr)) {
                $result = $paypal->getPaypalUrl($paypal->token);
                debug($result);
            }else {
                $this->log($paypal->errors);
                debug($paypal->errors);
                $result=false;
            }

            if(false!=$result) {
                $this->redirect($result);
            }else {
                $this->Session->setFlash('Erreur de connection avec paypal, veuillez réessayer','notif');

            }
        }
    }

model paypal.php

class Paypal extends AppModel {
    var $name = 'Paypal';
    var $useTable = false;

    //configuration
    var $methodName='SetExpressCheckout';
    var $environment = 'live';   // or 'beta-sandbox' or 'live'
    var $version = '124.0';
    //give correct info below
    var $API_UserName  = 'API_username';
    var $API_Password  = 'API_password';
    var $API_Signature = 'API_signature';     
    //variables
    var $errors        = null;   
    var $token         = null;
    var $transId       = null;
    /**
     * Send HTTP POST Request
     *
     * @param   string  The API method name
     * @param   string  The POST Message fields in &name=value pair format
     * @return  array   Parsed HTTP Response body
     */
    function PPHttpPost($methodName, $nvpStr) {
        // Set up your API credentials, PayPal end point, and API version.
        $API_UserName = $this->API_UserName;
        $API_Password = $this->API_Password;
        $API_Signature = $this->API_Signature;
        $API_Endpoint = "https://api-3t.paypal.com/nvp";
        if("sandbox" == $this->environment || "beta-sandbox" == $this->environment) {
            $API_Endpoint = "https://api-3t.$this->environment.paypal.com/nvp";
        }
        $version = urlencode($this->version);

        // 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;
    }
    /*
     * get PayPal Url for redirecting page
     */
    function getPaypalUrl($token) {    
        $payPalURL = "https://www.paypal.com/incontext?token={$token}";
        if("sandbox" === $this->environment || "beta-sandbox" === $this->environment) {        
            $payPalURL = "https://www.sandbox.paypal.com/incontext?token={$token}";
        }
        return $payPalURL;
    }     
    /*
     * call PayPal API: SetExpressCheckout
     */
    function setExpressCheckout($nvpStr) {
        // Execute the API operation; see the PPHttpPost function above.
        $httpParsedResponseAr = $this->PPHttpPost('SetExpressCheckout', $nvpStr);
        if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
            $this->token = urldecode($httpParsedResponseAr["TOKEN"]);          
            return true;
        } else  {
            $this->errors = $httpParsedResponseAr;
            return false;          
        }
    }
 /*
     * call PayPal API: GetExpressCheckoutDetails
     */
   // function GetExpressCheckoutDetails($token){
//$nvpstr='&TOKEN='.$token;
//$resArray=$this->hash_call('GetExpressCheckoutDetails',$nvpstr);
//debug($resArray);die();
//return $resArray;
//}

     /*
     * call PayPal API: DoExpressCheckoutPayment
     */
    function doExpressCheckoutPayment($nvpStr) {
        // Execute the API operation; see the PPHttpPost function above.
        $httpParsedResponseAr = $this->PPHttpPost('DoExpressCheckoutPayment', $nvpStr);
        if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) {
            $this->transId = urldecode($httpParsedResponseAr["PAYMENTINFO_0_TRANSACTIONID"]);        
            return true;
        } else  {
            $this->errors = $httpParsedResponseAr;
            return false;
        }      
    }
}

1 réponse


Pour activer les DG il fallait appeler Paypal, mais il me semble que c'était uniquement US et Canada
Apparemment les DG ne font plus partie d'Express Checkout (voir ici)
le mieux est de mettre 'Physical' pour ITEM_CATEGORY