Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.4, 8.0, 8.1, 8.2]
php: [8.0, 8.1, 8.2, 8.3, 8.4]
name: PHP - ${{ matrix.php }}
steps:
- name: Checkout code
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}
],
"require": {
"php": "^7.4|^8.0",
"php": "^8.0",
"ext-curl": "*",
"ext-json": "*",
"ext-openssl": "*",
Expand Down
47 changes: 10 additions & 37 deletions docs/Chargebacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ Below you'll find all properties for the Vatly Chargeback resource.
| Name | Type | Description |
| --- | --- | --- |
| `id` | `string` | Unique identifier for the chargeback (`chb_...`). |
| `status` | `string` | The status: `open`, `won`, or `lost`. |
| `orderId` | `string` | The disputed order ID. |
| `amount` | `integer` | Chargeback amount in cents. |
| `currency` | `string` | Three-letter ISO currency code. |
| `reason` | `string|null` | Reason provided by the bank. |
| `resource` | `string` | Always `chargeback`. |
| `merchantId` | `string` | The merchant ID. |
| `testmode` | `bool` | Whether this is a test chargeback. |
| `amount` | `object` | Chargeback amount (`value` and `currency`). |
| `settlementAmount` | `object` | Amount deducted from settlement (may differ from `amount`). |
| `reason` | `string` | Reason code for the dispute (e.g. `fraud`, `product_not_received`, `duplicate`). |
| `originalOrderId` | `string` | The ID of the original order that was disputed. |
| `orderId` | `string\|null` | The credit note order ID (after processing). |
| `createdAt` | `string` | Creation timestamp (ISO 8601). |

---
Expand All @@ -35,9 +37,9 @@ Retrieve a chargeback by its ID.
```php
$chargeback = $vatly->chargebacks->get('chb_abc123');

echo $chargeback->status;
echo $chargeback->amount / 100 . ' ' . $chargeback->currency;
echo $chargeback->reason;
echo $chargeback->amount->value . ' ' . $chargeback->amount->currency;
echo $chargeback->originalOrderId;
```


Expand Down Expand Up @@ -66,35 +68,6 @@ Retrieve a paginated list of all chargebacks.
$chargebacks = $vatly->chargebacks->list();

foreach ($chargebacks as $chargeback) {
echo $chargeback->id . ': ' . $chargeback->status;
echo $chargeback->id . ': ' . $chargeback->reason;
}
```



---

## Chargeback statuses

| Status | Description |
|--------|-------------|
| `open` | Dispute is ongoing |
| `won` | You won the dispute |
| `lost` | You lost the dispute |

---

## Helper methods



The Chargeback object provides convenient helper methods.




```php
$chargeback->isOpen(); // true if status is 'open'
$chargeback->isWon(); // true if status is 'won'
$chargeback->isLost(); // true if status is 'lost'
```
2 changes: 1 addition & 1 deletion docs/OneOffProducts.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Below you'll find all properties for the Vatly One-Off Product resource.
| `amount` | `integer` | Price in cents. |
| `currency` | `string` | Three-letter ISO currency code. |
| `testmode` | `bool` | Whether this is a test product. |
| `active` | `bool` | Whether the product is active. |
| `status` | `string` | The status: `approved`, `draft`, or `archived`. |
| `createdAt` | `string` | Creation timestamp (ISO 8601). |

---
Expand Down
4 changes: 1 addition & 3 deletions docs/Orders.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Below you'll find all properties for the Vatly Order resource.
| Name | Type | Description |
| --- | --- | --- |
| `id` | `string` | Unique identifier for the order (`ord_...`). |
| `status` | `string` | The status: `pending`, `paid`, `failed`, or `refunded`. |
| `status` | `string` | The status: `pending`, `paid`, or `failed`. |
| `customerId` | `string` | The customer ID. |
| `checkoutId` | `string|null` | The checkout ID (for initial orders). |
| `subscriptionId` | `string|null` | The subscription ID (for recurring orders). |
Expand Down Expand Up @@ -94,7 +94,6 @@ $orders = $vatly->orders->list([
| `pending` | Order is awaiting payment |
| `paid` | Payment successful |
| `failed` | Payment failed |
| `refunded` | Order has been refunded |

---

Expand All @@ -111,5 +110,4 @@ The Order object provides convenient helper methods.
$order->isPaid(); // true if status is 'paid'
$order->isPending(); // true if status is 'pending'
$order->isFailed(); // true if status is 'failed'
$order->isRefunded(); // true if status is 'refunded'
```
12 changes: 7 additions & 5 deletions docs/Refunds.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Below you'll find all properties for the Vatly Refund resource.
| Name | Type | Description |
| --- | --- | --- |
| `id` | `string` | Unique identifier for the refund (`ref_...`). |
| `status` | `string` | The status: `pending`, `succeeded`, or `failed`. |
| `status` | `string` | The status: `pending`, `completed`, `failed`, or `canceled`. |
| `orderId` | `string` | The order ID being refunded. |
| `amount` | `integer` | Refund amount in cents. |
| `currency` | `string` | Three-letter ISO currency code. |
Expand Down Expand Up @@ -124,8 +124,9 @@ foreach ($refunds as $refund) {
| Status | Description |
|--------|-------------|
| `pending` | Refund is being processed |
| `succeeded` | Refund completed successfully |
| `completed` | Refund completed successfully |
| `failed` | Refund failed |
| `canceled` | Refund was canceled |

---

Expand All @@ -139,7 +140,8 @@ The Refund object provides convenient helper methods.


```php
$refund->isPending(); // true if status is 'pending'
$refund->isSucceeded(); // true if status is 'succeeded'
$refund->isFailed(); // true if status is 'failed'
$refund->isPending(); // true if status is 'pending'
$refund->isCompleted(); // true if status is 'completed'
$refund->isFailed(); // true if status is 'failed'
$refund->isCanceled(); // true if status is 'canceled'
```
2 changes: 1 addition & 1 deletion docs/SubscriptionPlans.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Below you'll find all properties for the Vatly Subscription Plan resource.
| `intervalCount` | `integer` | Number of intervals between billings. |
| `trialDays` | `integer|null` | Default trial period in days. |
| `testmode` | `bool` | Whether this is a test plan. |
| `active` | `bool` | Whether the plan is active. |
| `status` | `string` | The status: `approved`, `draft`, or `archived`. |
| `createdAt` | `string` | Creation timestamp (ISO 8601). |

---
Expand Down
25 changes: 11 additions & 14 deletions docs/Subscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Below you'll find all properties for the Vatly Subscription resource.
| Name | Type | Description |
| --- | --- | --- |
| `id` | `string` | Unique identifier for the subscription (`sub_...`). |
| `status` | `string` | The status: `active`, `canceled`, `past_due`, `trialing`, `paused`, or `ended`. |
| `status` | `string` | The status: `active`, `created`, `trial`, `on_grace_period`, or `paused`. |
| `customerId` | `string` | The customer ID. |
| `planId` | `string` | The subscription plan ID. |
| `testmode` | `bool` | Whether this is a test subscription. |
Expand Down Expand Up @@ -102,8 +102,8 @@ Cancel a subscription. The subscription will remain active until the end of the
```php
$subscription = $vatly->subscriptions->cancel('sub_abc123');

// Subscription is now 'canceled' but active until period end
echo $subscription->status; // 'canceled'
// Subscription is now on grace period until current period ends
echo $subscription->status; // 'on_grace_period'
echo $subscription->currentPeriodEnd; // When it ends
```

Expand All @@ -116,11 +116,10 @@ echo $subscription->currentPeriodEnd; // When it ends
| Status | Description |
|--------|-------------|
| `active` | Subscription is active and billing |
| `canceled` | Subscription is canceled, active until period end |
| `past_due` | Payment failed, in grace period |
| `trialing` | In trial period |
| `created` | Subscription created, not yet active |
| `trial` | In trial period |
| `on_grace_period` | Canceled but still active until current period ends |
| `paused` | Subscription is paused |
| `ended` | Subscription has ended |

---

Expand All @@ -134,11 +133,9 @@ The Subscription object provides convenient helper methods.


```php
$subscription->isActive(); // true if status is 'active'
$subscription->isCanceled(); // true if status is 'canceled'
$subscription->isTrialing(); // true if status is 'trialing'
$subscription->isPastDue(); // true if status is 'past_due'
$subscription->hasEnded(); // true if status is 'ended'
$subscription->onTrial(); // true if currently in trial
$subscription->onGracePeriod(); // true if canceled but still active
$subscription->isActive(); // true if status is 'active'
$subscription->isCreated(); // true if status is 'created'
$subscription->onTrial(); // true if status is 'trial'
$subscription->onGracePeriod(); // true if status is 'on_grace_period'
$subscription->isPaused(); // true if status is 'paused'
```
2 changes: 1 addition & 1 deletion docs/Webhooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Vatly sends webhooks to notify your application when events happen, like success
| `subscription.ended` | Subscription ended |
| `order.paid` | Order payment received |
| `refund.created` | Refund initiated |
| `refund.succeeded` | Refund completed |
| `refund.completed` | Refund completed |
| `chargeback.created` | Chargeback received |
| `chargeback.won` | Chargeback dispute won |
| `chargeback.lost` | Chargeback dispute lost |
Expand Down
16 changes: 5 additions & 11 deletions src/API/Resources/Checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Checkout extends BaseResource

public ?string $createdAt = null;

public ?string $expiresAt = null;

/**
* Is this created?
*/
Expand All @@ -79,11 +81,11 @@ public function isCanceled(): bool
}

/**
* Is this completed?
* Is this failed?
*/
public function isCompleted(): bool
public function isFailed(): bool
{
return $this->status === CheckoutStatus::STATUS_COMPLETED;
return $this->status === CheckoutStatus::STATUS_FAILED;
}

/**
Expand All @@ -93,12 +95,4 @@ public function isExpired(): bool
{
return $this->status === CheckoutStatus::STATUS_EXPIRED;
}

/**
* Is this completed?
*/
public function isPending(): bool
{
return $this->status === CheckoutStatus::STATUS_PENDING;
}
}
23 changes: 23 additions & 0 deletions src/API/Resources/OneOffProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Vatly\API\Resources\Links\OneOffProductLinks;
use Vatly\API\Types\Money;
use Vatly\API\Types\ProductStatus;

