From 675c0ed3a9be1ffb551356a9fe34354b201aab6e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 3 Apr 2023 05:33:28 +0000 Subject: [PATCH 01/16] tutorial to add adapter --- docs/tutorials/add-new-payment-adapter.md | 204 ++++++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 docs/tutorials/add-new-payment-adapter.md diff --git a/docs/tutorials/add-new-payment-adapter.md b/docs/tutorials/add-new-payment-adapter.md new file mode 100644 index 0000000..07c6a08 --- /dev/null +++ b/docs/tutorials/add-new-payment-adapter.md @@ -0,0 +1,204 @@ +# Adding a new payment adapter 💾 + +This document is part of the Utopia contributors' guide. Before you continue reading this document make sure you have read the [Code of Conduct](../../CODE_OF_CONDUCT.md) and the [Contributing Guide](../../CONTRIBUTING.md). + +## Getting started + +Payment adapters help developers to process their payment using payment providers. With each payment provider you will be able to use a new payment provider to process payment. + +Utopia is and will always be tech-agnostic, which means, we are creating a tools based on technologies you already use and love, instead of creating a new tool-set for you. With that in mind, we accept all contributions with adapters for any payment providers. + +## 1. Prerequisites + +It's really easy to contribute to an open source project, but when using GitHub, there are a few steps we need to follow. This section will take you step-by-step through the process of preparing your own local version of utopia-php/pay, where you can make any changes without affecting Utopia right away. + +> If you are experienced with GitHub or have made a pull request before, you can skip to [Implement new adapter](#2-implement-new-adapter). + +### 1.1 Fork the utopia-php/pay repository + +Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/logger Github repository](https://github.com/utopia-php/pay) and click on the fork button. + +This will redirect you from `github.com/utopia-php/pay` to `github.com/YOUR_USERNAME/pay`, meaning all changes you do are only done inside your repository. Once you are there, click the highlighted `Code` button, copy the URL and clone the repository to your computer using `git clone` command: + +```shell +$ git clone [COPIED_URL] +``` + +> To clone a repository, you will need a basic understanding of CLI and git-cli binaries installed. If you are a beginner, we recommend you to use `Github Desktop`. It is a really clean and simple visual Git client. + +Finally, you will need to create a `feat-ZZZ-adapter` branch based on the `main` branch and switch to it. The `ZZZ` should represent the adapter name. + +## 2. Implement new adapter + +### 2.1 Add adapter class + +Before implementing the adapter, please make sure to **not use any PHP library!** You will need to build app API calls using HTTP requests. + +Create a new file `XXX.php` where `XXX` is the name of the adapter in [`PascalCase`](https://stackoverflow.com/a/41769355/7659504) in this location +```bash +src/Pay/Adapter/XXX.php +``` + +Inside this file, create a new class that extends adapter abstract class `Adapter`. Note that the class name should start with a capital letter, as PHP FIG standards suggest. + +Once a new class is created, you can start to implement your new adapter's flow. We have prepared a starting point for adapter class below, but you should also consider looking at other adapter implementations and try to follow the same standards. + +```php + If you copy this template, make sure to replace all placeholders wrapped like `[THIS]` and to implement everything marked as `TODO:`. + +When implementing new adapter, please make sure to follow these rules: + +- `getName()` needs to use same name as file name with first letter lowercased. For example, in `Stripe.php`, we use `stripe` + + +Please mention in your documentation what resources or API docs you used to implement the provider's API. + +## 2. Test your adapter + +After you finished adding your new adapter, you should write a proper test for it. To do that, you create `tests/Pay/Adapter/[PROVIDER_NAME]Tests.php` and write tests for the provider. Look at the test written for the existing adapters for examples. + +To run the test you can simply run + +```bash +composer test +``` + +## 4. Raise a pull request + +First of all, commit the changes with the message `Added XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia/pay. If you visit it at `github.com/YOUR_USERNAME/logger`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. + +## 🤕 Stuck ? +If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. \ No newline at end of file From 74b9ceb677199cd1e798cbc4471ba3ccc3e8f8e2 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Mon, 3 Apr 2023 05:35:04 +0000 Subject: [PATCH 02/16] rename and update --- CONTRIBUTING.md | 5 +++++ .../{add-new-payment-adapter.md => add-payment-adapter.md} | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) rename docs/tutorials/{add-new-payment-adapter.md => add-payment-adapter.md} (97%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 72939af..abc2180 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -76,6 +76,11 @@ This will allow the Utopia-php community to have sufficient discussion about the This is also important for the Utopia-php lead developers to be able to give technical input and different emphasis regarding the feature design and architecture. Some bigger features might need to go through our [RFC process](https://github.com/appwrite/rfc). + +## Adding a New Adapter + +You can follow our [Adding new Payment Adapter tutorial](docs/tutorials/add-payment-adapter.md) to add new payment provider support in this library. + ## Other Ways to Help Pull requests are great, but there are many other areas where you can help Utopia-php. diff --git a/docs/tutorials/add-new-payment-adapter.md b/docs/tutorials/add-payment-adapter.md similarity index 97% rename from docs/tutorials/add-new-payment-adapter.md rename to docs/tutorials/add-payment-adapter.md index 07c6a08..13310ac 100644 --- a/docs/tutorials/add-new-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -198,7 +198,7 @@ composer test ## 4. Raise a pull request -First of all, commit the changes with the message `Added XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia/pay. If you visit it at `github.com/YOUR_USERNAME/logger`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. +First of all, commit the changes with the message `Added XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia/pay. If you visit it at `github.com/YOUR_USERNAME/pay`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. ## 🤕 Stuck ? If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. \ No newline at end of file From 6018b9e7ba33261bd784a7d7bcd9c2892d3c20a4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 26 Apr 2023 09:55:37 +0545 Subject: [PATCH 03/16] Update add-payment-adapter.md --- docs/tutorials/add-payment-adapter.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 13310ac..11befbf 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -16,7 +16,7 @@ It's really easy to contribute to an open source project, but when using GitHub, ### 1.1 Fork the utopia-php/pay repository -Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/logger Github repository](https://github.com/utopia-php/pay) and click on the fork button. +Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/pay Github repository](https://github.com/utopia-php/pay) and click on the fork button. This will redirect you from `github.com/utopia-php/pay` to `github.com/YOUR_USERNAME/pay`, meaning all changes you do are only done inside your repository. Once you are there, click the highlighted `Code` button, copy the URL and clone the repository to your computer using `git clone` command: @@ -201,4 +201,4 @@ composer test First of all, commit the changes with the message `Added XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia/pay. If you visit it at `github.com/YOUR_USERNAME/pay`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. ## 🤕 Stuck ? -If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. \ No newline at end of file +If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. From e0af653d6b4f7122e4eac9f26cb08539d0dce1b4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:04:33 +0545 Subject: [PATCH 04/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 11befbf..cb1dc7a 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -4,7 +4,7 @@ This document is part of the Utopia contributors' guide. Before you continue rea ## Getting started -Payment adapters help developers to process their payment using payment providers. With each payment provider you will be able to use a new payment provider to process payment. +Payment adapters help developers process payments using payment providers. By adding a new payment provider, you will be able to use it to process payments. Utopia is and will always be tech-agnostic, which means, we are creating a tools based on technologies you already use and love, instead of creating a new tool-set for you. With that in mind, we accept all contributions with adapters for any payment providers. From 26f9f6c160dbfd0fc5aaca4d382a08c63cda9700 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:04:43 +0545 Subject: [PATCH 05/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index cb1dc7a..d3c989b 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -6,7 +6,7 @@ This document is part of the Utopia contributors' guide. Before you continue rea Payment adapters help developers process payments using payment providers. By adding a new payment provider, you will be able to use it to process payments. -Utopia is and will always be tech-agnostic, which means, we are creating a tools based on technologies you already use and love, instead of creating a new tool-set for you. With that in mind, we accept all contributions with adapters for any payment providers. +Utopia is and will always be tech-agnostic, meaning we are creating tools based on technologies you already use and love instead of creating a new toolset for you. With that in mind, we accept all contributions with adapters for any payment provider. ## 1. Prerequisites From cd03c9e746e57242f5af5ed3cca982384b375d62 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:04:55 +0545 Subject: [PATCH 06/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index d3c989b..c66c2e5 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -14,7 +14,7 @@ It's really easy to contribute to an open source project, but when using GitHub, > If you are experienced with GitHub or have made a pull request before, you can skip to [Implement new adapter](#2-implement-new-adapter). -### 1.1 Fork the utopia-php/pay repository +### 1.1 Fork the utopia-php/pay repository Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/pay Github repository](https://github.com/utopia-php/pay) and click on the fork button. From 5474b2753cc79036112f78c1ec18646257542fcd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:02 +0545 Subject: [PATCH 07/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index c66c2e5..c87dbd2 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -18,7 +18,7 @@ It's really easy to contribute to an open source project, but when using GitHub, Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/pay Github repository](https://github.com/utopia-php/pay) and click on the fork button. -This will redirect you from `github.com/utopia-php/pay` to `github.com/YOUR_USERNAME/pay`, meaning all changes you do are only done inside your repository. Once you are there, click the highlighted `Code` button, copy the URL and clone the repository to your computer using `git clone` command: +This will redirect you from `github.com/utopia-php/pay` to `github.com/YOUR_USERNAME/pay`, meaning all changes you do will only be done inside your repository. Once you are there, click the highlighted `Code` button, copy the URL, and clone the repository to your computer using `git clone` command: ```shell $ git clone [COPIED_URL] From 3fab134a5036191d587db43dd77d116da4f61add Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:09 +0545 Subject: [PATCH 08/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index c87dbd2..48ea9c3 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -26,7 +26,7 @@ $ git clone [COPIED_URL] > To clone a repository, you will need a basic understanding of CLI and git-cli binaries installed. If you are a beginner, we recommend you to use `Github Desktop`. It is a really clean and simple visual Git client. -Finally, you will need to create a `feat-ZZZ-adapter` branch based on the `main` branch and switch to it. The `ZZZ` should represent the adapter name. +Finally, you will need to create a `feat-ZZZ-adapter` branch based on the `main` branch and switch to it. Replace `ZZZ` with the adapter name. ## 2. Implement new adapter From cb4e908c6bd67c82af3e28cd6b20d4b986b14b99 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:16 +0545 Subject: [PATCH 09/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 48ea9c3..b6a255c 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -190,7 +190,7 @@ Please mention in your documentation what resources or API docs you used to impl After you finished adding your new adapter, you should write a proper test for it. To do that, you create `tests/Pay/Adapter/[PROVIDER_NAME]Tests.php` and write tests for the provider. Look at the test written for the existing adapters for examples. -To run the test you can simply run +To run the test, you can simply run ```bash composer test From 4db5459bdc5e37cdb238eab2415603f059717b04 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:24 +0545 Subject: [PATCH 10/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index b6a255c..4ea52ab 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -198,7 +198,7 @@ composer test ## 4. Raise a pull request -First of all, commit the changes with the message `Added XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia/pay. If you visit it at `github.com/YOUR_USERNAME/pay`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. +First of all, commit the changes with the message `Add XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia-php/pay. If you visit `github.com/YOUR_USERNAME/pay`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. ## 🤕 Stuck ? If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. From 10f5f682154ada4577df992529cdba066a3e82eb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:31 +0545 Subject: [PATCH 11/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 4ea52ab..794622b 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -201,4 +201,5 @@ composer test First of all, commit the changes with the message `Add XXX Adapter` (where `XXX` is adapter name) and push it. This will publish a new branch to your forked version of utopia-php/pay. If you visit `github.com/YOUR_USERNAME/pay`, you will see a new alert saying you are ready to submit a pull request. Follow the steps GitHub provides, and at the end, you will have your pull request submitted. ## 🤕 Stuck ? + If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. From 0147a7c38f576a843e8181fae4d1474e2fa8ffcb Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:36 +0545 Subject: [PATCH 12/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 794622b..560dde2 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -202,4 +202,4 @@ First of all, commit the changes with the message `Add XXX Adapter` (where `XXX` ## 🤕 Stuck ? -If you need any help with the contribution, feel free to head over to [Appwrite discord channel](https://appwrite.io/discord) and we'll be happy to help you out. +If you need any help with the contribution, feel free to head over to the [Appwrite discord channel](https://appwrite.io/discord), and we'll be happy to help you out. From 01fc6232b0445ead7eccaa13d156c61f162bed24 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:42 +0545 Subject: [PATCH 13/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 560dde2..8da5569 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -16,7 +16,7 @@ It's really easy to contribute to an open source project, but when using GitHub, ### 1.1 Fork the utopia-php/pay repository -Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia/pay Github repository](https://github.com/utopia-php/pay) and click on the fork button. +Before making any changes, you will need to fork Utopia's repository to keep branches on the official repo clean. To do that, visit the [utopia-php/pay Github repository](https://github.com/utopia-php/pay) and click on the fork button. This will redirect you from `github.com/utopia-php/pay` to `github.com/YOUR_USERNAME/pay`, meaning all changes you do will only be done inside your repository. Once you are there, click the highlighted `Code` button, copy the URL, and clone the repository to your computer using `git clone` command: From edb039cb0db90fc57c7ddc5f65e2e885381a21b5 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:05:57 +0545 Subject: [PATCH 14/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 8da5569..c784cf1 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -39,7 +39,7 @@ Create a new file `XXX.php` where `XXX` is the name of the adapter in [`PascalCa src/Pay/Adapter/XXX.php ``` -Inside this file, create a new class that extends adapter abstract class `Adapter`. Note that the class name should start with a capital letter, as PHP FIG standards suggest. +Inside this file, create a new class that extends the adapter abstract `Adapter` class. Note that the class name should start with a capital letter, as PHP FIG standards suggest. Once a new class is created, you can start to implement your new adapter's flow. We have prepared a starting point for adapter class below, but you should also consider looking at other adapter implementations and try to follow the same standards. From 02cfa62af05135656dccc809f205e9f07dd10e1b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 3 May 2023 07:08:17 +0545 Subject: [PATCH 15/16] Apply suggestions from code review Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index c784cf1..4d1c1c0 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -41,7 +41,7 @@ src/Pay/Adapter/XXX.php Inside this file, create a new class that extends the adapter abstract `Adapter` class. Note that the class name should start with a capital letter, as PHP FIG standards suggest. -Once a new class is created, you can start to implement your new adapter's flow. We have prepared a starting point for adapter class below, but you should also consider looking at other adapter implementations and try to follow the same standards. +Once a new class is created, you can implement your new adapter's flow. We have prepared a starting point for the adapter class below, but you should also consider looking at other adapter implementations and try to follow the same standards. ```php If you copy this template, make sure to replace all placeholders wrapped like `[THIS]` and to implement everything marked as `TODO:`. - -When implementing new adapter, please make sure to follow these rules: +> If you copy this template, make sure to replace all `[THIS]` placeholders and to implement everything marked as `TODO:`. -- `getName()` needs to use same name as file name with first letter lowercased. For example, in `Stripe.php`, we use `stripe` +When implementing a new adapter, please make sure to follow these rules: +- `getName()` needs to use the same name as the file name with the first letter lowercased. For example, in `Stripe.php`, we use `stripe`. Please mention in your documentation what resources or API docs you used to implement the provider's API. ## 2. Test your adapter -After you finished adding your new adapter, you should write a proper test for it. To do that, you create `tests/Pay/Adapter/[PROVIDER_NAME]Tests.php` and write tests for the provider. Look at the test written for the existing adapters for examples. +After you add your new adapter, you should write proper tests. To do that, create `tests/Pay/Adapter/[PROVIDER_NAME]Tests.php` and write tests for the provider. You can look at the tests written for the existing adapters for examples. To run the test, you can simply run From 0c20a2353e8a92c6f7e4840c8c4e2432be003721 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 7 May 2023 06:52:56 +0545 Subject: [PATCH 16/16] Update docs/tutorials/add-payment-adapter.md Co-authored-by: Steven <1477010+stnguyen90@users.noreply.github.com> --- docs/tutorials/add-payment-adapter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorials/add-payment-adapter.md b/docs/tutorials/add-payment-adapter.md index 4d1c1c0..1a1808c 100644 --- a/docs/tutorials/add-payment-adapter.md +++ b/docs/tutorials/add-payment-adapter.md @@ -39,7 +39,7 @@ Create a new file `XXX.php` where `XXX` is the name of the adapter in [`PascalCa src/Pay/Adapter/XXX.php ``` -Inside this file, create a new class that extends the adapter abstract `Adapter` class. Note that the class name should start with a capital letter, as PHP FIG standards suggest. +Inside this file, create a new class that extends the abstract `Adapter` class. Note that the class name should start with a capital letter, as PHP FIG standards suggest. Once a new class is created, you can implement your new adapter's flow. We have prepared a starting point for the adapter class below, but you should also consider looking at other adapter implementations and try to follow the same standards.