Skip to content

Commit 3abd51d

Browse files
committed
refactor: update README with new model and parameter names
- Replace deprecated model class names with new versions - Update parameter names to match latest API specification - Modify code examples to reflect current SDK usage - Adjust URL and callback parameter names for consistency
1 parent 2889559 commit 3abd51d

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ $monei = new Monei\MoneiClient('YOUR_API_KEY');
116116

117117
try {
118118
// Using request classes for better type safety and IDE autocompletion
119-
$request = new \OpenAPI\Client\Model\CreatePaymentRequest([
119+
$request = new OpenAPI\Client\Model\CreatePaymentRequest([
120120
'amount' => 1250, // 12.50€
121-
'orderId' => '100100000001',
121+
'order_id' => '100100000001',
122122
'currency' => 'EUR',
123123
'description' => 'Items description',
124-
'customer' => new \OpenAPI\Client\Model\Customer([
124+
'customer' => new OpenAPI\Client\Model\PaymentCustomer([
125125
'email' => 'john.doe@monei.com',
126126
'name' => 'John Doe'
127127
])
@@ -148,27 +148,27 @@ require_once(__DIR__ . '/vendor/autoload.php');
148148
$monei = new Monei\MoneiClient('YOUR_API_KEY');
149149

150150
try {
151-
$request = new \OpenAPI\Client\Model\CreatePaymentRequest([
151+
$request = new OpenAPI\Client\Model\CreatePaymentRequest([
152152
'amount' => 1999, // Amount in cents (19.99)
153-
'orderId' => '12345',
153+
'order_id' => '12345',
154154
'currency' => 'EUR',
155155
'description' => 'Order #12345',
156-
'customer' => new \OpenAPI\Client\Model\Customer([
156+
'customer' => new OpenAPI\Client\Model\PaymentCustomer([
157157
'email' => 'customer@example.com',
158158
'name' => 'John Doe',
159159
'phone' => '+34600000000'
160160
]),
161-
'billingDetails' => new \OpenAPI\Client\Model\BillingDetails([
162-
'address' => new \OpenAPI\Client\Model\Address([
161+
'billing_details' => new OpenAPI\Client\Model\PaymentBillingDetails([
162+
'address' => new OpenAPI\Client\Model\Address([
163163
'line1' => '123 Main St',
164164
'city' => 'Barcelona',
165165
'country' => 'ES',
166-
'postalCode' => '08001'
166+
'zip' => '08001'
167167
])
168168
]),
169-
'successUrl' => 'https://example.com/success',
170-
'failureUrl' => 'https://example.com/failure',
171-
'callbackUrl' => 'https://example.com/webhook'
169+
'complete_url' => 'https://example.com/success',
170+
'fail_url' => 'https://example.com/failure',
171+
'callback_url' => 'https://example.com/webhook'
172172
]);
173173

174174
$result = $monei->payments->create($request);
@@ -192,7 +192,7 @@ $monei = new Monei\MoneiClient('YOUR_API_KEY');
192192
try {
193193
$payment = $monei->payments->getPayment('pay_123456789');
194194
echo "Payment status: " . $payment->getStatus() . PHP_EOL;
195-
} catch (\OpenAPI\Client\ApiException $e) {
195+
} catch (OpenAPI\Client\ApiException $e) {
196196
echo 'Error retrieving payment: ', $e->getMessage(), PHP_EOL;
197197
}
198198
?>
@@ -209,14 +209,14 @@ require_once(__DIR__ . '/vendor/autoload.php');
209209
$monei = new Monei\MoneiClient('YOUR_API_KEY');
210210

211211
try {
212-
$refundRequest = new \OpenAPI\Client\Model\RefundPaymentRequest([
212+
$refundRequest = new OpenAPI\Client\Model\RefundPaymentRequest([
213213
'amount' => 500, // Partial refund of 5.00€
214-
'reason' => 'Customer request'
214+
'refund_reason' => 'Customer request'
215215
]);
216216

217217
$result = $monei->payments->refund('pay_123456789', $refundRequest);
218218
echo "Refund created with ID: " . $result->getId() . PHP_EOL;
219-
} catch (\OpenAPI\Client\ApiException $e) {
219+
} catch (OpenAPI\Client\ApiException $e) {
220220
echo 'Error refunding payment: ', $e->getMessage(), PHP_EOL;
221221
}
222222
?>
@@ -251,17 +251,17 @@ require_once(__DIR__ . '/vendor/autoload.php');
251251
$monei = new Monei\MoneiClient('YOUR_API_KEY');
252252

253253
try {
254-
$request = new \OpenAPI\Client\Model\CreatePaymentRequest([
254+
$request = new OpenAPI\Client\Model\CreatePaymentRequest([
255255
'amount' => 110, // Amount in cents (1.10)
256256
'currency' => 'EUR',
257-
'orderId' => '14379133960355',
257+
'order_id' => '14379133960355',
258258
'description' => 'Test Shop - #14379133960355',
259-
'customer' => new \OpenAPI\Client\Model\Customer([
259+
'customer' => new OpenAPI\Client\Model\PaymentCustomer([
260260
'email' => 'customer@example.com'
261261
]),
262-
'callbackUrl' => 'https://example.com/checkout/callback', // For asynchronous notifications
263-
'successUrl' => 'https://example.com/checkout/complete', // Redirect after payment
264-
'failureUrl' => 'https://example.com/checkout/cancel' // Redirect if customer cancels
262+
'callback_url' => 'https://example.com/checkout/callback', // For asynchronous notifications
263+
'complete_url' => 'https://example.com/checkout/complete', // Redirect after payment
264+
'fail_url' => 'https://example.com/checkout/cancel' // Redirect if customer cancels
265265
]);
266266

267267
$result = $monei->payments->create($request);
@@ -287,12 +287,12 @@ The customer enters their payment information and completes any required verific
287287

288288
4. **Customer is redirected back to your website**
289289

290-
- If the customer completes the payment, they are redirected to the `successUrl` with a `payment_id` query parameter
291-
- If the customer cancels, they are redirected to the `failureUrl`
290+
- If the customer completes the payment, they are redirected to the `complete_url` with a `payment_id` query parameter
291+
- If the customer cancels, they are redirected to the `fail_url`
292292

293293
5. **Receive asynchronous notification**
294294

295-
MONEI sends an HTTP POST request to your `callbackUrl` with the payment result. This ensures you receive the payment status even if the customer closes their browser during the redirect.
295+
MONEI sends an HTTP POST request to your `callback_url` with the payment result. This ensures you receive the payment status even if the customer closes their browser during the redirect.
296296

297297
For more information about the hosted payment page, visit the [MONEI Hosted Payment Page documentation](https://docs.monei.com/docs/integrations/use-prebuilt-payment-page).
298298

@@ -349,7 +349,7 @@ try {
349349

350350
http_response_code(200);
351351
echo json_encode(['received' => true]);
352-
} catch (\OpenAPI\Client\ApiException $e) {
352+
} catch (OpenAPI\Client\ApiException $e) {
353353
// Invalid signature
354354
http_response_code(401);
355355
echo json_encode(['error' => 'Invalid signature']);
@@ -359,7 +359,7 @@ try {
359359

360360
### Handling Payment Callbacks
361361

362-
MONEI sends an HTTP POST request to your `callbackUrl` with the payment result. This ensures you receive the payment status even if the customer closes their browser during the redirect.
362+
MONEI sends an HTTP POST request to your `callback_url` with the payment result. This ensures you receive the payment status even if the customer closes their browser during the redirect.
363363

364364
Example of handling the callback in a PHP script:
365365

@@ -397,7 +397,7 @@ try {
397397
// Acknowledge receipt of the webhook
398398
http_response_code(200);
399399
echo json_encode(['received' => true]);
400-
} catch (\OpenAPI\Client\ApiException $e) {
400+
} catch (OpenAPI\Client\ApiException $e) {
401401
// Invalid signature
402402
http_response_code(401);
403403
echo json_encode(['error' => 'Invalid signature']);
@@ -445,9 +445,9 @@ $monei->setAccountId('MERCHANT_ACCOUNT_ID');
445445

446446
// Make API calls on behalf of the merchant
447447
try {
448-
$request = new \OpenAPI\Client\Model\CreatePaymentRequest([
448+
$request = new OpenAPI\Client\Model\CreatePaymentRequest([
449449
'amount' => 1250,
450-
'orderId' => '12345',
450+
'order_id' => '12345',
451451
'currency' => 'EUR'
452452
]);
453453

@@ -509,9 +509,9 @@ function processPaymentsForMerchants($monei, $merchantAccounts) {
509509

510510
// Process payment for this merchant
511511
try {
512-
$request = new \OpenAPI\Client\Model\CreatePaymentRequest([
512+
$request = new OpenAPI\Client\Model\CreatePaymentRequest([
513513
'amount' => 1000,
514-
'orderId' => 'order-' . $merchantId . '-' . time(),
514+
'order_id' => 'order-' . $merchantId . '-' . time(),
515515
'currency' => 'EUR'
516516
]);
517517

0 commit comments

Comments
 (0)