Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 258
openapi_spec_hash: 428c1af03dcba08ed165656fb9300a88
config_hash: b0e46656e84a8c26907fbe6dc8116a3d
configured_endpoints: 260
openapi_spec_hash: eedf0dde9526910a946f962e7fec5f3b
config_hash: 3f6bda53c3a322ad2f6e7b5177be7280
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions src/CardDisputes/CardDispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Increase\CardDisputes\CardDispute\Loss;
use Increase\CardDisputes\CardDispute\Network;
use Increase\CardDisputes\CardDispute\ProvisionalCredit;
use Increase\CardDisputes\CardDispute\Rejection;
use Increase\CardDisputes\CardDispute\Status;
use Increase\CardDisputes\CardDispute\Type;
Expand All @@ -20,6 +21,7 @@
* If unauthorized activity occurs on a card, you can create a Card Dispute and we'll work with the card networks to return the funds if appropriate. For more information, see our guide on [card disputes](https://increase.com/documentation/card-disputes).
*
* @phpstan-import-type LossShape from \Increase\CardDisputes\CardDispute\Loss
* @phpstan-import-type ProvisionalCreditShape from \Increase\CardDisputes\CardDispute\ProvisionalCredit
* @phpstan-import-type RejectionShape from \Increase\CardDisputes\CardDispute\Rejection
* @phpstan-import-type VisaShape from \Increase\CardDisputes\CardDispute\Visa
* @phpstan-import-type WinShape from \Increase\CardDisputes\CardDispute\Win
Expand All @@ -35,6 +37,7 @@
* idempotencyKey: string|null,
* loss: null|Loss|LossShape,
* network: Network|value-of<Network>,
* provisionalCredit: null|ProvisionalCredit|ProvisionalCreditShape,
* rejection: null|Rejection|RejectionShape,
* status: Status|value-of<Status>,
* type: Type|value-of<Type>,
Expand Down Expand Up @@ -105,6 +108,12 @@ final class CardDispute implements BaseModel
#[Required(enum: Network::class)]
public string $network;

/**
* If a provisional credit has been provided for the Card Dispute, this will contain details of the provisional credit.
*/
#[Required('provisional_credit')]
public ?ProvisionalCredit $provisionalCredit;

