Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple API changes #1007

Merged
merged 3 commits into from
Sep 2, 2020
Merged
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ matrix:

env:
global:
- STRIPE_MOCK_VERSION=0.95.0
- STRIPE_MOCK_VERSION=0.98.0
cache:
directories:
- $HOME/.composer/cache/files
Expand Down
1 change: 1 addition & 0 deletions lib/BankAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* @property null|string|\Stripe\Account $account The ID of the account that the bank account is associated with.
* @property null|string $account_holder_name The name of the person or business that owns the bank account.
* @property null|string $account_holder_type The type of entity that holds the account. This can be either <code>individual</code> or <code>company</code>.
* @property null|string[] $available_payout_methods A set of available payout methods for this bank account. Only values from this set should be passed as the <code>method</code> when creating a payout.
* @property null|string $bank_name Name of the bank associated with the routing number (e.g., <code>WELLS FARGO</code>).
* @property string $country Two-letter ISO code representing the country the bank account is located in.
* @property string $currency Three-letter <a href="https://stripe.com/docs/payouts">ISO code for the currency</a> paid out to the bank account.
Expand Down
2 changes: 1 addition & 1 deletion lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @property null|string $address_state State/County/Province/Region.
* @property null|string $address_zip ZIP or postal code.
* @property null|string $address_zip_check If <code>address_zip</code> was provided, results of the check: <code>pass</code>, <code>fail</code>, <code>unavailable</code>, or <code>unchecked</code>.
* @property null|string[] $available_payout_methods A set of available payout methods for this card. Will be either <code>[&quot;standard&quot;]</code> or <code>[&quot;standard&quot;, &quot;instant&quot;]</code>. Only values from this set should be passed as the <code>method</code> when creating a transfer.
* @property null|string[] $available_payout_methods A set of available payout methods for this card. Only values from this set should be passed as the <code>method</code> when creating a payout.
* @property string $brand Card brand. Can be <code>American Express</code>, <code>Diners Club</code>, <code>Discover</code>, <code>JCB</code>, <code>MasterCard</code>, <code>UnionPay</code>, <code>Visa</code>, or <code>Unknown</code>.
* @property null|string $country Two-letter ISO code representing the country of the card. You could use this attribute to get a sense of the international breakdown of cards you've collected.
* @property null|string $currency
Expand Down
5 changes: 5 additions & 0 deletions lib/Checkout/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
* @property null|string $mode The mode of the Checkout Session, one of <code>payment</code>, <code>setup</code>, or <code>subscription</code>.
* @property null|string|\Stripe\PaymentIntent $payment_intent The ID of the PaymentIntent for Checkout Sessions in <code>payment</code> mode.
* @property string[] $payment_method_types A list of the types of payment methods (e.g. card) this Checkout Session is allowed to accept.
* @property string $payment_status The payment status of the Checkout Session, one of <code>paid</code>, <code>unpaid</code>, or <code>no_payment_required</code>. You can use this value to decide when to fulfill your customer's order.
* @property null|string|\Stripe\SetupIntent $setup_intent The ID of the SetupIntent for Checkout Sessions in <code>setup</code> mode.
* @property null|\Stripe\StripeObject $shipping Shipping information for this Checkout Session.
* @property null|\Stripe\StripeObject $shipping_address_collection When set, provides configuration for Checkout to collect a shipping address from a customer.
Expand All @@ -60,6 +61,10 @@ class Session extends \Stripe\ApiResource
const BILLING_ADDRESS_COLLECTION_AUTO = 'auto';
const BILLING_ADDRESS_COLLECTION_REQUIRED = 'required';

const PAYMENT_STATUS_NO_PAYMENT_REQUIRED = 'no_payment_required';
const PAYMENT_STATUS_PAID = 'paid';
const PAYMENT_STATUS_UNPAID = 'unpaid';

