如何在所有 PayPal 交易中退還費用 (How to return fee in all PayPal transactions)


問題描述

如何在所有 PayPal 交易中退還費用 (How to return fee in all PayPal transactions)

Good Afternoon 

I’m making a paypal integration with a Brasilian Magento Platform and I have to capture the fee returned by paypal 

//‑‑‑‑‑‑‑‑‑//routine to recover the fee on database Paypal//‑‑‑‑‑‑‑‑//
        $nvp = array(

            //'TRANSACTIONID'            => '7W763566L0166562G',
            'TRANSACTIONID'               => $transactionId,
            'METHOD'                => 'GetTransactionDetails',
            'PWD'                    => 'UVAYAK9WMNPP75KA',
            'USER'                    => 'leonardoccleao_api1.gmail.com',
            'SIGNATURE'            => 'AFcWxV21C7fd0v3bYYYRCpSSRl31AYlssmYYHWWmVugX7vy.se0mIMAM',
            'VERSION'                           => '84',

        );

        $curl = curl_init();

        curl_setopt( $curl , CURLOPT_URL , 'https://api‑3t.paypal.com/nvp' );
        curl_setopt( $curl , CURLOPT_SSL_VERIFYPEER , false );
        curl_setopt( $curl , CURLOPT_RETURNTRANSFER , 1 );
        curl_setopt( $curl , CURLOPT_POST , 1 );
        curl_setopt( $curl , CURLOPT_POSTFIELDS , http_build_query( $nvp ) );

        $response = urldecode( curl_exec( $curl ) );

        $responseNvp = array();

        if ( preg_match_all( '/(?<name>[^\=]+)\=(?<value>[^&]+)&?/' , $response , $matches ) ) {
            foreach ( $matches[ 'name' ] as $offset => $name ) {
                $responseNvp[ $name ] = $matches[ 'value' ][ $offset ];
            }
        }

        $fee_amount = $responseNvp['FEEAMT'];//fee recovered

        echo $fee_amount;//I get to print the fee
        curl_close( $curl );
        //‑‑‑‑‑‑‑‑‑/end routine to recover the fee on database Paypal //‑‑‑‑‑‑‑‑//

I get the fee by giving to PayPal the transaction Id (txv_id) but it only works in some transactions. In some transactions PayPal returns fee = 0.

I made a script to fill a data table with a range of transaction but of the 40 transactions made through paypal I just got 2 fees. The transactions have the same product and the same price, but not always the same fee 

I want know if PayPal has some another way to return this attribute

‑‑‑‑‑

參考解法

方法 1:

On some transactions, for example when paying with your PayPal balance, there is no fee. This might be the reason.

Paypal fees: https://www.paypal.com/webapps/helpcenter/article/?currentIssueID=11927&topicID=11500006&m=TCI

(by user1522200Sire)

參考文件

  1. How to return fee in all PayPal transactions (CC BY‑SA 3.0/4.0)

#curl #nvp #magento #paypal






相關問題

如何在所有 PayPal 交易中退還費用 (How to return fee in all PayPal transactions)

Cú pháp lệnh curl để đăng ký device_token trên Urban Airship là gì? (What is curl command syntax for device_token registration on Urban Airship?)

Nhận thời lượng video trên youtube từ URL với bash (Get youtube video duration from URL with bash)

đăng dữ liệu json với php curl cho đa phần / dữ liệu biểu mẫu để tải lên tệp nếu cakephp 2 (post json data with php curl for multipart/form-data for file upload vía cakephp 2)

ApacheMonitor 上的捲曲錯誤 (Curl error on ApacheMonitor)

從 ASP.net 使用 PHP 中的 POST 數據抓取數據 (Scraping data with POST data in PHP from ASP.net)

收聽推送消息? (Listen to a push message?)

在 PHP 中使用 cURL 的 RAW POST (RAW POST using cURL in PHP)

使用 php 和 curl 更新 mediawiki (using php and curl to update mediawiki)

在 Makefile 中鏈接 cURL (Linking cURL in Makefile)

將我的 .php 輸出發送到 curl 命令,該命令使用機器人在電報上向我發送消息 (Send my .php output to a curl command that messages me on telegram using a bot)

使用 Google My Business API 和 PHP 更新/修補本地帖子 (Updating/Patching a Local Post with Google My Business API and PHP)







留言討論