package com.diaoyun.zion;

import com.egzosn.pay.common.api.PayService;
import com.egzosn.pay.common.bean.CurType;
import com.egzosn.pay.common.bean.MethodType;
import com.egzosn.pay.common.bean.PayOrder;
import com.egzosn.pay.common.http.HttpConfigStorage;
import com.egzosn.pay.paypal.api.PayPalConfigStorage;
import com.egzosn.pay.paypal.api.PayPalPayService;
import com.egzosn.pay.paypal.bean.PayPalTransactionType;


import javax.servlet.http.HttpServletRequest;
import java.awt.image.BufferedImage;
import java.math.BigDecimal;
import java.util.Map;
import java.util.UUID;

/**
 *
 *
 * 微信
 * @author egan
 * @email egzosn@gmail.com
 * @date 2017/8/18
 */
public class PayTest {

    public static void main(String[] args) {
        PayPalConfigStorage storage = new PayPalConfigStorage();
        storage.setClientID("AWbyqn1AKJeVvzNsYms_9fs_LVr5_w5Xyt8nX5q0Wmqoq0NYCZf2wyz9DDeA5ArsWx0LFBwl5Oz6amD2");
        storage.setClientSecret("EFhRjCBzhtI1lf88Xiy3VF07gVpu1vWk0VheSP3n5J0fhQxA6Pu7j89dbyYTLj3FxqiJBOlxQRKG_58e");
        //storage.setTest(true);
        //发起付款后的页面转跳地址
        storage.setReturnUrl("http://127.0.0.1:8083/pay/success");
        //取消按钮转跳地址,这里用异步通知地址的兼容的做法
        storage.setNotifyUrl("http://127.0.0.1:8083/pay/cancel");
        HttpConfigStorage httpConfigStorage = new HttpConfigStorage();

        PayService service = new PayPalPayService(storage);
        BigDecimal price = new BigDecimal("500");
        PayOrder order = new PayOrder("Order_payment:", "Order payment", price, UUID.randomUUID().toString().replace("-", ""), PayPalTransactionType.sale);
        Map orderInfo = service.orderInfo(order);
        service.buildRequest(orderInfo, MethodType.POST);
    }
}
