创建 Refund 对象

通过发起一次退款请求创建一个新的 refund 对象,只能对已经发生交易并且没有全额退款的 charge 对象发起退款。当进行全额退款之前,可以进行多次退款,直至全额退款。当一次退款成功后,会发送 Webhooks 通知。

请求参数描述
CHARGE_ID required string支付 charge 对象的 id,该参数仅需要填写在请求地址内。
description required string退款详情,最多 255 个 Unicode 字符。针对 cmb_wallet & cmb_pc_qr 渠道最多支持 99 字节;针对 jdpay_wap 渠道最多支持 128 字节;针对 paypal 渠道最多支持 30 字节;针对 coolcredit 渠道最多支持 100 Unicode 字符。
amount optional,int退款金额大于 0, 单位为对应币种的最小货币单位,例如:人民币为分(如退款金额为 1 元,此处请填 100)。必须小于等于可退款金额,默认为全额退款。
metadata optional,hash参考元数据
funding_source optional string微信及 QQ 类退款资金来源。取值范围:unsettled_funds:使用未结算资金退款;recharge_funds:微信-使用可用余额退款,QQ-使用可用现金账户资金退款。注:默认值 unsettled_funds,该参数对于微信渠道的退款来说仅适用于微信老资金流商户使用,包括 wxwx_pubwx_pub_qrwx_litewx_wapwx_pub_scan 六个渠道;新资金流退款资金默认从基本账户中扣除。该参数仅在请求退款,传入该字段时返回。
extra conditional退款 extra 参数。split_fund_info 参数仅在使用 cb_alipay、cb_alipay_wap、cb_alipay_pc_direct 渠道时,需要按分账列表进行退款时传入,详见下方 extra 参数说明;raterefund_amount 参数仅在使用 cb_alipay_qr、cb_alipay_scan 渠道时需要传入。
extra 参数描述
split_fund_info optional, array分账列表,上送格式为: [{"account": "2088866088886666","amount": 1,"desc": "split_desc desc"}] ,详情参考下方 split_fund_info 参数说明
rate optional, float退款费率
refund_amount optional, int退款退还的人民币金额
hide_reason optional, boolean隐藏退款原因,仅支持微信支付渠道: wxwx_wapwx_pubwx_pub_qrwx_pub_scanwx_lite

split_fund_info 参数说明

参数说明
account required string接受分账资金的支付宝账户ID
amount required string分账的金额
desc optional, string分账描述信息

返回

如果发起退款成功,返回一个退款 refund 对象。如果发生错误,则会返回错误码和错误详情,详见 错误

定义

POST https://api.pingxx.com/v1/charges/{CHARGE_ID}/refunds
$ch = \Pingpp\Charge::retrieve({CHARGE_ID});
$re = $ch->refunds->create();
refund = Refund.create(this.charge, params);
ch = Pingpp::Charge.retrieve({CHARGE_ID})
re = ch.refunds.create
pingpp.charges.createRefund(
  {CHARGE_ID},
  {},
  function(err, refund) {
   }
);
ch = pingpp.Charge.retrieve('CHARGE_ID')
re = ch.refunds.create(description='desc', amount=1)
re, err := refund.New("CHARGE_ID", &RefundParams)
create(String chId, Dictionary<String, Object> params)

请求示例

curl https://api.pingxx.com/v1/charges/ch_L8qn10mLmr1GS8e5OODmHaL4/refunds \
-u sk_test_ibbTe5jLGCi5rzfH4OqPW9KC: \
-d description="Refund Description" \
-X POST
\Pingpp\Pingpp::setApiKey('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC');

$ch = \Pingpp\Charge::retrieve('ch_L8qn10mLmr1GS8e5OODmHaL4');
$re = $ch->refunds->create(array('description'=>'Refund Description'));
public Refund refund(Integer amount) {
  if (charge == null) {
      return null;
  }
  Refund refund = null;
  Map<String, Object> params = new HashMap<String, Object>();
  params.put("description", "苹果被咬了一口。");
  params.put("amount", amount);// 退款的金额, 单位为对应币种的最小货币单位,例如:人民币为分(如退款金额为 1 元,此处请填 100)。必须小于等于可退款金额,默认为全额退款

  try {
      refund = Refund.create(this.charge, params);
      System.out.println(refund);
  } catch (AuthenticationException e) {
      e.printStackTrace();
  } catch (InvalidRequestException e) {
      e.printStackTrace();
  } catch (APIConnectionException e) {
      e.printStackTrace();
  } catch (APIException e) {
      e.printStackTrace();
  } catch (ChannelException e) {
      e.printStackTrace();
  } catch (RateLimitException e) {
      e.printStackTrace();
  }
    return refund;
  }
Pingpp.api_key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"
ch = Pingpp::Charge.retrieve("ch_L8qn10mLmr1GS8e5OODmHaL4")
re = ch.refunds.create(:description => "Refund Description")
var pingpp = require('pingpp')('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC')
pingpp.charges.createRefund(
   "ch_L8qn10mLmr1GS8e5OODmHaL4",
   { description: "Refund Description" },
   function(err, refund) {
     // 异步调用
   }
);
pingpp.api_key = 'sk_test_ibbTe5jLGCi5rzfH4OqPW9KC'
ch = pingpp.Charge.retrieve('ch_L8qn10mLmr1GS8e5OODmHaL4')
re = ch.refunds.create(description='Refund Description', amount=1)
pingpp.Key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"
refundParams := &pingpp.RefundParams{
Description: "Refund Description",
}
//charge_id 为待退款的 Charge 的 ID
refund, err := refund.New("ch_L8qn10mLmr1GS8e5OODmHaL4", refundParams)
Dictionary<String, Object> params = new Dictionary<String, Object>();
params.Add("amount", 100);
params.Add("description", "Your Description");
 try {
     Refund re = Refund.create(chId, params);
     Console.WriteLine(re);
 } catch (Exception e) {
     Console.WriteLine(e.Message.ToString());
 }

返回示例

{
  "id": "re_y1u944PmfnrTHyvnL0nD0iD1",
  "object": "refund",
  "order_no": "y1u944PmfnrTHyvnL0nD0iD1",
  "amount": 1,
  "created": 1409634160,
  "succeed": true,
  "status": "succeeded",
  "time_succeed": 1409634192,
  "description": "Refund Description",
  "failure_code": null,
  "failure_msg": null,
  "metadata": {},
  "charge": "ch_L8qn10mLmr1GS8e5OODmHaL4",
  "charge_order_no": "123456789",
  "transaction_no": "2004450349201512090096425284",
  "funding_source": null,
  "extra": {}
}