@@ -113,20 +113,14 @@ public function makePaymentRequest()
113
113
}
114
114
115
115
116
- private function setHttpResponse ($ relativeUrl , $ method , $ body = []){
117
-
116
+ private function setHttpResponse ($ relativeUrl , $ method , $ body = [])
117
+ {
118
118
if (is_null ($ method )){
119
-
120
119
throw new isNullException ("Empty method not allowed " );
121
-
122
- }else {
123
-
124
- $ this ->response = $ this ->client ->{strtolower ($ method )}($ this ->baseUrl . $ relativeUrl , $ body );
125
-
126
- return $ this ;
127
-
128
120
}
129
121
122
+ $ this ->response = $ this ->client ->{strtolower ($ method )}($ this ->baseUrl . $ relativeUrl , ["body " => json_encode ($ body )]);
123
+ return $ this ;
130
124
}
131
125
132
126
/**
@@ -298,11 +292,8 @@ public function createPlan(){
298
292
* @return array
299
293
*/
300
294
public function fetchPlan ($ plan_code ){
301
-
302
295
$ this ->setRequestOptions ();
303
-
304
296
return $ this ->setHttpResponse ('/plan/ ' . $ plan_code , 'GET ' , [])->getResponse ();
305
-
306
297
}
307
298
308
299
/**
@@ -311,7 +302,6 @@ public function fetchPlan($plan_code){
311
302
* @return array
312
303
*/
313
304
public function updatePlan ($ plan_code ){
314
-
315
305
$ data = [
316
306
"name " => request ()->name ,
317
307
"description " => request ()->desc ,
@@ -323,17 +313,14 @@ public function updatePlan($plan_code){
323
313
];
324
314
325
315
$ this ->setRequestOptions ();
326
-
327
316
return $ this ->setHttpResponse ('/plan/ ' . $ plan_code , 'PUT ' , $ data )->getResponse ();
328
-
329
317
}
330
318
331
319
/**
332
320
* Create a customer
333
321
* @return array
334
322
*/
335
323
public function createCustomer (){
336
-
337
324
$ data = [
338
325
"email " => request ()->email ,
339
326
"first_name " => request ()->fname ,
@@ -344,22 +331,18 @@ public function createCustomer(){
344
331
];
345
332
346
333
$ this ->setRequestOptions ();
347
-
348
334
$ this ->setHttpResponse ('/customer ' , 'POST ' , $ data );
349
-
350
335
}
351
336
352
337
/**
353
338
* Fetch a customer based on id or code
354
339
* @param $customer_id
355
340
* @return array
356
341
*/
357
- public function fetchCustomer ($ customer_id ){
358
-
342
+ public function fetchCustomer ($ customer_id )
343
+ {
359
344
$ this ->setRequestOptions ();
360
-
361
345
return $ this ->setHttpResponse ('/customer/ ' . $ customer_id , 'GET ' , [])->getResponse ();
362
-
363
346
}
364
347
365
348
/**
@@ -368,7 +351,6 @@ public function fetchCustomer($customer_id){
368
351
* @return array
369
352
*/
370
353
public function updateCustomer ($ customer_id ){
371
-
372
354
$ data = [
373
355
"email " => request ()->email ,
374
356
"first_name " => request ()->fname ,
@@ -379,43 +361,36 @@ public function updateCustomer($customer_id){
379
361
];
380
362
381
363
$ this ->setRequestOptions ();
382
-
383
364
return $ this ->setHttpResponse ('/customer/ ' . $ customer_id , 'PUT ' , $ data )->getResponse ();
384
-
385
365
}
386
366
387
367
/**
388
368
* Export tranactions in .CSV
389
369
* @return array
390
370
*/
391
371
public function exportTransactions (){
392
-
393
372
$ data = [
394
373
"from " => request ()->from ,
395
374
"to " => request ()->to ,
396
375
'settled ' => request ()->settled
397
376
];
398
377
399
378
$ this ->setRequestOptions ();
400
-
401
379
return $ this ->setHttpResponse ('/transaction/export ' , 'GET ' , $ data )->getResponse ();
402
-
403
380
}
404
381
405
382
/**
406
383
* Create a subscription to a plan from a customer.
407
384
* @return array
408
385
*/
409
386
public function createSubscription (){
410
-
411
387
$ data = [
412
388
"customer " => request ()->customer , //Customer email or code
413
389
"plan " => request ()->plan ,
414
390
"authorization " => request ()->authorization_code
415
391
];
416
392
417
393
$ this ->setRequestOptions ();
418
-
419
394
$ this ->setHttpResponse ('/subscription ' , 'POST ' , $ data );
420
395
}
421
396
@@ -424,89 +399,74 @@ public function createSubscription(){
424
399
* @return array
425
400
*/
426
401
public function enableSubscription (){
427
-
428
402
$ data = [
429
403
"code " => request ()->code ,
430
404
"token " => request ()->token ,
431
405
];
432
406
433
407
$ this ->setRequestOptions ();
434
-
435
408
return $ this ->setHttpResponse ('/subscription/enable ' , 'POST ' , $ data )->getResponse ();
436
-
437
409
}
438
410
439
411
/**
440
412
* Disable a subscription using the subscription code and token
441
413
* @return array
442
414
*/
443
415
public function disableSubscription (){
444
-
445
416
$ data = [
446
417
"code " => request ()->code ,
447
418
"token " => request ()->token ,
448
419
];
449
420
450
421
$ this ->setRequestOptions ();
451
-
452
422
return $ this ->setHttpResponse ('/subscription/disable ' , 'POST ' , $ data )->getResponse ();
453
-
454
423
}
455
424
456
425
/**
457
426
* Fetch details about a certain subscription
458
427
* @param $subscription_id
459
428
* @return array
460
429
*/
461
- public function fetchSubscription ($ subscription_id ){
462
-
430
+ public function fetchSubscription ($ subscription_id )
431
+ {
463
432
$ this ->setRequestOptions ();
464
-
465
433
return $ this ->setHttpResponse ('/subscription/ ' .$ subscription_id , 'GET ' , [])->getResponse ();
466
-
467
434
}
468
435
469
436
/**
470
437
* Create pages you can share with users using the returned slug
471
438
* @return array
472
439
*/
473
440
public function createPage (){
474
-
475
441
$ data = [
476
442
"name " => request ()->name ,
477
443
"description " => request ()->description ,
478
444
"amount " => request ()->amount
479
445
];
480
446
481
447
$ this ->setRequestOptions ();
482
-
483
448
$ this ->setHttpResponse ('/page ' , 'POST ' , $ data );
484
-
485
449
}
486
450
487
451
/**
488
452
* Fetches all the pages the merchant has
489
453
* @return array
490
454
*/
491
- public function getAllPages (){
492
-
455
+ public function getAllPages ()
456
+ {
493
457
$ this ->setRequestOptions ();
494
-
495
458
return $ this ->setHttpResponse ('/page ' , 'GET ' , [])->getResponse ();
496
-
497
459
}
498
460
499
461
/**
500
462
* Fetch details about a certain page using its id or slug
501
463
* @param $page_id
502
464
* @return array
503
465
*/
504
- public function fetchPage ($ page_id ){
505
-
466
+ public function fetchPage ($ page_id )
467
+ {
506
468
$ this ->setRequestOptions ();
507
-
508
469
return $ this ->setHttpResponse ('/page/ ' .$ page_id , 'GET ' , [])->getResponse ();
509
-
510
470
}
511
471
512
472
/**
@@ -515,17 +475,14 @@ public function fetchPage($page_id){
515
475
* @return array
516
476
*/
517
477
public function updatePage ($ page_id ){
518
-
519
478
$ data = [
520
479
"name " => request ()->name ,
521
480
"description " => request ()->description ,
522
481
"amount " => request ()->amount
523
482
];
524
483
525
484
$ this ->setRequestOptions ();
526
-
527
485
return $ this ->setHttpResponse ('/page/ ' .$ page_id , 'PUT ' , $ data )->getResponse ();
528
-
529
486
}
530
487
531
488
}
0 commit comments