撤销 Charge 对象

针对已经创建的 Charge,你可以调用撤销接口进行交易的关闭。此接口仅接受 upacp_scanwx_pub_scancb_wx_pub_scanalipay_scancb_alipay_scanisv_scanisv_wapisv_qr 渠道的订单调用。接口支持对于未成功付款的订单进行撤销,则关闭交易。调用此接口后用户后期不能支付成功。

注: 1、wx_pub_scancb_wx_pub_scan 渠道可在交易产生 7 天内调用撤销接口;upacp_scan 渠道可在前日 23:00 至本日 23:00 之间内调用撤销接口;alipay_scan 渠道可在交易产生 24 小时内调用撤销接口;isv_scanisv_wapisv_qr 渠道可在交易产生当天调用撤销接口;

2、对于成功付款的订单请使用 退款 接口进行退款处理。只有针对未支付的订单,我们建议你调用撤销接口。

请求参数描述
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
}