튜토리얼
Delphi 개발환경에서 팝빌 SDK를 추가하고, 팩스 전송 (SendFAX) API를 호출하는 기본 과정을 단계별로 따라 해볼 수 있도록 구성된 가이드 입니다.
1. POPBiLL SDK 추가
팝빌 연동자료실에서 Delphi SDK 예제코드 다운로드 후 압축을 해제합니다.
압축해제한 SDK 예제코드에서 Linkhub/ Popbill/ PopbillTaxinvoice/ 각 폴더의 pas파일 3개를 프로젝트 유닛으로 추가합니다.
2. POPBiLL SDK 설정
아래 코드를 참조하여 Form 파일을 수정합니다.
- ① use 참조유닛 추가
- ② 인증정보 변수와 서비스 클래스를 선언
- ③ FormCreate 프로시저에 팩스 서비스 클래스 인스턴스 생성 및 초기화
unit Example;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, TypInfo, shellapi, ExtCtrls, Grids,
Popbill, PopbillFax;
const
// 링크아이디
LinkID = 'TESTER';
// 비밀키
SecretKey = 'SwWxqU+0TErBXy/9TVjIPEnI0VTUMMSQZtJf3Ed8q3I=';
// 생략
// ...
// ...
var
// 팩스 서비스 객체 선언
faxService : TFaxService;
// 생략
// ...
// ...
procedure TfrmExample.FormCreate(Sender: TObject);
begin
// 팩스 서비스 객체 초기화
faxService := TFaxService.Create(LinkID,SecretKey);
// 연동환경 설정, true-테스트, false-운영(Production), (기본값:false)
faxService.IsTest := true;
// 인증토큰 IP 검증 설정, true-사용, false-미사용, (기본값:true)
faxService.IPRestrictOnOff := true;
// 예외 처리 설정, true-사용, false-미사용, (기본값:true)
faxService.IsThrowException := true;
// 로컬시스템 시간 사용여부, true-사용, false-미사용, (기본값:false)
faxService.UseLocalTimeYN := false;
end;
3. SendFAX 기능 구현
Form에 버튼을 생성하고 버튼의 Click Event 코드에 팩스 전송 (SendFAX) 함수를 추가합니다.
procedure TfrmExample.btnSendFax_singleClick(Sender: TObject);
var
filePath, receiptNum, senderNum, senderName, receiverNum, receiverName,
title, requestNum : string;
adsYN : Boolean;
corpNum : String;
reserveDT : String;
userID : String;
begin
if OpenDialog1.Execute then begin
filePath := OpenDialog1.FileName;
end else begin
Exit;
end;
// 팝빌회원 사업자번호
corpNum := '1234567890';
// 팝빌회원 아이디
userID := 'testkorea';
// 발신번호
senderNum := '07043042992';
// 발신자명
senderName := '발신자명';
// 수신팩스번호
receiverNum := '070111222';
// 수신자명
receiverName := '수신자명';
// 광고팩스 전송여부
adsYN := False;
// 팩스제목
title := '팩스 단건전송 제목';
// 요청번호
// 파트너가 전송 건에 대해 관리번호를 구성하여 관리하는 경우 사용.
// 1~36자리로 구성. 영문, 숫자, 하이픈(-), 언더바(_)를 조합하여 팝빌 회원별로 중복되지 않도록 할당.
requestNum := '';
try
receiptNum := faxService.SendFAX(corpNum, senderNum,
senderName, receiverNum,
receiverName, filePath,
reserveDT, userID,
adsYN, title,
requestNum);
except
on le : EPopbillException do begin
ShowMessage('응답코드 : ' + IntToStr(le.code) + #10#13 +'응답메시지 : '+ le.Message);
Exit;
end;
end;
if faxService.LastErrCode <> 0 then
begin
ShowMessage('응답코드 : ' + IntToStr(faxService.LastErrCode) + #10#13 +'응답메시지 : '+ faxService.LastErrMessage);
end
else
begin
txtReceiptNum.Text := receiptNum;
ShowMessage('접수번호(receiptNum) :' + receiptNum);
end;
end;
4. API 응답결과 확인
API 호출 응답결과는 다음과 같습니다.
| 구분 | 응답 |
| 성공 | ReceiptNum(접수번호) : 18자리 문자열 |
| 실패 |
code : 오류코드 (8자리 음의 정수) [오류코드] message : 오류메시지 |












