撤销 Charge 对象

针对已经创建的 Charge,你可以调用撤销接口进行交易的关闭。接口支持对于未支付的 Charge 对象,发起撤销。 撤销接口支持如下支付渠道: alipayalipay_qralipay_litealipay_scanupacpupacp_pcupacp_wapupacp_scanwxwx_wapwx_litewx_pubwx_pub_qrwx_pub_scancb_wx_pub_scanalipay_scancb_alipay_scanisv_scanisv_wapisv_qr

注: 1、upacp_scanwx_pub_scancb_wx_pub_scanalipay_scancb_alipay_scanisv_scanisv_wapisv_qr 渠道支付的 Charge 对象,支持在已支付的状态下,调用撤销接口。对于成功付款的订单请使用 退款 接口进行退款处理。只有针对未支付的订单,我们建议你调用撤销接口。(如果是Order订单关联的 Charge 对象,使用这些渠道支付时,也仅支持对未支付的 Charge 对象,发起撤销。)

2、wx_pub_scancb_wx_pub_scan 渠道可在交易产生 7 天内调用撤销接口; wx、wx_wapwx_litewx_pubwx_pub_qr 渠道,官方建议在创建 Charge 后,不要立即发起撤销; upacpupacp_pcupacp_wapupacp_scan 渠道,仅支持在创建Charge 的同一天(即前日 23:00 至本日 23:00 之间)内调用撤销接口; alipay_scan 渠道可在交易产生 24 小时内调用撤销接口; isv_scanisv_wapisv_qr渠道可在交易产生当天调用撤销接口;

请求参数描述
CHARGE_ID required stringcharge 对象 ID,该参数仅需要填写在请求地址内。

返回

返回一个 charge 对象。如果发生错误,则会返回错误码和错误详情,详见 错误

定义

POST /v1/charges/{CHARGE_ID}/reverse
\Pingpp\Charge::reverse();
Charge.reverse();
Pingpp::Charge.reverse();
pingpp.charges.reverse();
pingpp.Charge.reverse()
ch,err := charge.Reverse()
Charge.Reverse();

请求示例

curl https://api.pingxx.com/v1/charges/ch_injTG4KGWPePS88WPGPyfzz5/reverse \
-H "Pingplusplus-Signature: SIGNATURE" \
-H "Pingplusplus-Request-Timestamp: 1475029155" \
-H "Content-Type: application/json" \
-u sk_test_ibbTe5jLGCi5rzfH4OqPW9KC:
-d '{}'
\Pingpp\Pingpp::setApiKey('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC');

$charge_id = 'ch_bTyjfTnzHCaHOyjbzP4mHmX1';
try {
    $charge = \Pingpp\Charge::reverse($charge_id);
    echo $charge;
} catch (\Pingpp\Error\Base $e) {
    if ($e->getHttpStatus() != null) {
        header('Status: ' . $e->getHttpStatus());
        echo $e->getHttpBody();
    } else {
        echo $e->getMessage();
    }
}
Pingpp.apiKey = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC";

public Charge reverse(String id) {
    Charge charge = null;
    try {
        charge = Charge.reverse(id);
        System.out.println(charge);
    } catch (PingppException e) {
        e.printStackTrace();
    }

    return charge;
}
require "pingpp"
Pingpp.api_key = "sk_test_ibbTe5jLGCi5rzfH4OqPW9KC"

ch = Pingpp::Charge.reverse("ch_en9e9O90S080SCyrfPr10y5S")
puts ch
var pingpp = require('pingpp')('sk_test_ibbTe5jLGCi5rzfH4OqPW9KC');
pingpp.charges.reverse(
  'ch_ynT0uT5OmnHOTuDy90D8C44S',
  {},
  function(err, charge) {
    if (err != null){
      console.log(err);
    } else {
      console.log(charge);
    }
    // YOUR CODE
  }
);
print "撤销Charge对象:"
try:
    charge_info = pingpp.Charge.reverse('ch_Civ1O8880Wf1KmbPCCGujf5S')
    print(charge_info)
except Exception as e:
    print e.http_body
func ExampleCharge_reverse() {
	ch, err := charge.Reverse("ch_bTyjfTnzHCaHOyjbzP4mHmX1")
	if err != nil {
		log.Fatal(err)
	}
	chstring, _ := json.Marshal(ch)
	log.Printf("%v\n", string(chstring))
}
public static Charge ChargeReverse(string chargeId)
{
    return Charge.Reverse(chargeId);
}

返回示例

{
  "id": "ch_injTG4KGWPePS88WPGPyfzz5",
  "object": "charge",
  "created": 1495694197,
  "livemode": true,
  "paid": true,
  "refunded": false,
  "reversed": true,
  "app": "app_4OOi9SGuD88GGqbL",
  "channel": "isv_scan",
  "order_no": "149569419725834",
  "client_ip": "127.0.0.1",
  "amount": 1,
  "amount_settle": 1,
  "currency": "cny",
  "subject": "cm isv_scan",
  "body": "cm isv_scan",
  "extra": {
    "scan_code": "130141564083799183",
    "terminal_id": "00000001",
    "pay_channel": "wx",
    "buyer_account": "omYJss9x8g2TzmrxnUtrOr7qWhwc",
    "chcd_discount": "0.00",
    "mer_discount": "0.00"
  },
  "time_paid": 1495694546,
  "time_expire": 1495780597,
  "time_settle": null,
  "transaction_no": "4002362001201705252516756579",
  "refunds": {
    "object": "list",
    "url": "/v1/charges/ch_injTG4KGWPePS88WPGPyfzz5/refunds",
    "has_more": false,
    "data": []
  },
  "amount_refunded": 0,
  "failure_code": null,
  "failure_msg": null,
  "metadata": {},
  "credential": {},
  "description": null
}