const crypto = require('crypto');
const { URLSearchParams } = require('url');
function GenerateSignature(requestObj, secretKey) {
const params = new URLSearchParams();
params.append('amount', requestObj.Amount);
params.append('currency', requestObj.Currency);
params.append('failure_url', requestObj.FailureUrl);
params.append('merchant_order_id', requestObj.MerchantOrderId);
params.append('client_key', requestObj.ClientKey);
params.append('success_url', requestObj.SuccessUrl);
params.sort();
const message = params.toString();
const hashValue = crypto.createHmac('sha256', secretKey).update(message).digest('base64');
return hashValue;
}
const crypto = require('crypto');
const { URLSearchParams } = require('url');
//ONDEMAN 타입의 플랜생성 시
function GeneratePlanSignature(requestObj, secretKey) {
const params = new URLSearchParams();
params.append('currency', requestObj.Currency);
params.append('merchant_order_ref', requestObj.MerchantOrderRef);
params.append('client_key', requestObj.ClientKey);
params.sort();
const message = params.toString();
const hashValue = crypto.createHmac('sha256', secretKey).update(message).digest('base64');
return hashValue;
}
//ONDEMAND 타입의 빌링키발급 요청 시
function GenerateSubscribeSignature(requestObj, secretKey) {
const params = new URLSearchParams();
params.append('currency', requestObj.Currency);
params.append('merchant_order_ref', requestObj.MerchantOrderRef);
params.append('client_key', requestObj.ClientKey);
params.append('success_url', requestObj.SuccessUrl);
params.append('failure_url', requestObj.FailureUrl);
params.sort();
const message = params.toString();
const hashValue = crypto.createHmac('sha256', secretKey).update(message).digest('base64');
return hashValue;
}
//ONDEMAND 타입의 비인증결제 요청 시
function GenerateDeductionSignature(requestObj, secretKey) {
const params = new URLSearchParams();
params.append('amount', requestObj.Amount);
params.append('client_key', requestObj.ClientKey);
params.append('currency', requestObj.Currency);
params.append('merchant_order_ref', requestObj.MerchantOrderRef);
params.append('subscription_order_ref', requestObj.SubscriptionOrderRef);
params.sort();
const message = params.toString();
const hashValue = crypto.createHmac('sha256', secretKey).update(message).digest('base64');
return hashValue;
}