Skip to content

Commit dc719b4

Browse files
Navneet RaiNavneet Rai
Navneet Rai
authored and
Navneet Rai
committed
Added Mock Class and Tests
1 parent 566a292 commit dc719b4

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Subscription Billing for Laravel 5
22

3+
[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework)
4+
[![Total Downloads](https://poser.pugx.org/laravel/framework/downloads.svg)](https://packagist.org/packages/laravel/framework)
5+
[![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework)
6+
[![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework)
7+
[![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)
8+
39
laravel-subscription is a simple laravel 5 library for creating subscription billing and handling server notifications.
410

511
---

src/SubscriptionFactory.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,21 @@ class SubscriptionFactory{
1010
protected $serviceClassMap = array();
1111

1212
public function __construct(){
13-
$this->registerService('2checkout', 'Userdesk\\Subscription\\Services\\TwoCheckout');
13+
$this->registerServiceAlias('TwoCheckout', '2checkout');
14+
}
15+
16+
/**
17+
* Builds and returns payment services
18+
*
19+
* It will first try to build an payment service
20+
*
21+
* @param string $serviceName Name of service to create
22+
*
23+
* @return \Userdesk\Subscription\Contracts\Service
24+
*/
25+
26+
public function registerServiceAlias($serviceName, $alias){
27+
$this->registerService($alias, 'Userdesk\\Subscription\\Services\\'.$serviceName);
1428
}
1529

1630
/**
@@ -24,6 +38,11 @@ public function __construct(){
2438
*/
2539
public function createService($serviceName){
2640
$config = Config::get(sprintf("subscription.services.%s", $serviceName));
41+
42+
if(empty($config)){
43+
throw new SubscriptionException(sprintf('No Config exists for Service %s.', $serviceName));
44+
}
45+
2746
$fullyQualifiedServiceName = $this->getFullyQualifiedServiceName($serviceName);
2847
if (class_exists($fullyQualifiedServiceName)) {
2948
return $this->buildService($fullyQualifiedServiceName, $config);

0 commit comments

Comments
 (0)