Skip to content

Commit

Permalink
Merge pull request #9 from corean/main
Browse files Browse the repository at this point in the history
laravel 10 migrate
  • Loading branch information
getsolaris authored Jan 15, 2024
2 parents 7d7877e + c727eb2 commit c188bff
Show file tree
Hide file tree
Showing 11 changed files with 131 additions and 264 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0"
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
Expand Down Expand Up @@ -52,4 +52,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
119 changes: 39 additions & 80 deletions src/Attributes/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,59 +10,16 @@

class Billing extends TossPayments implements AttributeInterface
{
/**
* @var string
*/
protected string $uri;

/**
* @var string
*/
protected string $customerKey;

/**
* @var string
*/
protected string $cardNumber;

/**
* @var string
*/
protected string $cardExpirationYear;

/**
* @var string
*/
protected string $cardExpirationMonth;

/**
* @var string
*/
protected string $customerIdentityNumber;

/**
* @var string
*/
protected string $authKey;

/**
* @var string
*/
protected string $billingKey;

/**
* @var int
*/
protected int $amount;

/**
* @var string
*/
protected string $orderName;

/**
* @var string
*/
protected string $orderId;

public function __construct()
Expand All @@ -82,21 +39,21 @@ public function initializeUri(): static
}

/**
* @param string|null $endpoint
* @param bool $withUri
* @param string|null $endpoint
* @param bool $withUri
* @return string
*/
public function createEndpoint(?string $endpoint, bool $withUri = true): string
{
if ($withUri) {
return $this->url.$this->uri.$this->start($endpoint);
return $this->url . $this->uri . $this->start($endpoint);
}

return $this->url.$this->start($endpoint);
return $this->url . $this->start($endpoint);
}

/**
* @param string $customerKey
* @param string $customerKey
* @return $this
*/
public function customerKey(string $customerKey): static
Expand All @@ -107,7 +64,7 @@ public function customerKey(string $customerKey): static
}

/**
* @param string $cardNumber
* @param string $cardNumber
* @return $this
*/
public function cardNumber(string $cardNumber): static
Expand All @@ -118,7 +75,7 @@ public function cardNumber(string $cardNumber): static
}

/**
* @param string $cardExpirationYear
* @param string $cardExpirationYear
* @return $this
*/
public function cardExpirationYear(string $cardExpirationYear): static
Expand All @@ -129,7 +86,7 @@ public function cardExpirationYear(string $cardExpirationYear): static
}

/**
* @param string $cardExpirationMonth
* @param string $cardExpirationMonth
* @return $this
*/
public function cardExpirationMonth(string $cardExpirationMonth): static
Expand All @@ -140,7 +97,7 @@ public function cardExpirationMonth(string $cardExpirationMonth): static
}

/**
* @param string $customerIdentityNumber
* @param string $customerIdentityNumber
* @return $this
*/
public function customerIdentityNumber(string $customerIdentityNumber)
Expand All @@ -151,18 +108,19 @@ public function customerIdentityNumber(string $customerIdentityNumber)
}

/**
* @param string|null $cardPassword
* @param string|null $customerName
* @param string|null $customerEmail
* @param Vbv|null $vbv
* @param string|null $cardPassword
* @param string|null $customerName
* @param string|null $customerEmail
* @param Vbv|null $vbv
* @return PromiseInterface|Response
*/
public function authorizationsCard(
?string $cardPassword = null,
?string $customerName = null,
?string $customerEmail = null,
?Vbv $vbv = null
): PromiseInterface|Response {
?Vbv $vbv = null
): PromiseInterface|Response
{
$parameters = [];
if ($cardPassword) {
$parameters['cardPassword'] = $cardPassword;
Expand All @@ -177,16 +135,16 @@ public function authorizationsCard(
}

if ($vbv) {
$parameters['vbv'] = (array) $vbv;
$parameters['vbv'] = (array)$vbv;
}

return $this->client->post($this->createEndpoint('/authorizations/card'), [
'customerKey' => $this->customerKey,
'cardNumber' => $this->cardNumber,
'cardExpirationYear' => $this->cardExpirationYear,
'cardExpirationMonth' => $this->cardExpirationMonth,
'customerIdentityNumber' => $this->customerIdentityNumber,
] + $parameters);
'customerKey' => $this->customerKey,
'cardNumber' => $this->cardNumber,
'cardExpirationYear' => $this->cardExpirationYear,
'cardExpirationMonth' => $this->cardExpirationMonth,
'customerIdentityNumber' => $this->customerIdentityNumber,
] + $parameters);
}

/**
Expand All @@ -201,7 +159,7 @@ public function authorizationsIssue(): PromiseInterface|Response
}

/**
* @param string $billingKey
* @param string $billingKey
* @return $this
*/
public function billingKey(string $billingKey): static
Expand Down Expand Up @@ -233,20 +191,21 @@ public function orderName(string $orderName): static
}

/**
* @param string|null $customerEmail
* @param string|null $customerName
* @param string|null $customerMobilePhone
* @param int|null $taxFreeAmount
* @param int|null $cardInstallmentPlan
* @param string|null $customerEmail
* @param string|null $customerName
* @param string|null $customerMobilePhone
* @param int|null $taxFreeAmount
* @param int|null $cardInstallmentPlan
* @return PromiseInterface|Response
*/
public function request(
?string $customerEmail = null,
?string $customerName = null,
?string $customerMobilePhone = null,
?int $taxFreeAmount = null,
?int $cardInstallmentPlan = null
): PromiseInterface|Response {
?int $taxFreeAmount = null,
?int $cardInstallmentPlan = null
): PromiseInterface|Response
{
$parameters = [];
if ($customerEmail) {
$parameters['customerEmail'] = $customerEmail;
Expand All @@ -268,11 +227,11 @@ public function request(
$parameters['cardInstallmentPlan'] = $cardInstallmentPlan;
}

return $this->client->post($this->createEndpoint('/'.$this->billingKey), [
'amount' => $this->amount,
'customerKey' => $this->customerKey,
'orderId' => $this->orderId,
'orderName' => $this->orderName,
] + $parameters);
return $this->client->post($this->createEndpoint('/' . $this->billingKey), [
'amount' => $this->amount,
'customerKey' => $this->customerKey,
'orderId' => $this->orderId,
'orderName' => $this->orderName,
] + $parameters);
}
}
Loading

0 comments on commit c188bff

Please sign in to comment.