0

我在我的脚本中集成了贝宝支付网关,

我已经在贝宝沙盒中对其进行了测试,并且效果很好。然后我为“paypal live”制作了脚本,当然只是更改了名为 $environment 的变量。

它完全没有任何错误,但问题是,没有钱被转移到贝宝账户..

我已经检查了 paypal api 的签名等,这完全没问题..

但是还是没有转钱。。

我虽然可以在这里发布以寻求帮助

function paiement_succes()
{
  // Obtain the token from PayPal.
  if(!array_key_exists('token', $_REQUEST)) 
         exit('Token is not received.');
  // Set request-specific fields.
  $token = urlencode(htmlspecialchars($_REQUEST['token']));
  // Add request-specific fields to the request string.
  $nvpStr = "&TOKEN=$token";
  // Execute the API operation; see the PPHttpPost function above.
  $httpParsedResponseAr = $this->PPHttpPost('GetExpressCheckoutDetails', $nvpStr);
  if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) 
      {
          $this->load->model('payment_model');
          $this->payment_model->paypal_payment();
          $msg = "<label>Thank you !! your payment is successfully done</label>
              <a href='".base_url()."envoie_de_photos/envoyer_vos_photos"."'>Go To Photo Uploading</a>";
          echo $msg;
      } 
  else  
      {
        //exit('GetExpressCheckoutDetails failed: ' . print_r($httpParsedResponseAr, true));
        echo "Payment failed for unknown reason";
      }
}


function pay_by_paypal()
{

        $environment = 'live';
        $_SESSION['item_name']=$this->input->post('item_name');
        $_SESSION['amount']=$this->input->post('amount');
        $_SESSION['currency_code']=$this->input->post('currency_code');
        $_SESSION['no_of_photo']=$this->input->post('no_of_photo');

        $qty=urlencode("1");
        $product_name=urldecode($_SESSION['item_name']);
        $price=urlencode($_SESSION['amount']);
        $currencyID = urlencode($_SESSION['currency_code']);



// or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')
     $paymentType = urlencode('Order'); 
     $nvpStr=""; 
     $returnURL = (base_url()."paiement/paiement_succes");
     $cancelURL = (base_url()."paiement/paiement_echec");  
     $i=0;
     $total_amount=0;

     $str = "&METHOD=SetExpressCheckout
&RETURNURL=$returnURL
&CANCELURL=$cancelURL
&L_PAYMENTREQUEST_0_NAME0=$product_name
&L_PAYMENTREQUEST_0_NUMBER0=$qty
&L_PAYMENTREQUEST_0_AMT0=$price
&L_PAYMENTREQUEST_0_DESC0=$product_name
&PAYMENTREQUEST_0_AMT=$price
&PAYMENTREQUEST_0_CURRENCYCODE=$currencyID"; 
     $nvpStr=$nvpStr.$str;
$httpParsedResponseAr = $this->PPHttpPost('SetExpressCheckout', $nvpStr);

if("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"]))
    {
    // Redirect to paypal.com.
    $token = urldecode($httpParsedResponseAr["TOKEN"]);
    $payPalURL = "https://www.paypal.com/webscr&cmd=_express-checkout&token=$token";
    if("sandbox" === $environment) 
            {
        $payPalURL = "https://www.$environment.paypal.com/webscr&cmd=_express-checkout&token=$token";
        }
    header("Location: $payPalURL");
    exit;
} 
else  
    {
    exit('SetExpressCheckout failed: ' . print_r($httpParsedResponseAr, true));
}

}

/** SetExpressCheckout NVP example; last modified 08MAY23.
 *
 *  Initiate an Express Checkout transaction. 
*/


/**
 * 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
 */
private function PPHttpPost($methodName_, $nvpStr_) {
    //global $environment;
        $environment = 'live';  // or 'beta-sandbox' or 'live'
    // Set up your API credentials, PayPal end point, and API version.
    $API_UserName = urlencode('exmaple_api1.sazet_rey.com');
    $API_Password = urlencode('BH89Hx&*09$%bhy65');
    $API_Signature = urlencode('sdfr$%$VGBHHYT899999090-9987777');
    $API_Endpoint = "https://api-3t.paypal.com/nvp";
    if("sandbox" === $environment) {
        $API_Endpoint = "https://api-3t.$environment.paypal.com/nvp";
    }
    $version = urlencode('65.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;
}

我很感激对此的一些帮助,如果发生任何事情,我将不胜感激

4

2 回答 2

0

检查并确保您没有传递名为“主题”的变量。如果您将其传递过来,这将导致您的 API 调用尝试传递到您在主题中传递的 PayPal 帐户上。但是,如果您确实拥有权限并获得了成功的回复,那么这笔钱将在该帐户中,而不是您的 API 凭证来自的那个帐户。如果您没有 API 权限,您将收到一条错误提示。当您进行 API 调用时,您是否收到任何类型的响应。如果是这样,你要回什么?

于 2013-02-12T14:08:15.003 回答
0

您是否收到来自 PayPal 的电子邮件,告知您已收到付款?如果是这样,请检查以确保您的 PayPal 帐户上的电子邮件地址得到确认。

于 2013-02-12T15:13:24.697 回答