package com.ym.mec.thirdparty.adapay;

import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.payment.Payment;
import com.huifu.adapay.model.refund.Refund;
import com.huifu.adapay.notify.INotifyCallback;
/**
 * @author jane.zhao
 */
public class NotifyCallback implements INotifyCallback {

    /**
     * 用户接收并处理支付成功的异步消息
     * @param payment 成功的支付对象
     * @throws Exception 异常
     */
    @Override
    public void paymentSuccessMessageArrived(Payment payment) throws Exception {
        System.out.println("receive paymentSuccess msg=" + JSON.toJSONString(payment));

    }

    /**
     * 用户接收并处理支付失败的异步消息
     * @param payment 失败的支付对象
     * @throws Exception 异常
     */
    @Override
    public void paymentFailedMessageArrived(Payment payment) throws Exception {
        System.out.println("receive paymentFailed msg=" + JSON.toJSONString(payment));
    }

    /**
     * 用户接收并处理关闭支付交易成功的异步消息
     * @param payment 关闭成功的支付对象
     * @throws Exception 异常
     */
    @Override
    public void paymentCloseSuccessMessageArrived(Payment payment) throws Exception {
        System.out.println("receive paymentCloseSuccess msg=" + JSON.toJSONString(payment));
    }

    /**
     * 用户接收并处理关闭支付交易失败的异步消息
     * @param payment 关闭失败的支付对象
     * @throws Exception 异常
     */
    @Override
    public void paymentCloseFailedMessageArrived(Payment payment) throws Exception {
        System.out.println("receive paymentCloseFailed msg=" + JSON.toJSONString(payment));
    }

    /**
     * 用户接收并处理退款成功的异步消息
     * @param refund 成功的退款对象
     * @throws Exception 异常
     */
    @Override
    public void refundSuccessMessageArrived(Refund refund) throws Exception {
        System.out.println("receive refundSuccess msg=" + JSON.toJSONString(refund));
    }

    /**
     * 用户接收并处理退款失败的异步消息
     * @param refund 失败的退款对象
     * @throws Exception 异常
     */
    @Override
    public void refundFailedMessageArrived(Refund refund) throws Exception {
        System.out.println("receive refundFailed msg=" + JSON.toJSONString(refund));
    }

    /**
     * 用户接收并处理未知的异步消息
     * @param msg 未知消息
     * @throws Exception 异常
     */
    @Override
    public void unknownMessageArrived(String msg) throws Exception {
        System.out.println("receive unknown msg=" + msg);
    }
}
