File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 13
13
"require" : {
14
14
"php" : " >=5.5.9" ,
15
15
"illuminate/support" : " 5.2.*" ,
16
- "guzzlehttp/guzzle" : " ~5.0"
16
+ "guzzlehttp/guzzle" : " ~5.0" ,
17
+ "ramsey/uuid" : " 3.1.*"
17
18
},
18
19
"require-dev" : {
19
20
"phpunit/phpunit" : " 4.*" ,
Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Support \Facades \Facade ;
6
6
7
- class PaystackFacade extends Facade {
7
+ class Paystack extends Facade {
8
8
/**
9
9
* Get the registered name of the component.
10
10
*
Original file line number Diff line number Diff line change 3
3
namespace Unicodeveloper \Paystack ;
4
4
5
5
use GuzzleHttp \Client ;
6
+ use Ramsey \Uuid \Uuid ;
7
+ use Ramsey \Uuid \Exception \UnsatisfiedDependencyException ;
6
8
7
9
class Paystack {
8
10
@@ -208,6 +210,30 @@ public function getAccessCode()
208
210
*/
209
211
public function genTranxRef ()
210
212
{
213
+ try {
211
214
215
+ // Generate a version 1 (time-based) UUID object
216
+ $ uuid1 = Uuid::uuid1 ();
217
+ echo $ uuid1 ->toString () . "\n" ; // i.e. e4eaaaf2-d142-11e1-b3e4-080027620cdd
218
+
219
+ // // Generate a version 3 (name-based and hashed with MD5) UUID object
220
+ // $uuid3 = Uuid::uuid3(Uuid::NAMESPACE_DNS, 'php.net');
221
+ // echo $uuid3->toString() . "\n"; // i.e. 11a38b9a-b3da-360f-9353-a5a725514269
222
+
223
+ // // Generate a version 4 (random) UUID object
224
+ // $uuid4 = Uuid::uuid4();
225
+ // echo $uuid4->toString() . "\n"; // i.e. 25769c6c-d34d-4bfe-ba98-e0ee856f3e7a
226
+
227
+ // // Generate a version 5 (name-based and hashed with SHA1) UUID object
228
+ // $uuid5 = Uuid::uuid5(Uuid::NAMESPACE_DNS, 'php.net');
229
+ // echo $uuid5->toString() . "\n"; // i.e. c4a760a8-dbcf-5254-a0d9-6a4474bd1b62
230
+
231
+ } catch (UnsatisfiedDependencyException $ e ) {
232
+
233
+ // Some dependency was not met. Either the method cannot be called on a
234
+ // 32-bit system, or it can, but it relies on Moontoast\Math to be present.
235
+ echo 'Caught exception: ' . $ e ->getMessage () . "\n" ;
236
+
237
+ }
212
238
}
213
239
}
Original file line number Diff line number Diff line change 3
3
namespace Unicodeveloper \Paystack \Test ;
4
4
5
5
use PHPUnit_Framework_TestCase ;
6
+ use Unicodeveloper \Paystack \Paystack ;
6
7
7
8
class PaystackTest extends PHPUnit_Framework_TestCase
8
9
{
@@ -13,4 +14,10 @@ public function testTrueIsTrue()
13
14
{
14
15
$ this ->assertTrue (true );
15
16
}
17
+
18
+ public function testTranxRef ()
19
+ {
20
+ $ paystack = new Paystack ();
21
+ echo $ paystack ->genTranxRef ();
22
+ }
16
23
}
You can’t perform that action at this time.
0 commit comments