沙盒Paypal金钱扣除问题 [英] Sandbox Paypal Money Deduction Issues

查看:238
本文介绍了沙盒Paypal金钱扣除问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

function paiement_echec()
    {
    echo "payment cancelled by the user";
    }

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"])) 
      {
          //print_r($httpParsedResponseAr);
          $payerID = urlencode($httpParsedResponseAr["PAYERID"]);
          //$token = urlencode("token");
          $paymentType = urlencode('Sale');         // or 'Sale' or 'Order'
          $paymentAmount = urlencode("4.39");
          $currencyID = urlencode("USD");                       // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD')

// Add request-specific fields to the request string.
          $nvpStr = "&TOKEN=$token&PAYERID=$payerID&PAYMENTACTION=$paymentType&AMT=$paymentAmount&CURRENCYCODE=$currencyID";
          $httpParsedResponseAr = $this->PPHttpPost('DoExpressCheckoutPayment', $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";
            }
      } 
  else  
      {
        //exit('GetExpressCheckoutDetails failed: ' . print_r($httpParsedResponseAr, true));
        echo "Payment failed for unknown reason";
      }
}


function pay_by_paypal()
{

        $environment = 'sandbox';
        $_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']);
        $currencyID = urlencode("USD");



// 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_PAYMENTACTION=$paymentType
&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.$environment.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 = 'sandbox';   // or 'beta-sandbox' or 'live'
    // Set up your API credentials, PayPal end point, and API version.
    $API_UserName = urlencode('saswat_1360720799_biz_api1.gmail.com');
    $API_Password = urlencode('1360720821');
    $API_Signature = urlencode('ApDCeFez-N1Gd1-O3ubTGdpyiow4AlNlRemm8XJFcbsA.WbSMtlMSqHf');
    $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;
}



我在Paypal沙箱中有三个帐户:两个业务和一个个人。我所有的Paypal帐户都有美元作为默认货币。

I have three accounts in the Paypal sandbox: two business and one personal. All of my Paypal accounts have USD as default currency.

在上述代码中,我使用欧元作为货币。

In the above code I was using EUR as a currency.

当我进行交易时,如果我以我的个人(买家)帐户以欧元付款,那么我的买家帐户将扣除金额(等值金额的美元已从我的买家帐户扣除)。这是完全正常的,没有问题。

When I am carrying out transaction, if I am paying from my personal (buyer) account in EUR, then my buyer account is getting money deducted (equivalent amount of USD is getting subtracted from my buyer account). This is totally fine, there is no issue with that.

问题是没有金额被添加到我的业务或(卖家)帐户。

The problem is that no amount is getting added to my business or (seller) account.

我在Stack Overflow上发现了一个帖子:

I found a post on Stack Overflow that reads:


如果事务的currencycode和

if the currencycode of the transaction and the seller account doesnt match, then money doesnt get aded to sellers account

我将欧元更改为美元,(因为我的卖家帐户没有
匹配,沙箱卖家测试帐户是在USD),并发现,在转换为美元,然后我的钱被添加到我的卖家帐户。

I changed the euro to USD, (since my sandbox seller test account is in USD) and found out that, after converting it into USD, then my money is getting added to my seller account.

这是一个问题

我有一个网站,买家可以用英镑,欧元,MYN,新加坡元,澳元支付。

I have a site where buyers can pay in GBP, EUR, MYN, SGD, AUD.

如果交易需要以特定货币进行,即根据卖家帐户设置的货币,则不需要使用不同的货币。

If the transaction needs to be carried out in particular currency, that is the currency set as per the seller account, then there's no need to use different currencies.

由于在SetExpressCheckOut传递的currencyCode应该与DoExpressCheckout匹配,并且正如我遇到的问题,currencyCode需要与沙盒卖家帐户相同,所以即使买家选择GBP ,我必须将其作为卖家帐户的currencyCode发送给SetExpressCheckout。

Since the currencyCode which is passed in SetExpressCheckOut should match with the DoExpressCheckout, and as I have faced problem, currencyCode needs to be same as that of sandbox seller account, so even if buyers are selecting GBP, I have to send it to SetExpressCheckout as the currencyCode of the seller account.

推荐答案

您应该添加您想要的货币

You should add the currencies you would like to receive payments in through the control panel of your business account in question.

前往个人资料 - > 我的设置 - >财务信息选项卡和货币余额。从那里选择货币并将其添加到列表。然后,您收到的款项会以他们所支付的货币余额存入,直到您将它们转换为您想要的货币。

Go to Profile -> My Settings -> Financial Information tab and Currency Balances. From there select a currency and add it to the list. Your received payments are then kept in the respective currency balance they were made until you convert them to whatever you want.

这篇关于沙盒Paypal金钱扣除问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