File tree Expand file tree Collapse file tree 2 files changed +53
-7
lines changed
Expand file tree Collapse file tree 2 files changed +53
-7
lines changed Original file line number Diff line number Diff line change @@ -62,7 +62,50 @@ $payment = TossPayments::for(Payment::class)
6262return $payment->json();
6363```
6464
65+ ### [ paymentKey로 결제 조회] ( https://docs.tosspayments.com/reference#paymentkey%EB%A1%9C-%EA%B2%B0%EC%A0%9C-%EC%A1%B0%ED%9A%8C )
6566
67+ GET /v1/payments/{paymentKey}
68+
69+ ``` php
70+ use Getsolaris\LaravelTossPayments\TossPayments;
71+ use Getsolaris\LaravelTossPayments\Attributes\Payment;
72+
73+ $payment = TossPayments::for(Payment::class)
74+ ->paymentKey($paymentKey)
75+ ->get();
76+
77+ return $payment->json();
78+ ```
79+
80+ ### [ orderId로 결제 조회] ( https://docs.tosspayments.com/reference#orderid%EB%A1%9C-%EA%B2%B0%EC%A0%9C-%EC%A1%B0%ED%9A%8C )
81+
82+ GET /v1/payments/orders/{orderId}
83+
84+ ``` php
85+ use Getsolaris\LaravelTossPayments\TossPayments;
86+ use Getsolaris\LaravelTossPayments\Attributes\Payment;
87+
88+ $payment = TossPayments::for(Payment::class)
89+ ->orderId($orderId)
90+ ->get();
91+
92+ return $payment->json();
93+ ```
94+
95+ ### [ 결제 취소] ( https://docs.tosspayments.com/reference#%EA%B2%B0%EC%A0%9C-%EC%B7%A8%EC%86%8C )
96+
97+ POST /v1/payments/{paymentKey}/cancel
98+
99+ ``` php
100+ use Getsolaris\LaravelTossPayments\TossPayments;
101+ use Getsolaris\LaravelTossPayments\Attributes\Payment;
102+
103+ $payment = TossPayments::for(Payment::class)
104+ ->paymentId($paymentId)
105+ ->cancel(reason: $reason);
106+
107+ return $payment->json();
108+ ```
66109
67110## [ 거래 (Transaction)] ( https://docs.tosspayments.com/reference#%EA%B1%B0%EB%9E%98 )
68111
Original file line number Diff line number Diff line change @@ -15,14 +15,14 @@ class Payment extends TossPayments implements AttributeInterface
1515 protected string $ uri ;
1616
1717 /**
18- * @var string
18+ * @var string|null
1919 */
20- protected string $ paymentKey ;
20+ protected ? string $ paymentKey = null ;
2121
2222 /**
23- * @var string
23+ * @var string|null
2424 */
25- protected string $ orderId ;
25+ protected ? string $ orderId = null ;
2626
2727 /**
2828 * @var int
@@ -104,14 +104,17 @@ public function confirm(): PromiseInterface|Response
104104 */
105105 public function get (): PromiseInterface |Response
106106 {
107- return $ this ->client ->get ($ this ->createEndpoint ('/ ' .$ this ->paymentKey ));
107+ return $ this ->client ->get ($ this ->createEndpoint ('/ ' . ( $ this ->paymentKey ?? ' orders/ ' . $ this -> orderId ) ));
108108 }
109109
110110 /**
111+ * @param string $reason
111112 * @return PromiseInterface|Response
112113 */
113- public function order ( ): PromiseInterface |Response
114+ public function cancel ( string $ reason ): PromiseInterface |Response
114115 {
115- return $ this ->client ->get ($ this ->createEndpoint ('/orders/ ' .$ this ->orderId ));
116+ return $ this ->client ->post ($ this ->createEndpoint ('/ ' .$ this ->paymentKey .'/cancel ' ), [
117+ 'cancelReason ' => $ reason ,
118+ ]);
116119 }
117120}
You can’t perform that action at this time.
0 commit comments