Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

laravel 10 migrate #9

Merged
merged 5 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "getsolaris/laravel-tosspayments",
"name": "corean/laravel-tosspayments",
corean marked this conversation as resolved.
Show resolved Hide resolved
"description": "A Laravel package to Toss Payments",
"keywords": [
"getsolaris",
Expand All @@ -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 @@ -51,5 +51,5 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": false
}
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