| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CallbackRequest; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest; |
| | | import io.cellulant.model.Payload; |
| | | import io.cellulant.service.CheckoutEncryption; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Tingg支付工具类 |
| | | */ |
| | | @Slf4j |
| | | public class TinggPayUtil { |
| | | |
| | | private static String accessKey = "KxjPP444jEE7K88E7juej4PKqqzKq7qKjKj84q744q9zj4Ej4zK47uj4KKj4"; |
| | | private static String accessKey = "8rc1gTV9n91Tc1Sy9oVWry99fgrgrVV8concf9onWooWSg9TVW8nSgo98g88"; |
| | | |
| | | private static String ivKey = "qsffKsCOJJdhSBCQ"; |
| | | private static String ivKey = "ABp0pqpHMteEJM2N"; |
| | | |
| | | private static String secretKey = "9jjz4Ex74P8ue4qK"; |
| | | private static String secretKey = "rf8Vo1n9yTSW98cg"; |
| | | |
| | | |
| | | /** |
| | |
| | | try { |
| | | CheckoutEncryption checkoutEncrption = new CheckoutEncryption(ivKey, secretKey); |
| | | Payload payload = getPayload(checkoutRequest); |
| | | log.info("支付请求参数:{}", JSON.toJSONString(payload)); |
| | | String param = checkoutEncrption.encrypt(payload); |
| | | System.out.println("Encrpted payload=" + param); |
| | | String url = "https://online.uat.tingg.africa/testing/express/checkout?encrypted_payload=" + param + "&access_key=" + accessKey; |
| | | String url = "https://checkout.tingg.africa/express/checkout?encrypted_payload=" + param + "&access_key=" + accessKey; |
| | | log.info("支付链接:{}", url); |
| | | return ResultUtil.success(url); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String countryCode="GHA";//收取付款的国家的3位ISO代码 |
| | | String currencyCode = "GHS";//3位ISO代码的货币,商家正在开发票。 |
| | | String serviceCode="IGOGHANA";//服务代码 |
| | | String serviceCode="I-GO_TECHNOLOGIES_LI";//服务代码 |
| | | String dueDate = sdf.format(new Date(System.currentTimeMillis() + 1800000));//到期时间 |
| | | String languageCode="EN"; |
| | | String paymentOptionCode = "";//支付选项码 |
| | |
| | | } |
| | | |
| | | |
| | | public static CallbackRequest getRequestParam(HttpServletRequest request) throws IOException { |
| | | // 读取参数 |
| | | InputStream inputStream; |
| | | StringBuilder sb = new StringBuilder(); |
| | | inputStream = request.getInputStream(); |
| | | String s; |
| | | BufferedReader in = new BufferedReader(new InputStreamReader(inputStream, "UTF-8")); |
| | | while ((s = in.readLine()) != null) { |
| | | sb.append(s); |
| | | } |
| | | in.close(); |
| | | inputStream.close(); |
| | | String json = sb.toString(); |
| | | System.err.println("结果-----》" + json); |
| | | CallbackRequest callbackRequest = JSON.parseObject(json, CallbackRequest.class); |
| | | |
| | | return callbackRequest; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | public static void main(String[] ages){ |
| | | CheckoutRequest checkoutRequest = new CheckoutRequest(); |
| | | checkoutRequest.setMsisdn(233240000000L); |
| | | checkoutRequest.setMsisdn(Long.valueOf("233244915521")); |
| | | checkoutRequest.setCustomerEmail("393733352@qq.com"); |
| | | checkoutRequest.setAccountNumber("4111111111111111"); |
| | | checkoutRequest.setCustomerFirstName("zhibing"); |
| | | checkoutRequest.setCustomerLastName("pu"); |
| | | checkoutRequest.setAccountNumber("233244915521"); |
| | | checkoutRequest.setCustomerFirstName("GOU"); |
| | | checkoutRequest.setCustomerLastName("XIONG"); |
| | | checkoutRequest.setRequestAmount(1.00D); |
| | | checkoutRequest.setMerchantTransactionId("123456T"); |
| | | checkoutRequest.setMerchantTransactionId("00030"); |
| | | checkoutRequest.setRequestDescription("payment test"); |
| | | checkoutRequest.setCallbackUrl("https://10pz685243.zicp.fun"); |
| | | checkoutRequest.setPendingRedirectUrl("https://10pz685243.zicp.fun"); |
| | | checkoutRequest.setSuccessRedirectUrl("https://10pz685243.zicp.fun"); |
| | | checkoutRequest.setCallbackUrl("https://10pz685243.zicp.fun/base/IGO/wxCancelUserBalance"); |
| | | checkoutRequest.setPendingRedirectUrl("https://www.baidu.com"); |
| | | checkoutRequest.setSuccessRedirectUrl("https://www.baidu.com"); |
| | | checkoutRequest.setFailRedirectUrl("https://www.baidu.com"); |
| | | ResultUtil resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | System.err.println(JSON.toJSONString(resultUtil)); |