dev-think-one /
laravel-gocardless-payment
| 1 | <?php |
||
| 2 | |||
| 3 | namespace GoCardlessPayment\MandateCheckout; |
||
| 4 | |||
| 5 | use GoCardlessPayment\Makeable; |
||
| 6 | |||
| 7 | /** |
||
| 8 | * @see https://developer.gocardless.com/api-reference#billing-request-flows-create-a-billing-request-flow |
||
| 9 | */ |
||
| 10 | class ReturnUrls implements \JsonSerializable |
||
| 11 | { |
||
| 12 | use Makeable; |
||
| 13 | |||
| 14 | public readonly string $successUrl; |
||
| 15 | |||
| 16 | public ?string $cancelUrl = null; |
||
| 17 | |||
| 18 | 1 | public function __construct(string $successUrl, ?string $cancelUrl = null) |
|
| 19 | { |
||
| 20 | 1 | $this->successUrl = $successUrl; |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 21 | 1 | $this->cancelUrl = $cancelUrl; |
|
| 22 | } |
||
| 23 | |||
| 24 | 1 | public function jsonSerialize(): array |
|
| 25 | { |
||
| 26 | 1 | return array_filter([ |
|
| 27 | 1 | 'redirect_uri' => $this->successUrl, |
|
| 28 | 1 | 'exit_uri' => $this->cancelUrl ?: $this->successUrl, |
|
| 29 | 1 | ], fn ($i) => ! is_null($i)); |
|
| 30 | } |
||
| 31 | } |
||
| 32 |