package com.ycwl.basic.pay.adapter;

import com.ycwl.basic.pay.entity.CancelOrderRequest;
import com.ycwl.basic.pay.entity.CongMingPayConfig;
import com.ycwl.basic.pay.entity.CreateOrderRequest;
import com.ycwl.basic.pay.entity.CreateOrderResponse;
import com.ycwl.basic.pay.entity.RefundOrderRequest;
import com.ycwl.basic.pay.enums.PayAdapterType;
import org.junit.Test;

public class CongMingPayAdapterTest {
    private CongMingPayAdapter getAdapter() {
        CongMingPayConfig config = new CongMingPayConfig();
        config.setProgramId("202311792173507165");
        config.setShopId("7898ffe6550cc695ce6d31c248ced1a6");
        config.setApiKey("2803188405D8E09930CC47918399D5D9");
        return new CongMingPayAdapter(config);
    }

    @Test
    public void testCreateOrder() {
        CongMingPayAdapter adapter = getAdapter();
        CreateOrderRequest request = new CreateOrderRequest();
        request.setPrice(100);
        request.setOrderNo("1234567890");
        request.setGoodsName("测试订单");
        request.setDescription("测试订单");
        request.setUserIdentify("123456789");
        request.setNotifyUrl("https://www.baidu.com");
        CreateOrderResponse response = adapter.createOrder(request);
        System.out.println(response);
    }

    @Test
    public void testQueryOrder() {
        CongMingPayAdapter adapter = getAdapter();
        adapter.queryOrder("123456789");
    }

    @Test
    public void testRefundOrder() {
        CongMingPayAdapter adapter = getAdapter();
        RefundOrderRequest request = new RefundOrderRequest();
        request.setOrderNo("3993158860935401472");
        request.setRefundNo("3993158860935401472");
        request.setPrice(1);
        request.setRefundPrice(1);
        request.setNotifyUrl("https://www.zhentuai.com/api/mobile/wx/pay/v1/3955650120997015552/payNotify");
        adapter.refund(request);
    }

    @Test
    public void testCancelOrder() {
        CongMingPayAdapter adapter = getAdapter();
        CancelOrderRequest request = new CancelOrderRequest();
        request.setOrderNo("123456789");
        adapter.cancelOrder(request);
    }

    @Test
    public void testA() {
        PayAdapterType.valueOf("CONG_MING_PAY");
    }
}