class OneOffProduct extends BaseResource
{
Expand All @@ -26,5 +27,27 @@ class OneOffProduct extends BaseResource
*/
public Money $basePrice;

public bool $testmode;

/** @see ProductStatus */
public string $status;

public string $createdAt;

public OneOffProductLinks $links;

public function isApproved(): bool
{
return $this->status === ProductStatus::APPROVED;
}

public function isDraft(): bool
{
return $this->status === ProductStatus::DRAFT;
}

public function isArchived(): bool
{
return $this->status === ProductStatus::ARCHIVED;
}
}
44 changes: 11 additions & 33 deletions src/API/Resources/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@ class Order extends BaseResource
/**
* @example creditcard
*/
public string $paymentMethod;
public ?string $paymentMethod = null;

public ?string $invoiceNumber = null;

/** @see OrderStatus */
public string $status;

public bool $cancelled = false;

public OrderLinks $links;

public Address $customerDetails;
Expand All @@ -68,6 +66,10 @@ class Order extends BaseResource
*/
public array $lines;

/**
* @var array|object|null
*/
public $metadata = null;

/**
* Get the line value objects
Expand All @@ -85,14 +87,6 @@ public function lines(): OrderLineCollection
);
}

/**
* Is this order created?
*/
public function isCreated(): bool
{
return $this->status === OrderStatus::STATUS_CREATED;
}

/**
* Is this order paid for?
*/
Expand All @@ -102,35 +96,19 @@ public function isPaid(): bool
}

/**
* Is this order canceled?
*/
public function isCanceled(): bool
{
return $this->status === OrderStatus::STATUS_CANCELED;
}

/**
* Is this order completed?
* Is this order pending?
*/
public function isCompleted(): bool
{
return $this->status === OrderStatus::STATUS_COMPLETED;
}

/**
* Is this order expired?
*/
public function isExpired(): bool
public function isPending(): bool
{
return $this->status === OrderStatus::STATUS_EXPIRED;
return $this->status === OrderStatus::STATUS_PENDING;
}

/**
* Is this order completed?
* Is this order failed?
*/
public function isPending(): bool
public function isFailed(): bool
{
return $this->status === OrderStatus::STATUS_PENDING;
return $this->status === OrderStatus::STATUS_FAILED;
}

/**
Expand Down
Loading