首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Paypal API退款(PHP API)

Paypal API退款(PHP API)
EN

Stack Overflow用户
提问于 2015-11-25 20:38:55
回答 2查看 485关注 0票数 0

这是我第一次发帖:我希望将PayPal应用编程接口集成到我的网站中,我可以成功完成付款,但不能退款部分。我在lib文件夹中看到了一个退款api;但是,我不确定应该使用哪个ID,我没有看到很多关于退款的示例。

这就是我现在所拥有的:

代码语言:javascript
复制
$refund = new Refund();
$refund->setId($payment_id);
$refund->setAmount(1000);
$refund->get($payment_id, $this->apiContext);


try {
    //$refund = Refund::get();
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
            exit(1);
}

// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY

return json_decode($payment, 128);

其中,付款详细信息为:

代码语言:javascript
复制
 array(10) {
      ["id"]=>
      string(28) "PAY-1WL153218P032830GKZK2BLY"
      ["intent"]=>
      string(4) "sale"
      ["state"]=>
      string(7) "created"
      ["cart"]=>
      string(17) "08X596883D298843B"
      ["payer"]=>
      array(3) {
        ["payment_method"]=>
        string(6) "paypal"
        ["status"]=>
        string(8) "VERIFIED"
        ["payer_info"]=>
        array(8) {
          ["email"]=>
          string(32) "ted.chou12-facilitator@gmail.com"
          ["first_name"]=>
          string(4) "test"
          ["last_name"]=>
          string(11) "facilitator"
          ["payer_id"]=>
          string(13) "GGYZW23EGRAY4"
          ["shipping_address"]=>
          array(7) {
            ["recipient_name"]=>
            string(16) "test facilitator"
            ["line1"]=>
            string(22) "88 Des Voeux Road West"
            ["line2"]=>
            string(6) "3F 520"
            ["city"]=>
            string(9) "Hong Kong"
            ["state"]=>
            string(9) "Hong Kong"
            ["postal_code"]=>
            string(6) "000000"
            ["country_code"]=>
            string(2) "HK"
          }
          ["phone"]=>
          string(10) "4088069385"
          ["country_code"]=>
          string(2) "US"
          ["billing_address"]=>
          array(6) {
            ["line1"]=>
            string(22) "88 Des Voeux Road West"
            ["line2"]=>
            string(6) "3F 520"
            ["city"]=>
            string(9) "Hong Kong"
            ["state"]=>
            string(9) "Hong Kong"
            ["postal_code"]=>
            string(6) "000000"
            ["country_code"]=>
            string(2) "HK"
          }
        }
      }
      ["transactions"]=>
      array(1) {
        [0]=>
        array(6) {
          ["amount"]=>
          array(3) {
            ["total"]=>
            string(7) "2340.00"
            ["currency"]=>
            string(3) "TWD"
            ["details"]=>
            array(3) {
              ["subtotal"]=>
              string(7) "2310.00"
              ["tax"]=>
              string(4) "0.00"
              ["shipping"]=>
              string(5) "30.00"
            }
          }
          ["payee"]=>
          array(1) {
            ["email"]=>
            string(35) "jaypatel512-facilitator@hotmail.com"
          }
          ["description"]=>
          string(19) "Payment description"
          ["invoice_number"]=>
          string(13) "5655a0adceedf"
          ["item_list"]=>
          array(2) {
            ["items"]=>
            array(3) {
              [0]=>
              array(5) {
                ["name"]=>
                string(2) "25"
                ["sku"]=>
                string(2) "11"
                ["price"]=>
                string(6) "529.00"
                ["currency"]=>
                string(3) "TWD"
                ["quantity"]=>
                int(3)
              }
              [1]=>
              array(5) {
                ["name"]=>
                string(13) "Warrior Model"
                ["sku"]=>
                string(2) "15"
                ["price"]=>
                string(6) "180.00"
                ["currency"]=>
                string(3) "TWD"
                ["quantity"]=>
                int(1)
              }
              [2]=>
              array(5) {
                ["name"]=>
                string(7) "dim_sum"
                ["sku"]=>
                string(2) "22"
                ["price"]=>
                string(6) "543.00"
                ["currency"]=>
                string(3) "TWD"
                ["quantity"]=>
                int(1)
              }
            }
            ["shipping_address"]=>
            array(7) {
              ["recipient_name"]=>
              string(16) "test facilitator"
              ["line1"]=>
              string(22) "88 Des Voeux Road West"
              ["line2"]=>
              string(6) "3F 520"
              ["city"]=>
              string(9) "Hong Kong"
              ["state"]=>
              string(9) "Hong Kong"
              ["postal_code"]=>
              string(6) "000000"
              ["country_code"]=>
              string(2) "HK"
            }
          }
          ["related_resources"]=>
          array(0) {
          }
        }
      }
      ["redirect_urls"]=>
      array(2) {
        ["return_url"]=>
        string(97) "..."
        ["cancel_url"]=>
        string(59) "..."
      }
      ["create_time"]=>
      string(20) "2015-11-25T11:51:10Z"
      ["update_time"]=>
      string(20) "2015-11-25T11:51:10Z"
      ["links"]=>
      array(3) {
        [0]=>
        array(3) {
          ["href"]=>
          string(79) "..."
          ["rel"]=>
          string(4) "self"
          ["method"]=>
          string(3) "GET"
        }
        [1]=>
        array(3) {
          ["href"]=>
          string(87) ".../execute"
          ["rel"]=>
          string(7) "execute"
          ["method"]=>
          string(4) "POST"
        }
        [2]=>
        array(3) {
          ["href"]=>
          string(94) "..."
          ["rel"]=>
          string(12) "approval_url"
          ["method"]=>
          string(8) "REDIRECT"
        }
      }
    }
EN

回答 2

Stack Overflow用户

发布于 2015-11-26 01:00:13

一旦您执行付款,您将得到一个sale=>id。这就是你用来退款的id。

它还将在transactions=>related_resources=>links下为您包含一个完整的URI,其'rel‘值为'refund’。

来源:https://developer.paypal.com/docs/api/#refunds

票数 0
EN

Stack Overflow用户

发布于 2015-11-26 22:22:56

每次支付都会产生一个sale_id,例如4CFG677234DFG234F。此ID将用于退款。

不要把付款id和sale_id搞混了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33916763

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档