Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Guide in Docs #41

Merged
merged 1 commit into from
Feb 24, 2023
Merged
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
7 changes: 7 additions & 0 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -58,6 +58,7 @@ function navbar() {
return [
{text: 'Home', link: '/'},
{text: 'Documentation', items: sidebar()},
{text: 'Upgrading', items: upgradeGuides()},
{text: 'Creator', link: '/creator'},
]
}
@@ -84,3 +85,9 @@ function sidebar() {
},
]
}

function upgradeGuides() {
return [
{text: 'v1.x to v2.x', link: '/upgrade-guide/v1x-to-v2x'},
]
}
53 changes: 53 additions & 0 deletions docs/upgrade-guide/v1x-to-v2x.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
title: Upgrading from v1.x to v2.x
---

# Upgrading from v1.x to v2.x

[[toc]]

::: info
We attempt to document every possible breaking change. Since some of these breaking changes are in obscure parts of the
package only a portion of these changes may actually affect your application.
:::

## High Impact Changes

### Setting Gross Amount and Order ID

::: danger
Level of impact: **High**
:::

Kasir object no longer have a `transaction_details` property. Instead, it is now assigns `gross_amount` and `order_id`
individually.

If you are implementing `transactionDetails()` method to assign the `gross_amount` and `order_id` individually, you need
to update that to `grossAmount()` and `orderId()` method respectively.

Or, if you are implementing `getTransactionDetails()` method to get the `gross_amount` and `order_id` individually, you need to
update that to `getGrossAmount()` and `getOrderId()` method respectively.

```php
class YourController extends Controller
{
public function transaction(Request $request) {
$kasir = Kasir::make() // [!code focus:7]
->transactionDetails([ // [!code --]
'gross_amount' => $request->get('gross_amount'), // [!code --]
'order_id' => 'order-'.Str::randomUuid(), // [!code --]
]); // [!code --]
->grossAmount($request->get('gross_amount')) // [!code ++]
->orderId('order-'.Str::randomUuid()); // [!code ++]

// [!code focus:6]
$gross_amount = $kasir->getTransactionDetails()['gross_amount']; // [!code --]
$gross_amount = $kasir->getGrossAmount(); // [!code ++]

$order_id = $kasir->getTransactionDetails()['order_id']; // [!code --]
$order_id = $kasir->getOrderId(); // [!code ++]

// ...
}
}
```