Skip to content

Commit ce56dde

Browse files
committed
Refactor: Update UPGRADE.md with new v3 usage examples, adjusted mappings, and remove old references
1 parent 4e7284e commit ce56dde

2 files changed

Lines changed: 73 additions & 38 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@
1616
/pint.json export-ignore
1717
/.run export-ignore
1818
/phpstan.neon export-ignore
19+
/UPGRADE.md export-ignore
1920

UPGRADE.md

Lines changed: 72 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -64,33 +64,50 @@ Version 3 introduces **breaking changes** to improve code structure, type safety
6464

6565
**Before (v2):**
6666
```php
67-
$checkoutClient = new CheckoutClient('public-key', 'secret-key', Environment::SANDBOX);
68-
$response = $checkoutClient->createCheckout($payload);
67+
$checkout = (new Checkout())
68+
->setTotalAmount(
69+
(new TotalAmount())
70+
->setValue(100) // ...
71+
) // ...
72+
73+
$checkoutResponse = (new CheckoutClient(
74+
new PaymayaClient(
75+
'sk-X8qolYjy62kIzEbr0QRK1h4b4KDVHaNcwMYk39jInSl', // secret
76+
'pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah', // public
77+
PaymayaClient::ENVIRONMENT_SANDBOX
78+
)
79+
))->execute($checkout);
80+
81+
echo 'id: '.$checkoutResponse->checkoutId."\n";
82+
echo 'url: '.$checkoutResponse->redirectUrl."\n";
6983
```
7084

7185
**Now (v3):**
7286
```php
73-
use Lloricode\Paymaya\PaymayaConnector;
74-
use Lloricode\Paymaya\Requests\CreateCheckoutRequest;
75-
use Lloricode\Paymaya\DataTransferObjects\CheckoutDto;
76-
77-
$connector = new PaymayaConnector(apiKey: 'your-api-key', secret: 'your-secret');
78-
79-
$response = $connector->send(
80-
new CreateCheckoutRequest(
81-
new CheckoutDto(
82-
amount: 100.00,
83-
currency: 'PHP',
84-
redirectUrl: 'https://your-site.com/success'
85-
)
86-
)
87+
$api = new PaymayaConnector(
88+
environment: Environment::sandbox,
89+
secretKey: 'sk-X8qolYjy62kIzEbr0QRK1h4b4KDVHaNcwMYk39jInSl',
90+
publicKey: 'pk-Z0OSzLvIcOI2UIvDhdTGVVfRSSeiGStnceqwUE7n0Ah',
8791
);
92+
93+
$checkout = new CheckoutDto(
94+
totalAmount: new TotalAmountDto(
95+
value: 100,
96+
details: new AmountDetailDto(
97+
subtotal: 100
98+
)
99+
), // ...
100+
101+
$checkoutResponse = $api->send(new CreateCheckoutRequest($checkout))->dto();
102+
103+
echo 'id: '.$checkoutResponse->checkoutId."\n";
104+
echo 'url: '.$checkoutResponse->redirectUrl."\n";
88105
```
89106

90107
---
91108

92109
#### Removed Multiple Clients
93-
- **Removed:** `CheckoutClient`, `PaymentsClient`, `WebhookClient`, etc.
110+
- **Removed:** `CheckoutClient`, `CustomizationClient`, `WebhookClient`, `PaymayaClient`, etc.
94111
- **Use instead:** `PaymayaConnector` + specific Request classes like:
95112
- `CreateCheckoutRequest`
96113
- `GetCheckoutRequest`
@@ -104,17 +121,40 @@ $response = $connector->send(
104121

105122
**Old (v2):**
106123
```php
107-
$checkoutClient->createCheckout([
108-
'amount' => [
109-
'value' => 100,
110-
'currency' => 'PHP'
111-
]
112-
]);
124+
$checkout = (new Checkout())
125+
->setTotalAmount(
126+
// ...
127+
)
128+
->setBuyer(
129+
// ...
130+
)
131+
->addItem(
132+
// ...
133+
)
134+
->setRedirectUrl(
135+
// ...
136+
)
137+
->setRequestReferenceNumber('1551191039')
138+
->setMetadata(
139+
// ...
140+
);
113141
```
114142

115143
**New (v3):**
116144
```php
117-
new CheckoutDto(amount: 100, currency: 'PHP');
145+
$checkout = new CheckoutDto(
146+
totalAmount: new TotalAmountDto(
147+
value: 100,
148+
details: new AmountDetailDto(
149+
subtotal: 100
150+
)
151+
),
152+
buyer: // ...
153+
items: // ...
154+
redirectUrl: // ...
155+
requestReferenceNumber: '1551191039',
156+
metadata: // ...
157+
);
118158
```
119159

120160
---
@@ -169,14 +209,14 @@ See [Laravel PayMaya SDK](https://github.com/lloricode/laravel-paymaya-sdk) for
169209

170210
### Old → New Class & Method Mapping
171211

172-
| v2 Class / Method | v3 Replacement |
173-
|--------------------------------|---------------------------------------------|
174-
| `CheckoutClient::createCheckout()` | `PaymayaConnector + CreateCheckoutRequest` |
175-
| `CheckoutClient::retrieve()` | `PaymayaConnector + GetCheckoutRequest` |
176-
| `WebhookClient::register()` | `PaymayaConnector + CreateWebhookRequest` |
177-
| `WebhookClient::list()` | `PaymayaConnector + ListWebhookRequest` |
178-
| `Environment::SANDBOX` | `Environment::Sandbox` (Enum) |
179-
| `Environment::PRODUCTION` | `Environment::Production` (Enum) |
212+
| v2 Class / Method | v3 Replacement |
213+
|-----------------------------------------------|---------------------------------------------|
214+
| `CheckoutClient::execute() + PaymayaClient` | `PaymayaConnector + CreateCheckoutRequest` |
215+
| `CheckoutClient::retrieve() + PaymayaClient` | `PaymayaConnector + GetCheckoutRequest` |
216+
| `WebhookClient::register() + PaymayaClient` | `PaymayaConnector + CreateWebhookRequest` |
217+
| `WebhookClient::retrieve() + PaymayaClient` | `PaymayaConnector + GetAllWebhookRequest` |
218+
| `PaymayaClient::ENVIRONMENT_SANDBOX` | `Environment::Sandbox` (Enum) |
219+
| `PaymayaClient::ENVIRONMENT_PRODUCTION` | `Environment::Production` (Enum) |
180220

181221
---
182222

@@ -199,12 +239,6 @@ If you plan to contribute, please make sure to:
199239

200240
---
201241

202-
## v4.x (TBD)
203-
204-
*Details will be added here when v4 is released.*
205-
206-
---
207-
208242
## References
209243
- [Full Documentation](https://github.com/lloricode/paymaya-sdk-php)
210244
- [Saloon Documentation](https://docs.saloon.dev/)

0 commit comments

Comments
 (0)