Skip to content

Commit bd9bc80

Browse files
author
Morten Bak
committed
fix make payment link
1 parent 4f7a41b commit bd9bc80

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ $createdPayment = \Netbums\Quickpay\Quickpay::api()->payments()->create(
129129
```
130130
After a payment is created you can create a payment link for it, and redirect the user to the payment link.
131131

132+
#### Create a payment link
133+
```php
134+
$paymentLinkData = new \Netbums\Quickpay\DataObjects\PaymentLink(
135+
id: 437296737,
136+
amount: 100
137+
);
138+
139+
$paymentLink = \Netbums\Quickpay\Quickpay::api()->payments()->createLink($paymentLinkData);
140+
```
141+
This will return a URL, that you can redirect the user to.
142+
132143
#### Update a payment
133144
```php
134145
```

src/DataObjects/PaymentLink.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
public function __construct(
88
public int $id, // transaction id
99
public int $amount, // Amount to authorize
10-
public ?string $language,
11-
public ?string $continue_url,
12-
public ?string $cancel_url,
13-
public ?string $callback_url,
10+
public ?string $language = null,
11+
public ?string $continue_url = null,
12+
public ?string $cancel_url = null,
13+
public ?string $callback_url = null,
1414
) {
1515
}
1616

@@ -19,10 +19,10 @@ public static function fromArray(array $data): static
1919
return new static(
2020
id: $data['id'],
2121
amount: $data['amount'],
22-
language: $data['language'],
23-
continue_url: $data['continue_url'],
24-
cancel_url: $data['cancel_url'],
25-
callback_url: $data['callback_url'],
22+
language: $data['language'] ?? null,
23+
continue_url: $data['continue_url'] ?? null,
24+
cancel_url: $data['cancel_url'] ?? null,
25+
callback_url: $data['callback_url'] ?? null,
2626
);
2727
}
2828

src/Resources/PaymentResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ public function create(Payment $payment): array
7070
*
7171
* @throws CreatePaymentLinkFailed
7272
*/
73-
public function createLink(int $id, PaymentLink $paymentLink): array
73+
public function createLink(PaymentLink $paymentLink): array
7474
{
75+
$id = $paymentLink->id;
7576
$this->method = 'put';
7677
$this->endpoint = 'payments/'.$id.'/link';
7778
$this->data = $paymentLink->toArray();

0 commit comments

Comments
 (0)