|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* Copyright Iain Cambridge 2020-2023. |
|
7
|
|
|
* |
|
8
|
|
|
* Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license. |
|
9
|
|
|
* |
|
10
|
|
|
* Change Date: TBD ( 3 years after 2.2.0 release ) |
|
11
|
|
|
* |
|
12
|
|
|
* On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file. |
|
13
|
|
|
*/ |
|
14
|
|
|
|
|
15
|
|
|
namespace Parthenon\Billing\Response; |
|
16
|
|
|
|
|
17
|
|
|
use Parthenon\Billing\Entity\Subscription; |
|
18
|
|
|
use Symfony\Component\Validator\ConstraintViolationListInterface; |
|
19
|
|
|
|
|
20
|
|
|
class StartSubscriptionResponse |
|
21
|
|
|
{ |
|
22
|
|
|
public const CODE_REQUEST_INVALID = '320000'; |
|
23
|
|
|
public const CODE_NO_BILLING_DETAILS = '320001'; |
|
24
|
|
|
public const CODE_UNSUPPORTED_PAYMENT_PROVIDER = '320002'; |
|
25
|
|
|
public const CODE_PLAN_NOT_FOUND = '320003'; |
|
26
|
|
|
public const CODE_PLAN_PRICE_NOT_FOUND = '320004'; |
|
27
|
|
|
public const CODE_GENERAL_ERROR = '320005'; |
|
28
|
|
|
|
|
29
|
|
|
public static function createGeneralError(): array |
|
30
|
|
|
{ |
|
31
|
|
|
return [ |
|
32
|
|
|
'success' => false, |
|
33
|
|
|
'code' => static::CODE_GENERAL_ERROR, |
|
34
|
|
|
]; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public static function createInvalidRequestResponse(ConstraintViolationListInterface $errors): array |
|
|
|
|
|
|
38
|
|
|
{ |
|
39
|
|
|
return [ |
|
40
|
|
|
'success' => false, |
|
41
|
|
|
'code' => static::CODE_REQUEST_INVALID, |
|
42
|
|
|
]; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public static function createNoBillingDetails(): array |
|
46
|
|
|
{ |
|
47
|
|
|
return [ |
|
48
|
|
|
'success' => false, |
|
49
|
|
|
'code' => static::CODE_NO_BILLING_DETAILS, |
|
50
|
|
|
]; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public static function createUnsupportedPaymentProvider(): array |
|
54
|
|
|
{ |
|
55
|
|
|
return [ |
|
56
|
|
|
'success' => false, |
|
57
|
|
|
'code' => static::CODE_UNSUPPORTED_PAYMENT_PROVIDER, |
|
58
|
|
|
]; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public static function createPlanNotFound(): array |
|
62
|
|
|
{ |
|
63
|
|
|
return [ |
|
64
|
|
|
'success' => false, |
|
65
|
|
|
'code' => static::CODE_PLAN_NOT_FOUND, |
|
66
|
|
|
]; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
public static function createPlanPriceNotFound(): array |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
|
|
'success' => false, |
|
73
|
|
|
'code' => static::CODE_PLAN_PRICE_NOT_FOUND, |
|
74
|
|
|
]; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public static function createSuccessResponse(Subscription $subscription): array |
|
|
|
|
|
|
78
|
|
|
{ |
|
79
|
|
|
return [ |
|
80
|
|
|
'success' => true, |
|
81
|
|
|
]; |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.