ShopPlatform.Web 1.0.0.0
농산물, 소프트웨어 라이선스와 개발 용역을 직접 판매하는 CodeMaru 직영 쇼핑몰입니다.
로딩중...
검색중...
일치하는것 없음
ShopPlatform.Payments.TossPaymentGateway 클래스 참조sealed

더 자세히 ...

ShopPlatform.Payments.TossPaymentGateway에 대한 상속 다이어그램 :
ShopPlatform.Payments.TossPaymentGateway에 대한 협력 다이어그램:

Public 멤버 함수

 TossPaymentGateway (HttpClient http, ShopPaymentConfig config, PaymentKeyProtector protector)
Task< PaymentStartResultStartAsync (string orderNo, decimal amount, string customerName)
async Task< PaymentConfirmResultConfirmAsync (string paymentKey, string orderId, int amount)

Private 속성

readonly HttpClient _http
readonly ShopPaymentConfig _config
readonly PaymentKeyProtector _protector

정적 Private 속성

const string ApiBase = "https://api.tosspayments.com/v1"

상세한 설명

토스페이먼츠 V2 구현. 테넌트별 키 사용.

TossPaymentGateway.cs 파일의 17 번째 라인에서 정의되었습니다.

생성자 & 소멸자 문서화

◆ TossPaymentGateway()

ShopPlatform.Payments.TossPaymentGateway.TossPaymentGateway ( HttpClient http,
ShopPaymentConfig config,
PaymentKeyProtector protector )
inline

지정한 설정으로 TossPaymentGateway 클래스의 새 인스턴스를 초기화합니다.

매개변수
httphttp에 사용할 HttpClient 값입니다.
configconfig에 사용할 ShopPaymentConfig 값입니다.
protectorprotector에 사용할 PaymentKeyProtector 값입니다.

TossPaymentGateway.cs 파일의 89 번째 라인에서 정의되었습니다.

90 {
91 _http = http;
92 _config = config;
93 _protector = protector;
94 }

다음을 참조함 : _config, _http, _protector.

멤버 함수 문서화

◆ ConfirmAsync()

async Task< PaymentConfirmResult > ShopPlatform.Payments.TossPaymentGateway.ConfirmAsync ( string paymentKey,
string orderId,
int amount )
inline

Confirm Async 작업을 수행합니다.

매개변수
paymentKeypayment Key에 사용할 string 값입니다.
orderIdorder Id에 사용할 string 값입니다.
amountamount에 사용할 int 값입니다.
반환값
Confirm Async 작업에서 생성한 Task<PaymentConfirmResult> 결과입니다.

ShopPlatform.Payments.IPaymentGateway를 구현.

TossPaymentGateway.cs 파일의 189 번째 라인에서 정의되었습니다.

190 {
191 var secretKey = _protector.Unprotect(_config.TossSecretKeyEncrypted);
192 if (string.IsNullOrEmpty(secretKey))
193 return new PaymentConfirmResult { Succeeded = false, Error = "결제 키가 설정되지 않았습니다." };
194
195 var encoded = Convert.ToBase64String(Encoding.UTF8.GetBytes($"{secretKey}:"));
196 var req = new HttpRequestMessage(HttpMethod.Post, $"{ApiBase}/payments/confirm");
197 req.Headers.Authorization = new AuthenticationHeaderValue("Basic", encoded);
198 req.Content = new StringContent(
199 JsonSerializer.Serialize(new { paymentKey, orderId, amount }),
200 Encoding.UTF8, "application/json");
201
202 var resp = await _http.SendAsync(req);
203 var body = await resp.Content.ReadAsStringAsync();
204
205 if (!resp.IsSuccessStatusCode)
206 return new PaymentConfirmResult { Succeeded = false, Error = body };
207
208 using var doc = JsonDocument.Parse(body);
209 var txId = doc.RootElement.TryGetProperty("paymentKey", out var pk) ? pk.GetString() : null;
210 return new PaymentConfirmResult { Succeeded = true, TransactionId = txId };
211 }

다음을 참조함 : _config, _http, _protector.

◆ StartAsync()

Task< PaymentStartResult > ShopPlatform.Payments.TossPaymentGateway.StartAsync ( string orderNo,
decimal amount,
string customerName )
inline

Start Async 작업을 수행합니다.

매개변수
orderNoorder No에 사용할 string 값입니다.
amountamount에 사용할 decimal 값입니다.
customerNamecustomer Name에 사용할 string 값입니다.
반환값
Start Async 작업에서 생성한 Task<PaymentStartResult> 결과입니다.

ShopPlatform.Payments.IPaymentGateway를 구현.

TossPaymentGateway.cs 파일의 136 번째 라인에서 정의되었습니다.

137 {
138 return Task.FromResult(new PaymentStartResult
139 {
140 OrderId = orderNo,
141 OrderNo = orderNo,
142 Amount = amount,
143 ClientKey = _config.TossClientKey,
144 SuccessUrl = _config.SuccessReturnUrl,
145 FailUrl = _config.FailReturnUrl
146 });
147 }

다음을 참조함 : _config.

멤버 데이터 문서화

◆ _config

readonly ShopPaymentConfig ShopPlatform.Payments.TossPaymentGateway._config
private

config 값을 보관합니다.

TossPaymentGateway.cs 파일의 46 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConfirmAsync(), StartAsync(), TossPaymentGateway().

◆ _http

readonly HttpClient ShopPlatform.Payments.TossPaymentGateway._http
private

http 값을 보관합니다.

TossPaymentGateway.cs 파일의 37 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConfirmAsync(), TossPaymentGateway().

◆ _protector

readonly PaymentKeyProtector ShopPlatform.Payments.TossPaymentGateway._protector
private

protector 값을 보관합니다.

TossPaymentGateway.cs 파일의 55 번째 라인에서 정의되었습니다.

다음에 의해서 참조됨 : ConfirmAsync(), TossPaymentGateway().

◆ ApiBase

const string ShopPlatform.Payments.TossPaymentGateway.ApiBase = "https://api.tosspayments.com/v1"
staticprivate

Api Base 값을 보관합니다.

TossPaymentGateway.cs 파일의 27 번째 라인에서 정의되었습니다.


이 클래스에 대한 문서화 페이지는 다음의 파일로부터 생성되었습니다.: