|
5 | 5 | use Getsolaris\LaravelTossPayments\Contracts\AttributeInterface; |
6 | 6 | use Getsolaris\LaravelTossPayments\Objects\CashReceipt; |
7 | 7 | use Getsolaris\LaravelTossPayments\Objects\RefundReceiveAccount; |
| 8 | +use Getsolaris\LaravelTossPayments\Objects\Vbv; |
8 | 9 | use Getsolaris\LaravelTossPayments\TossPayments; |
9 | 10 | use GuzzleHttp\Promise\PromiseInterface; |
10 | 11 | use Illuminate\Http\Client\Response; |
@@ -46,6 +47,27 @@ class Payment extends TossPayments implements AttributeInterface |
46 | 47 | */ |
47 | 48 | protected string $bank; |
48 | 49 |
|
| 50 | + /** |
| 51 | + * @var string |
| 52 | + */ |
| 53 | + protected string $cardNumber; |
| 54 | + |
| 55 | + /** |
| 56 | + * @var string |
| 57 | + */ |
| 58 | + protected string $cardExpirationYear; |
| 59 | + |
| 60 | + /** |
| 61 | + * @var string |
| 62 | + */ |
| 63 | + protected string $cardExpirationMonth; |
| 64 | + |
| 65 | + /** |
| 66 | + * @var string |
| 67 | + */ |
| 68 | + protected string $customerIdentityNumber; |
| 69 | + |
| 70 | + |
49 | 71 | /** |
50 | 72 | * @var int |
51 | 73 | */ |
@@ -288,4 +310,108 @@ public function virtualAccounts( |
288 | 310 | 'bank' => $this->bank, |
289 | 311 | ] + $parameters); |
290 | 312 | } |
| 313 | + |
| 314 | + /** |
| 315 | + * @param string $cardNumber |
| 316 | + * @return $this |
| 317 | + */ |
| 318 | + public function cardNumber(string $cardNumber): static |
| 319 | + { |
| 320 | + $this->cardNumber = $cardNumber; |
| 321 | + |
| 322 | + return $this; |
| 323 | + } |
| 324 | + |
| 325 | + /** |
| 326 | + * @param string $cardExpirationYear |
| 327 | + * @return $this |
| 328 | + */ |
| 329 | + public function cardExpirationYear(string $cardExpirationYear): static |
| 330 | + { |
| 331 | + $this->cardExpirationYear = $cardExpirationYear; |
| 332 | + |
| 333 | + return $this; |
| 334 | + } |
| 335 | + |
| 336 | + /** |
| 337 | + * @param string $cardExpirationMonth |
| 338 | + * @return $this |
| 339 | + */ |
| 340 | + public function cardExpirationMonth(string $cardExpirationMonth): static |
| 341 | + { |
| 342 | + $this->cardExpirationMonth = $cardExpirationMonth; |
| 343 | + |
| 344 | + return $this; |
| 345 | + } |
| 346 | + |
| 347 | + /** |
| 348 | + * @param string $customerIdentityNumber |
| 349 | + * @return $this |
| 350 | + */ |
| 351 | + public function customerIdentityNumber(string $customerIdentityNumber) |
| 352 | + { |
| 353 | + $this->customerIdentityNumber = $customerIdentityNumber; |
| 354 | + |
| 355 | + return $this; |
| 356 | + } |
| 357 | + |
| 358 | + /** |
| 359 | + * @param string|null $cardPassword |
| 360 | + * @param int|null $cardInstallmentPlan |
| 361 | + * @param bool|null $useFreeInstallmentPlan |
| 362 | + * @param int|null $taxFreeAmount |
| 363 | + * @param string|null $customerEmail |
| 364 | + * @param string|null $customerName |
| 365 | + * @param Vbv|null $vbv |
| 366 | + * @return PromiseInterface|Response |
| 367 | + */ |
| 368 | + public function keyIn( |
| 369 | + ?string $cardPassword = null, |
| 370 | + ?int $cardInstallmentPlan = null, |
| 371 | + ?bool $useFreeInstallmentPlan = null, |
| 372 | + ?int $taxFreeAmount = null, |
| 373 | + ?string $customerEmail = null, |
| 374 | + ?string $customerName = null, |
| 375 | + ?Vbv $vbv = null |
| 376 | + ): PromiseInterface|Response |
| 377 | + { |
| 378 | + $parameters = []; |
| 379 | + if ($cardPassword) { |
| 380 | + $parameters['cardPassword'] = $cardPassword; |
| 381 | + } |
| 382 | + |
| 383 | + if ($cardInstallmentPlan) { |
| 384 | + $parameters['cardInstallmentPlan'] = $cardInstallmentPlan; |
| 385 | + } |
| 386 | + |
| 387 | + if ($useFreeInstallmentPlan) { |
| 388 | + $parameters['useFreeInstallmentPlan'] = $useFreeInstallmentPlan; |
| 389 | + } |
| 390 | + |
| 391 | + if ($taxFreeAmount) { |
| 392 | + $parameters['taxFreeAmount'] = $taxFreeAmount; |
| 393 | + } |
| 394 | + |
| 395 | + if ($customerEmail) { |
| 396 | + $parameters['customerEmail'] = $customerEmail; |
| 397 | + } |
| 398 | + |
| 399 | + if ($customerName) { |
| 400 | + $parameters['customerName'] = $customerName; |
| 401 | + } |
| 402 | + |
| 403 | + if ($vbv) { |
| 404 | + $parameters['vbv'] = (array) $vbv; |
| 405 | + } |
| 406 | + |
| 407 | + return $this->client->post($this->createEndpoint('/key-in'), [ |
| 408 | + 'amount' => $this->amount, |
| 409 | + 'orderId' => $this->orderId, |
| 410 | + 'orderName' => $this->orderName, |
| 411 | + 'cardNumber' => $this->cardNumber, |
| 412 | + 'cardExpirationYear' => $this->cardExpirationYear, |
| 413 | + 'cardExpirationMonth' => $this->cardExpirationMonth, |
| 414 | + 'customerIdentityNumber' => $this->customerIdentityNumber, |
| 415 | + ] + $parameters); |
| 416 | + } |
291 | 417 | } |
0 commit comments