首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在drupal中使用uc_paypal.modue的贝宝退款

在drupal中使用uc_paypal.modue的贝宝退款
EN

Stack Overflow用户
提问于 2022-12-03 19:56:42
回答 1查看 17关注 0票数 0

drupal有一个名为uc_paypal.module的模块,它包含代码的这一部分。

代码语言:javascript
运行
复制
// Sends a request to PayPal and returns a response array.
function uc_paypal_api_request($request, $server) {
  $request['USER'] = variable_get('uc_paypal_api_username', '');
  $request['PWD'] = variable_get('uc_paypal_api_password', '');
  $request['VERSION'] = '3.0';
  $request['SIGNATURE'] = variable_get('uc_paypal_api_signature', '');

  $data = '';
  foreach ($request as $key => $value) {
    $data .= $key .'='. urlencode(ereg_replace(',', '', $value)) .'&';
  }
  $data = substr($data, 0, -1);

  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $server);
  curl_setopt($ch, CURLOPT_VERBOSE, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_NOPROGRESS, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION,0);
  $response = curl_exec($ch);
  if ($error = curl_error($ch)) {
    watchdog('uc_paypal', $error, WATCHDOG_ERROR);
  }
  curl_close($ch);

  return _uc_paypal_nvp_to_array($response);

}

我想做的是创建一个链接按钮,可以退款一个完整的订单。

我找到了这个API代码示例。

代码语言:javascript
运行
复制
curl -v -X POST https://api-m.sandbox.paypal.com/v2/payments/captures/2GG279541U471931P/refund \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <Access-Token>" \
-H "PayPal-Request-Id: 123e4567-e89b-12d3-a456-426655440020" \
-d '{
  "amount": {
    "value": "10.00",
    "currency_code": "USD"
  },
  "invoice_id": "INVOICE-123",
  "note_to_payer": "DefectiveProduct",
  "payment_instruction": {
    "platform_fees": [
      {
        "amount": {
          "currency_code": "USD",
          "value": "1.00"
        }
      }
    ]
  }
}'

我想要做的是使用下面的代码从数据库中加载数据,以获得订单的TxnId。

代码语言:javascript
运行
复制
$result = db_query("SELECT order_id, txn_id 
FROM uc_payment_paypal_ipn WHERE status = 'Completed' AND uid = %d AND order_id = %d", $uid, $order->order_id);

并加入所有三个项目到一个PHP调用Paypal,以退款的订单。我只是不知道怎么把这些密码连在一起。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-12-03 20:01:29

该代码示例用于当前REST,它使用客户端和机密进行身份验证,以首先获得访问令牌。

uc_paypal.module使用更老的(15+年份)经典的NVP,它使用用户PWD签名进行身份验证。

通常,将非常老的API和当前的API混合使用并不是一个好主意。下面是API引用用于典型的API RefundTransaction调用。

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

https://stackoverflow.com/questions/74670206

复制
相关文章

相似问题

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