Skip to content

Commit 3bffc73

Browse files
committed
PHPAY-40: Merge branch 'develop' of github.com:phpay-io/phpay into 40-create-tests-to-created-features
2 parents af6e558 + 5e047e7 commit 3bffc73

File tree

3 files changed

+111
-27
lines changed

3 files changed

+111
-27
lines changed

examples/efi/charges.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,46 @@
4343
'status' => 'unpaid',
4444
])
4545
->getAll();
46+
47+
/**
48+
* find charge by id
49+
*
50+
* @return array charge
51+
*/
52+
$phpay
53+
->charge()
54+
->find($chargeId);
55+
56+
/**
57+
* confirm receipt
58+
*
59+
* @return array charge
60+
*/
61+
$phpay
62+
->charge()
63+
->confirmReceipt($chargeId);
64+
65+
/**
66+
* cancel charge
67+
*/
68+
$phpay
69+
->charge()
70+
->cancel($chargeId);
71+
72+
/**
73+
* update due date
74+
*/
75+
$phpay
76+
->charge()
77+
->updateDueDate($chargeId, $dueDate);
78+
79+
/**
80+
* update billet metadata
81+
* notification_url and custom_id
82+
*/
83+
$phpay
84+
->charge()
85+
->updateMetadata($chargeId, [
86+
'notification_url' => $notificationUrl,
87+
'custom_id' => $customId,
88+
]);

src/Gateways/Efi/Resources/Charge/Charge.php

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ public function getAll(): array
9696
return $this->get('v1/charges', $this->queryParams);
9797
}
9898

99+
/**
100+
* find charge by id
101+
*
102+
* @return array<array|mixed>
103+
*/
104+
public function find(string $id): array
105+
{
106+
return $this->get("v1/charge/{$id}");
107+
}
108+
99109
/**
100110
* create charge
101111
*
@@ -122,71 +132,63 @@ public function create(): array
122132
}
123133

124134
/**
125-
* update charge
135+
* update billet metadata
136+
* notification_url and custom_id
126137
*
127138
* @param string $id
128139
* @param array<mixed> $data
129140
* @return array<mixed>
130141
*/
131-
public function update(string $id, array $data): array
142+
public function updateMetadata(string $id, array $data): array
132143
{
133-
return $this->put("payments/{$id}", $data);
144+
return $this->put("v1/charge/{$id}/metadata", $data);
134145
}
135146

136147
/**
137-
* destroy charge
138-
*
139-
* @param string $id
140-
* @return bool
141-
*/
142-
public function destroy(string $id): bool
143-
{
144-
return $this->delete("payments/{$id}");
145-
}
146-
147-
/**
148-
* get status charge
148+
* cancel charge
149149
*
150150
* @param string $id
151151
* @return array<array|mixed>
152152
*/
153-
public function getStatus(string $id): array
153+
public function cancel(string $id): array
154154
{
155-
return $this->get("payments/{$id}/status");
155+
return $this->put("v1/charge/{$id}/cancel", []);
156156
}
157157

158158
/**
159-
* get digitable line
159+
* update due date
160160
*
161161
* @param string $id
162-
* @return mixed
162+
* @param string $dueDate
163+
* @return array<array|mixed>
163164
*/
164-
public function getDigitableLine(string $id): mixed
165+
public function updateDueDate(string $id, string $dueDate): array
165166
{
166-
return $this->get("payments/{$id}/identificationField")['identificationField'];
167+
return $this->put("v1/charge/{$id}/billet", [
168+
'expire_at' => $dueDate,
169+
]);
167170
}
168171

169172
/**
170-
* get qrcode pix
173+
* get status charge
171174
*
172175
* @param string $id
173176
* @return array<array|mixed>
174177
*/
175-
public function getQrCodePix(string $id): array
178+
public function getStatus(string $id): array
176179
{
177-
return $this->get("payments/{$id}/pixQrCode");
180+
return $this->get("payments/{$id}/status");
178181
}
179182

180183
/**
181184
* confirm receipt
182185
*
183186
* @param string $id
184-
* @param array<mixed> $data
185187
* @return array<mixed>
186188
*/
187-
public function confirmReceipt(string $id, array $data): array
189+
public function confirmReceipt(string $id): array
188190
{
189-
return $this->post("payments/{$id}/receiveInCash", $data);
191+
return $this->put("v1/charge/{$id}/settle", []);
190192
}
191193

192194
/**

src/Gateways/Efi/Resources/Charge/Interface/ChargeInterface.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ interface ChargeInterface
1313
*/
1414
public function getAll(): array;
1515

16+
/**
17+
* find charge by id
18+
*
19+
* @param string $id
20+
* @return array<array|mixed>
21+
*/
22+
public function find(string $id): array;
23+
1624
/**
1725
* set customer
1826
*
@@ -28,4 +36,35 @@ public function setCustomer(array $customer): Charge;
2836
* @return ChargeInterface
2937
*/
3038
public function setQueryParams(array $queryParams): ChargeInterface;
39+
40+
/**
41+
* @param string $id
42+
* @return array<array|mixed>
43+
*/
44+
public function confirmReceipt(string $id): array;
45+
46+
/**
47+
* cancel charge by id
48+
*
49+
* @param string $id
50+
* @return array<array|mixed>
51+
*/
52+
public function cancel(string $id): array;
53+
54+
/**
55+
* @param string $id
56+
* @param string $dueDate
57+
* @return array<array|mixed>
58+
*/
59+
public function updateDueDate(string $id, string $dueDate): array;
60+
61+
/**
62+
* update billet metadata
63+
* notification_url and custom_id
64+
*
65+
* @param string $id
66+
* @param array<mixed> $data
67+
* @return array<mixed>
68+
*/
69+
public function updateMetadata(string $id, array $data): array;
3170
}

0 commit comments

Comments
 (0)