1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stadem\VivaPayments\Enums; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @see https://developer.vivawallet.com/integration-reference/response-codes/#statusid-parameter |
7
|
|
|
*/ |
8
|
|
|
enum TransactionStatus: string |
9
|
|
|
{ |
10
|
|
|
/** The transaction has been completed successfully (PAYMENT SUCCESSFUL) */ |
11
|
|
|
case PaymentSuccessful = 'F'; |
12
|
|
|
|
13
|
|
|
/** The transaction is in progress (PAYMENT PENDING) */ |
14
|
|
|
case PaymentPending = 'A'; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* The transaction has been captured |
18
|
|
|
* (the C status refers to the original pre-auth transaction which has now been captured; |
19
|
|
|
* the capture will be a separate transaction with status F) |
20
|
|
|
*/ |
21
|
|
|
case Captured = 'C'; |
22
|
|
|
|
23
|
|
|
/** The transaction was not completed successfully (PAYMENT UNSUCCESSFUL) */ |
24
|
|
|
case Error = 'E'; |
25
|
|
|
|
26
|
|
|
/** The transaction has been fully or partially refunded */ |
27
|
|
|
case Refunded = 'R'; |
28
|
|
|
|
29
|
|
|
/** The transaction was cancelled by the merchant */ |
30
|
|
|
case Cancelled = 'X'; |
31
|
|
|
|
32
|
|
|
/** The cardholder has disputed the transaction with the issuing Bank */ |
33
|
|
|
case Disputed = 'M'; |
34
|
|
|
|
35
|
|
|
/** Dispute Awaiting Response */ |
36
|
|
|
case DisputeAwaiting = 'MA'; |
37
|
|
|
|
38
|
|
|
/** Dispute in Progress */ |
39
|
|
|
case DisputeInProgress = 'MI'; |
40
|
|
|
|
41
|
|
|
/** A disputed transaction has been refunded (Dispute Lost) */ |
42
|
|
|
case DisputeLost = 'ML'; |
43
|
|
|
|
44
|
|
|
/** Dispute Won */ |
45
|
|
|
case DisputeWon = 'MW'; |
46
|
|
|
|
47
|
|
|
/** Suspected Dispute */ |
48
|
|
|
case DisputeSuspected = 'MS'; |
49
|
|
|
|
50
|
|
|
|
51
|
|
|
public static function fromName(string $name): string |
52
|
|
|
{ |
53
|
|
|
foreach (self::cases() as $status) { |
54
|
|
|
if( $name === $status->name ){ |
|
|
|
|
55
|
|
|
return $status->value; |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
throw new \ValueError("$name is not a valid backing value for enum " . self::class ); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
|
62
|
|
|
public static function fromValue(string $value): string |
63
|
|
|
{ |
64
|
|
|
foreach (self::cases() as $status) { |
65
|
|
|
if( $value === $status->value ){ |
66
|
|
|
return $status->name; |
|
|
|
|
67
|
|
|
} |
68
|
|
|
} |
69
|
|
|
throw new \ValueError("$value is not a valid backing value for enum " . self::class ); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
|
74
|
|
|
|
75
|
|
|
|
76
|
|
|
} |