const SUBMIT_TYPE_AUTO = 'auto';
const SUBMIT_TYPE_BOOK = 'book';
const SUBMIT_TYPE_DONATE = 'donate';
Expand Down
23 changes: 23 additions & 0 deletions lib/Issuing/Dispute.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@
*
* @property string $id Unique identifier for the object.
* @property string $object String representing the object's type. Objects of the same type share the same value.
* @property int $amount Disputed amount. Usually the amount of the <code>disputed_transaction</code>, but can differ (usually because of currency fluctuation).
* @property null|\Stripe\BalanceTransaction[] $balance_transactions List of balance transactions associated with the dispute.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $currency The currency the <code>disputed_transaction</code> was made in.
* @property \Stripe\StripeObject $evidence
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
* @property string $status Current status of the dispute.
* @property string|\Stripe\Issuing\Transaction $transaction The transaction being disputed.
*/
class Dispute extends \Stripe\ApiResource
Expand All @@ -27,4 +33,21 @@ class Dispute extends \Stripe\ApiResource
use \Stripe\ApiOperations\Create;
use \Stripe\ApiOperations\Retrieve;
use \Stripe\ApiOperations\Update;

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return Dispute the submited dispute
*/
public function submit($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/submit';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}
}
1 change: 1 addition & 0 deletions lib/Issuing/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
* @property null|string|\Stripe\Issuing\Cardholder $cardholder The cardholder to whom this transaction belongs.
* @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
* @property string $currency Three-letter <a href="https://www.iso.org/iso-4217-currency-codes.html">ISO currency code</a>, in lowercase. Must be a <a href="https://stripe.com/docs/currencies">supported currency</a>.
* @property null|string|\Stripe\Issuing\Dispute $dispute If you've disputed the transaction, the ID of the dispute.
* @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
* @property int $merchant_amount The amount that the merchant will receive, denominated in <code>merchant_currency</code> and in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a>. It will be different from <code>amount</code> if the merchant is taking payment in a different currency.
* @property string $merchant_currency The currency with which the merchant is taking payment.
Expand Down
2 changes: 1 addition & 1 deletion lib/Reporting/ReportRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @property null|string $error If something should go wrong during the run, a message about the failure (populated when <code>status=failed</code>).
* @property bool $livemode Always <code>true</code>: reports can only be run on live-mode data.
* @property \Stripe\StripeObject $parameters
* @property string $report_type The ID of the <a href="https://stripe.com/docs/reporting/statements/api#report-types">report type</a> to run, such as <code>&quot;balance.summary.1&quot;</code>.
* @property string $report_type The ID of the <a href="https://stripe.com/docs/reports/report-types">report type</a> to run, such as <code>&quot;balance.summary.1&quot;</code>.
* @property null|\Stripe\File $result The file object representing the result of the report run (populated when <code>status=succeeded</code>).
* @property string $status Status of this report run. This will be <code>pending</code> when the run is initially created. When the run finishes, this will be set to <code>succeeded</code> and the <code>result</code> field will be populated. Rarely, we may encounter an error, at which point this will be set to <code>failed</code> and the <code>error</code> field will be populated.
* @property null|int $succeeded_at Timestamp at which this run successfully finished (populated when <code>status=succeeded</code>). Measured in seconds since the Unix epoch.
Expand Down
20 changes: 20 additions & 0 deletions lib/Service/Issuing/DisputeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,26 @@ public function retrieve($id, $params = null, $opts = null)
return $this->request('get', $this->buildPath('/v1/issuing/disputes/%s', $id), $params, $opts);
}

/**
* Submits an Issuing <code>Dispute</code> to the card network. Stripe validates
* that all evidence fields required for the dispute’s reason are present. For more
* details, see <a
* href="/docs/issuing/purchases/disputes#dispute-reasons-and-evidence">Dispute
* reasons and evidence</a>.
*
* @param string $id
* @param null|array $params
* @param null|array|\Stripe\Util\RequestOptions $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Issuing\Dispute
*/
public function submit($id, $params = null, $opts = null)
{
return $this->request('post', $this->buildPath('/v1/issuing/disputes/%s/submit', $id), $params, $opts);
}

/**
* Updates the specified Issuing <code>Dispute</code> object by setting the values
* of the parameters passed. Any parameters not provided will be left unchanged.
Expand Down
15 changes: 14 additions & 1 deletion tests/Stripe/Issuing/DisputeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ final class DisputeTest extends \PHPUnit\Framework\TestCase

public function testIsCreatable()
{
$params = [];
$params = [
'transaction' => 'ipi_123',
];

$this->expectsRequest(
'post',
Expand Down Expand Up @@ -56,4 +58,15 @@ public function testIsUpdatable()
$resource = Dispute::update(self::TEST_RESOURCE_ID, []);
static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource);
}

public function testIsSubmittable()
{
$resource = Dispute::retrieve(self::TEST_RESOURCE_ID);
$this->expectsRequest(
'post',
'/v1/issuing/disputes/' . self::TEST_RESOURCE_ID . '/submit'
);
$resource->submit();
static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource);
}
}
17 changes: 16 additions & 1 deletion tests/Stripe/Service/Issuing/DisputeServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public function testAll()

public function testCreate()
{
$params = [];
$params = [
'transaction' => 'ipi_123',
];

$this->expectsRequest(
'post',
Expand Down Expand Up @@ -73,4 +75,17 @@ public function testUpdate()
]);
static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource);
}

public function testSubmit()
{
$this->expectsRequest(
'post',
'/v1/issuing/disputes/' . self::TEST_RESOURCE_ID . '/submit',
['metadata' => ['key' => 'value']]
);
$resource = $this->service->submit(self::TEST_RESOURCE_ID, [
'metadata' => ['key' => 'value'],
]);
static::assertInstanceOf(\Stripe\Issuing\Dispute::class, $resource);
}
}
4 changes: 2 additions & 2 deletions tests/Stripe/Service/SubscriptionScheduleServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function testCreate()
$resource = $this->service->create([
'phases' => [
[
'plans' => [
['plan' => 'plan_123', 'quantity' => 2],
'items' => [
['price' => 'price_123', 'quantity' => 2],
],
],
],
Expand Down
4 changes: 2 additions & 2 deletions tests/Stripe/SubscriptionScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function testIsCreatable()
$resource = SubscriptionSchedule::create([
'phases' => [
[
'plans' => [
['plan' => 'plan_123', 'quantity' => 2],
'items' => [
['price' => 'price_123', 'quantity' => 2],
],
],
],
Expand Down