/**
* If the Card Dispute has been rejected, this will contain details of the rejection.
*/
Expand Down Expand Up @@ -166,6 +175,7 @@ final class CardDispute implements BaseModel
* idempotencyKey: ...,
* loss: ...,
* network: ...,
* provisionalCredit: ...,
* rejection: ...,
* status: ...,
* type: ...,
Expand All @@ -189,6 +199,7 @@ final class CardDispute implements BaseModel
* ->withIdempotencyKey(...)
* ->withLoss(...)
* ->withNetwork(...)
* ->withProvisionalCredit(...)
* ->withRejection(...)
* ->withStatus(...)
* ->withType(...)
Expand All @@ -210,6 +221,7 @@ public function __construct()
*
* @param Loss|LossShape|null $loss
* @param Network|value-of<Network> $network
* @param ProvisionalCredit|ProvisionalCreditShape|null $provisionalCredit
* @param Rejection|RejectionShape|null $rejection
* @param Status|value-of<Status> $status
* @param Type|value-of<Type> $type
Expand All @@ -227,6 +239,7 @@ public static function with(
?string $idempotencyKey,
Loss|array|null $loss,
Network|string $network,
ProvisionalCredit|array|null $provisionalCredit,
Rejection|array|null $rejection,
Status|string $status,
Type|string $type,
Expand All @@ -246,6 +259,7 @@ public static function with(
$self['idempotencyKey'] = $idempotencyKey;
$self['loss'] = $loss;
$self['network'] = $network;
$self['provisionalCredit'] = $provisionalCredit;
$self['rejection'] = $rejection;
$self['status'] = $status;
$self['type'] = $type;
Expand Down Expand Up @@ -361,6 +375,20 @@ public function withNetwork(Network|string $network): self
return $self;
}

/**
* If a provisional credit has been provided for the Card Dispute, this will contain details of the provisional credit.
*
* @param ProvisionalCredit|ProvisionalCreditShape|null $provisionalCredit
*/
public function withProvisionalCredit(
ProvisionalCredit|array|null $provisionalCredit
): self {
$self = clone $this;
$self['provisionalCredit'] = $provisionalCredit;

return $self;
}

/**
* If the Card Dispute has been rejected, this will contain details of the rejection.
*
Expand Down
173 changes: 173 additions & 0 deletions src/CardDisputes/CardDispute/ProvisionalCredit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?php

declare(strict_types=1);

namespace Increase\CardDisputes\CardDispute;

use Increase\CardDisputes\CardDispute\ProvisionalCredit\Reversal;
use Increase\Core\Attributes\Required;
use Increase\Core\Concerns\SdkModel;
use Increase\Core\Contracts\BaseModel;

/**
* If a provisional credit has been provided for the Card Dispute, this will contain details of the provisional credit.
*
* @phpstan-import-type ReversalShape from \Increase\CardDisputes\CardDispute\ProvisionalCredit\Reversal
*
* @phpstan-type ProvisionalCreditShape = array{
* amount: int,
* cardholderAccountTransactionID: string,
* providedAt: \DateTimeInterface,
* provisionalCreditFundingAccountTransactionID: string,
* reversal: null|Reversal|ReversalShape,
* }
*/
final class ProvisionalCredit implements BaseModel
{
/** @use SdkModel<ProvisionalCreditShape> */
use SdkModel;

/**
* The amount of the provisional credit in the minor unit of its currency. For dollars, for example, this is cents.
*/
#[Required]
public int $amount;

/**
* The identifier of the Transaction that credited the cardholder's Account.
*/
#[Required('cardholder_account_transaction_id')]
public string $cardholderAccountTransactionID;

/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the provisional credit was provided.
*/
#[Required('provided_at')]
public \DateTimeInterface $providedAt;

/**
* The identifier of the Transaction that debited the provisional credit funding Account.
*/
#[Required('provisional_credit_funding_account_transaction_id')]
public string $provisionalCreditFundingAccountTransactionID;

/**
* If the provisional credit has been reversed, this will contain details of the reversal.
*/
#[Required]
public ?Reversal $reversal;

/**
* `new ProvisionalCredit()` is missing required properties by the API.
*
* To enforce required parameters use
* ```
* ProvisionalCredit::with(
* amount: ...,
* cardholderAccountTransactionID: ...,
* providedAt: ...,
* provisionalCreditFundingAccountTransactionID: ...,
* reversal: ...,
* )
* ```
*
* Otherwise ensure the following setters are called
*
* ```
* (new ProvisionalCredit)
* ->withAmount(...)
* ->withCardholderAccountTransactionID(...)
* ->withProvidedAt(...)
* ->withProvisionalCreditFundingAccountTransactionID(...)
* ->withReversal(...)
* ```
*/
public function __construct()
{
$this->initialize();
}

/**
* Construct an instance from the required parameters.
*
* You must use named parameters to construct any parameters with a default value.
*
* @param Reversal|ReversalShape|null $reversal
*/
public static function with(
int $amount,
string $cardholderAccountTransactionID,
\DateTimeInterface $providedAt,
string $provisionalCreditFundingAccountTransactionID,
Reversal|array|null $reversal,
): self {
$self = new self;

$self['amount'] = $amount;
$self['cardholderAccountTransactionID'] = $cardholderAccountTransactionID;
$self['providedAt'] = $providedAt;
$self['provisionalCreditFundingAccountTransactionID'] = $provisionalCreditFundingAccountTransactionID;
$self['reversal'] = $reversal;

return $self;
}

/**
* The amount of the provisional credit in the minor unit of its currency. For dollars, for example, this is cents.
*/
public function withAmount(int $amount): self
{
$self = clone $this;
$self['amount'] = $amount;

return $self;
}

/**
* The identifier of the Transaction that credited the cardholder's Account.
*/
public function withCardholderAccountTransactionID(
string $cardholderAccountTransactionID
): self {
$self = clone $this;
$self['cardholderAccountTransactionID'] = $cardholderAccountTransactionID;

return $self;
}

/**
* The [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date and time at which the provisional credit was provided.
*/
public function withProvidedAt(\DateTimeInterface $providedAt): self
{
$self = clone $this;
$self['providedAt'] = $providedAt;

return $self;
}

/**
* The identifier of the Transaction that debited the provisional credit funding Account.
*/
public function withProvisionalCreditFundingAccountTransactionID(
string $provisionalCreditFundingAccountTransactionID
): self {
$self = clone $this;
$self['provisionalCreditFundingAccountTransactionID'] = $provisionalCreditFundingAccountTransactionID;

return $self;
}

/**
* If the provisional credit has been reversed, this will contain details of the reversal.
*
* @param Reversal|ReversalShape|null $reversal
*/
public function withReversal(Reversal|array|null $reversal): self
{
$self = clone $this;
$self['reversal'] = $reversal;

return $self;
}
}
Loading