-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for saved payment methods
- Loading branch information
1 parent
f3be3d4
commit e362095
Showing
30 changed files
with
1,165 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities\Collections; | ||
|
||
use Paddle\SDK\Entities\PaymentMethod; | ||
|
||
class PaymentMethodCollection extends Collection | ||
{ | ||
public static function from(array $itemsData, Paginator|null $paginator = null): self | ||
{ | ||
return new self( | ||
array_map(fn (array $item): PaymentMethod => PaymentMethod::from($item), $itemsData), | ||
$paginator, | ||
); | ||
} | ||
|
||
public function current(): PaymentMethod | ||
{ | ||
return parent::current(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities; | ||
|
||
use Paddle\SDK\Notifications\Entities\DateTime; | ||
use Paddle\SDK\Notifications\Entities\Entity; | ||
|
||
class CustomerAuthToken implements Entity | ||
{ | ||
private function __construct( | ||
public string $customerAuthToken, | ||
public \DateTimeInterface $expiresAt, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
customerAuthToken: $data['customer_auth_token'], | ||
expiresAt: DateTime::from($data['expires_at']), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities; | ||
|
||
use Paddle\SDK\Entities\Shared\Card; | ||
use Paddle\SDK\Entities\Shared\Paypal; | ||
use Paddle\SDK\Entities\Shared\SavedPaymentMethodOrigin; | ||
use Paddle\SDK\Entities\Shared\SavedPaymentMethodType; | ||
|
||
class PaymentMethod implements Entity | ||
{ | ||
private function __construct( | ||
public string $id, | ||
public string $customerId, | ||
public string $addressId, | ||
public SavedPaymentMethodType $type, | ||
public Card|null $card, | ||
public Paypal|null $paypal, | ||
public SavedPaymentMethodOrigin $origin, | ||
public \DateTimeInterface|null $savedAt, | ||
public \DateTimeInterface|null $updatedAt, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
id: $data['id'], | ||
customerId: $data['customer_id'], | ||
addressId: $data['address_id'], | ||
type: SavedPaymentMethodType::from($data['type']), | ||
card: isset($data['card']) ? Card::from($data['card']) : null, | ||
paypal: isset($data['paypal']) ? Paypal::from($data['paypal']) : null, | ||
origin: SavedPaymentMethodOrigin::from($data['origin']), | ||
savedAt: isset($data['saved_at']) ? DateTime::from($data['saved_at']) : null, | ||
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities\Shared; | ||
|
||
class Paypal | ||
{ | ||
private function __construct( | ||
public string $email, | ||
public string $reference, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
$data['email'], | ||
$data['reference'], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities\Shared; | ||
|
||
use Paddle\SDK\PaddleEnum; | ||
|
||
/** | ||
* @method static SavedPaymentMethodOrigin SavedDuringPurchase() | ||
* @method static SavedPaymentMethodOrigin Subscription() | ||
*/ | ||
final class SavedPaymentMethodOrigin extends PaddleEnum | ||
{ | ||
private const SavedDuringPurchase = 'saved_during_purchase'; | ||
private const Subscription = 'subscription'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Entities\Shared; | ||
|
||
use Paddle\SDK\PaddleEnum; | ||
|
||
/** | ||
* @method static SavedPaymentMethodType Alipay() | ||
* @method static SavedPaymentMethodType ApplePay() | ||
* @method static SavedPaymentMethodType Card() | ||
* @method static SavedPaymentMethodType GooglePay() | ||
* @method static SavedPaymentMethodType Paypal() | ||
*/ | ||
final class SavedPaymentMethodType extends PaddleEnum | ||
{ | ||
private const Alipay = 'alipay'; | ||
private const ApplePay = 'apple_pay'; | ||
private const Card = 'card'; | ||
private const GooglePay = 'google_pay'; | ||
private const Paypal = 'paypal'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Notifications\Entities; | ||
|
||
use Paddle\SDK\Entities\DateTime; | ||
use Paddle\SDK\Notifications\Entities\Shared\SavedPaymentMethodDeletionReason; | ||
use Paddle\SDK\Notifications\Entities\Shared\SavedPaymentMethodOrigin; | ||
use Paddle\SDK\Notifications\Entities\Shared\SavedPaymentMethodType; | ||
|
||
class DeletedPaymentMethod implements Entity | ||
{ | ||
private function __construct( | ||
public string $id, | ||
public string $customerId, | ||
public string $addressId, | ||
public SavedPaymentMethodType $type, | ||
public SavedPaymentMethodOrigin $origin, | ||
public \DateTimeInterface|null $savedAt, | ||
public \DateTimeInterface|null $updatedAt, | ||
public SavedPaymentMethodDeletionReason $deletionReason, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
id: $data['id'], | ||
customerId: $data['customer_id'], | ||
addressId: $data['address_id'], | ||
type: SavedPaymentMethodType::from($data['type']), | ||
origin: SavedPaymentMethodOrigin::from($data['origin']), | ||
savedAt: isset($data['saved_at']) ? DateTime::from($data['saved_at']) : null, | ||
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null, | ||
deletionReason: SavedPaymentMethodDeletionReason::from($data['deletion_reason']), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Notifications\Entities; | ||
|
||
use Paddle\SDK\Entities\DateTime; | ||
use Paddle\SDK\Notifications\Entities\Shared\SavedPaymentMethodOrigin; | ||
use Paddle\SDK\Notifications\Entities\Shared\SavedPaymentMethodType; | ||
|
||
class PaymentMethod implements Entity | ||
{ | ||
private function __construct( | ||
public string $id, | ||
public string $customerId, | ||
public string $addressId, | ||
public SavedPaymentMethodType $type, | ||
public SavedPaymentMethodOrigin $origin, | ||
public \DateTimeInterface|null $savedAt, | ||
public \DateTimeInterface|null $updatedAt, | ||
) { | ||
} | ||
|
||
public static function from(array $data): self | ||
{ | ||
return new self( | ||
id: $data['id'], | ||
customerId: $data['customer_id'], | ||
addressId: $data['address_id'], | ||
type: SavedPaymentMethodType::from($data['type']), | ||
origin: SavedPaymentMethodOrigin::from($data['origin']), | ||
savedAt: isset($data['saved_at']) ? DateTime::from($data['saved_at']) : null, | ||
updatedAt: isset($data['updated_at']) ? DateTime::from($data['updated_at']) : null, | ||
); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Notifications/Entities/Shared/SavedPaymentMethodDeletionReason.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* |------ | ||
* | ! Generated code ! | ||
* | Altering this code will result in changes being overwritten | | ||
* |-------------------------------------------------------------|. | ||
*/ | ||
|
||
namespace Paddle\SDK\Notifications\Entities\Shared; | ||
|
||
use Paddle\SDK\PaddleEnum; | ||
|
||
/** | ||
* @method static SavedPaymentMethodDeletionReason ReplacedByNewerVersion() | ||
* @method static SavedPaymentMethodDeletionReason Api() | ||
*/ | ||
final class SavedPaymentMethodDeletionReason extends PaddleEnum | ||
{ | ||
private const ReplacedByNewerVersion = 'replaced_by_newer_version'; | ||
private const Api = 'api'; | ||
} |
Oops, something went wrong.