Skip to content

Commit dac16e7

Browse files
author
AliH
authored
WIP: New implementation (#15)
* Adds new implementaion * Implements some payment functions * Finished implementing payment methods * Adds a lot of changes * Add newline to the end of .gitignore * Completed tests * Removed unused uses * Add laravel support and more tests * Updated README * Updated services paths * Updated services paths * Small bug fixed * Bug fixes * Bug fixes * Bug fixes * Adds version * Fixed bugs * More laravel documentation * Bug fixes * More docs * More docs * More docs * More docs * Adds hints to Laravel Facades * Fixed small mistake * Fixed issues requested by aziz * Improved validation exception * Improved validation exception * Adds publishable API key * Adds http status code to ApiException * Removed coverage file and added .gitattributes * Removed coverage file and added .gitattributes * Added CHANGELOG.md * Updated dates and links
1 parent 78f70d9 commit dac16e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+5444
-263
lines changed

.gitattributes

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.gitignore export-ignore
2+
/tests export-ignore
3+
/phpunit.xml export-ignore

.gitignore

+28-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,35 @@
11
# Created by .ignore support plugin (hsz.mobi)
22
### Composer template
33
composer.phar
4+
.phpunit.result.cache
45
vendor/
56
.idea
7+
coverage.xml
68

7-
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
8-
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
9-
# composer.lock
9+
### macOS ###
10+
# General
11+
.DS_Store
12+
.AppleDouble
13+
.LSOverride
1014

15+
# Icon must end with two \r
16+
Icon
17+
18+
# Thumbnails
19+
._*
20+
21+
# Files that might appear in the root of a volume
22+
.DocumentRevisions-V100
23+
.fseventsd
24+
.Spotlight-V100
25+
.TemporaryItems
26+
.Trashes
27+
.VolumeIcon.icns
28+
.com.apple.timemachine.donotpresent
29+
30+
# Directories potentially created on remote AFP share
31+
.AppleDB
32+
.AppleDesktop
33+
Network Trash Folder
34+
Temporary Items
35+
.apdisk

CHANGELOG.md

+171
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# Changelog
2+
All notable changes to this library will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
## [Unreleased]
8+
* Nothing New
9+
10+
11+
## [1.0.0] - 2020-04-06
12+
13+
This version of the library is a complete reimplementation from ground up.
14+
Please checkout the following sections to see what changed
15+
16+
### Summary
17+
18+
There is many changes to the library API, so let's get going.
19+
First we need to set the secret API key:
20+
21+
Before
22+
23+
```php
24+
\Moyasar\Client::setApiKey("API-KEY");
25+
```
26+
27+
After
28+
29+
```php
30+
\Moyasar\Moyasar::setApiKey('API-KEY');
31+
```
32+
33+
#### Payment and Invoice Fetch
34+
35+
In case of fetching a payment, we use `PaymentService` class.
36+
37+
Before:
38+
39+
```php
40+
$data = \Moyasar\Payment::fetch("760878ec-d1d3-5f72-9056-191683f55872");
41+
$data = \Moyasar\Invoice::fetch("760878ec-d1d3-5f72-9056-191683f55872");
42+
```
43+
44+
After:
45+
46+
```php
47+
$paymentService = new \Moyasar\Providers\PaymentService();
48+
$invoiceService = new \Moyasar\Providers\InvoiceService();
49+
50+
$payment = $paymentService->fetch('760878ec-d1d3-5f72-9056-191683f55872');
51+
$invoice = $invoiceService->fetch('760878ec-d1d3-5f72-9056-191683f55872');
52+
```
53+
54+
The returned result is of type `\Moyasar\Payment` and `\Moyasar\Invoice`
55+
respectively and has the ability to perform operations on that
56+
payment instance like `update`, `refund`, `capture`, and `void`, and operations
57+
on the other invoice instance like `update` and `cancel`.
58+
59+
#### Payment and Invoice Listing
60+
61+
Before:
62+
63+
```php
64+
$payments = \Moyasar\Payment::all();
65+
$invoices = \Moyasar\Invoice::all();
66+
```
67+
68+
Listing payments or invoices using `list` method in both `PaymentService` and `InvoiceService` class
69+
returns a `PaginationResult` instance:
70+
71+
```php
72+
$paymentService = new \Moyasar\Providers\PaymentService();
73+
$invoiceService = new \Moyasar\Providers\InvoiceService();
74+
75+
$search = \Moyasar\Search::query();
76+
$search = $search->createdAfter('date');
77+
$search = $search->createdBefore('date');
78+
$search = $search->id('id');
79+
$search = $search->page('page-number-to-list');
80+
$search = $search->source('payment-source-type');
81+
$search = $search->status('status');
82+
83+
$paymentListing = $paymentService->all($search);
84+
$payments = $paymentListing->result;
85+
86+
$invoiceListing = $invoiceService->all();
87+
$invoices = $invoiceListing->result;
88+
89+
$invoiceListing->currentPage; // Current Page
90+
$invoiceListing->nextPage; // Next Page or null
91+
$invoiceListing->previousPage; // Previous Page or null
92+
$invoiceListing->totalCount; // Total Invoices
93+
$invoiceListing->totalPages; // Total Pages
94+
```
95+
96+
---
97+
98+
### Removed
99+
* `Client` class
100+
* `HttpRequestNotFound` class
101+
* `Invoice` class (Used to perform all invoice operations)
102+
* `Payment` class (Used to perform all payment operations)
103+
104+
### Added
105+
* `Moyasar` class that stores API keys and version information
106+
* `HttpClient` interface
107+
* `HttpClient` class, implements all HTTP transactions
108+
* `Resource` class
109+
* `OnlineResource` class that represent resources that can perform some operations
110+
* `Invoice` class, extends `OnlineResource`, used to perform operations related to a single invoice
111+
* `Payment` class, extends `OnlineResource`
112+
* `InvoiceService` service class, used to create, fetch, and list invoices
113+
* `PaymentService` service class, used to fetch, and list payments
114+
* `Search` class, used to provide search parameters to list methods in `InvoiceService` and `PaymentService`
115+
* `Source` class to represent a payment source for `Payment`
116+
* `CreditCard` class that represents `creditcard` payment method in Moyasar's API
117+
* `Sadad` class that represents `sadad` payment method in Moyasar's API
118+
* `PaginationResult` class, returned by list methods on `InvoiceService` and `PaymentService`
119+
* `BaseException` as a base for all library exceptions
120+
* `ApiException` class that represent error returned by Moyasar's API
121+
* `ValidationException` thrown when data validation fails before sending a request to the backend
122+
* `Invoice` facade for Laravel
123+
* `Payment` facade for Laravel
124+
* `LaravelServiceProvider` class, used to automatically register Moyasar's services in Laravel's service container
125+
* `GuzzleClientFactory` factory class
126+
* Unit Testing
127+
* Laravel Configuration File `config/config.php`
128+
129+
### Changes
130+
* The library now requires PHP version `5.6.0` or higher instead of `5.5.0`
131+
132+
133+
## [0.5.0] - 2019-03-27
134+
### Removed
135+
* Disabled the ability to create payments from the library. We recommend you to use [Moyasar Payment Form]
136+
137+
### Changes
138+
* In this version, we change our library name to be only the word `moyasar`.
139+
140+
141+
## [v0.4.3] - 2019-01-28
142+
### Added
143+
* Add ability in PHP wrappers to do:
144+
* Update a payment.
145+
* Update an invoice.
146+
* Cancel an invoice.
147+
148+
149+
## [v0.4.0] - 2016-11-02
150+
### Changed
151+
* This version has a breaking change. We rename our main classes to be single not plural. So `Payments` class now `Payment` and `Invoices` changed to `Invoice`
152+
153+
154+
## [v0.3.5] - 2016-09-05
155+
### Changed
156+
* Fixed List Method
157+
158+
159+
## [v0.3.0] - 2016-07-19
160+
* First Release
161+
162+
163+
[Unreleased]: https://github.com/moyasar/moyasar-php/compare/1.0.0...HEAD
164+
[1.0.0]: https://github.com/moyasar/moyasar-php/releases/tag/1.0.0
165+
[0.5.0]: https://github.com/moyasar/moyasar-php/releases/tag/0.5.0
166+
[v0.4.3]: https://github.com/moyasar/moyasar-php/releases/tag/v0.4.3
167+
[v0.4.0]: https://github.com/moyasar/moyasar-php/releases/tag/v0.4.0
168+
[v0.3.5]: https://github.com/moyasar/moyasar-php/releases/tag/v0.3.5
169+
[v0.3.0]: https://github.com/moyasar/moyasar-php/releases/tag/v0.3.0
170+
171+
[Moyasar Payment Form]: https://moyasar.com/docs/payments/create-payment/mpf/

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Moyasar
3+
Copyright (c) 2020 Moyasar
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)