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

API Updates #1283

Merged
merged 3 commits into from
May 9, 2022
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
3 changes: 0 additions & 3 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@
require __DIR__ . '/lib/LoginLink.php';
require __DIR__ . '/lib/Mandate.php';
require __DIR__ . '/lib/Order.php';
require __DIR__ . '/lib/OrderItem.php';
require __DIR__ . '/lib/OrderReturn.php';
require __DIR__ . '/lib/PaymentIntent.php';
require __DIR__ . '/lib/PaymentLink.php';
require __DIR__ . '/lib/PaymentMethod.php';
Expand Down Expand Up @@ -211,7 +209,6 @@
require __DIR__ . '/lib/Service/Issuing/TransactionService.php';
require __DIR__ . '/lib/Service/MandateService.php';
require __DIR__ . '/lib/Service/OrderService.php';
require __DIR__ . '/lib/Service/OrderReturnService.php';
require __DIR__ . '/lib/Service/PaymentIntentService.php';
require __DIR__ . '/lib/Service/PaymentLinkService.php';
require __DIR__ . '/lib/Service/PaymentMethodService.php';
Expand Down
1 change: 0 additions & 1 deletion lib/Charge.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @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 null|string|\Stripe\Account $on_behalf_of The account (if any) the charge was made on behalf of without triggering an automatic transfer. See the <a href="https://stripe.com/docs/connect/charges-transfers">Connect documentation</a> for details.
* @property null|string|\Stripe\Order $order ID of the order this charge is for if one exists.
* @property null|\Stripe\StripeObject $outcome Details about whether the payment was accepted, and why. See <a href="https://stripe.com/docs/declines">understanding declines</a> for details.
* @property bool $paid <code>true</code> if the charge succeeded, or was successfully authorized for later capture.
* @property null|string|\Stripe\PaymentIntent $payment_intent ID of the PaymentIntent associated with this charge, if one exists.
Expand Down
4 changes: 2 additions & 2 deletions lib/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public static function search($params = null, $opts = null)
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
* @return \Stripe\CashBalance
*/
public static function retrieveCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
Expand All @@ -142,7 +142,7 @@ public static function retrieveCashBalance($id, $cashBalanceId, $params = null,
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
* @return \Stripe\CashBalance
*/
public static function updateCashBalance($id, $cashBalanceId, $params = null, $opts = null)
{
Expand Down
2 changes: 1 addition & 1 deletion lib/FinancialConnections/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function disconnect($params = null, $opts = null)
*
* @return \Stripe\FinancialConnections\Account the refreshed account
*/
public function refresh($params = null, $opts = null)
public function refreshAccount($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/refresh';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
Expand Down
3 changes: 3 additions & 0 deletions lib/LineItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@
*
* @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_discount Total discount amount applied. If no discounts were applied, defaults to 0.
* @property int $amount_subtotal Total before any discounts or taxes are applied.
* @property int $amount_tax Total tax amount applied. If no tax was applied, defaults to 0.
* @property int $amount_total Total after discounts and taxes.
* @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 string $description An arbitrary string attached to the object. Often useful for displaying to users. Defaults to product name.
* @property \Stripe\StripeObject[] $discounts The discounts applied to the line item.
* @property null|\Stripe\Price $price The price used to generate the line item.
* @property string|\Stripe\Product $product <p>The ID of the product for this line item.</p><p>This will always be the same as <code>price.product</code>.</p>
* @property null|int $quantity The quantity of products being purchased.
* @property \Stripe\StripeObject[] $taxes The taxes applied to the line item.
*/
Expand Down
100 changes: 69 additions & 31 deletions lib/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,32 @@
namespace Stripe;

/**
* Order objects are created to handle end customers' purchases of previously
* defined <a href="https://stripe.com/docs/api#products">products</a>. You can
* create, retrieve, and pay individual orders, as well as list all orders. Orders
* are identified by a unique, random ID.
*
* Related guide: <a href="https://stripe.com/docs/orders-legacy">Tax, Shipping,
* and Inventory</a>.
* An Order describes a purchase being made by a customer, including the products
* &amp; quantities being purchased, the order status, the payment information, and
* the billing/shipping details.
*
* @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 A positive integer in the smallest currency unit (that is, 100 cents for $1.00, or 1 for ¥1, Japanese Yen being a zero-decimal currency) representing the total amount for the order.
* @property null|int $amount_returned The total amount that was returned to the customer.
* @property null|string $application ID of the Connect Application that created the order.
* @property null|int $application_fee A fee in cents that will be applied to the order and transferred to the application owner’s Stripe account. The request must be made with an OAuth key or the Stripe-Account header in order to take an application fee. For more information, see the application fees documentation.
* @property null|string|\Stripe\Charge $charge The ID of the payment used to pay for the order. Present if the order status is <code>paid</code>, <code>fulfilled</code>, or <code>refunded</code>.
* @property int $amount_subtotal Order cost before any discounts or taxes are applied. A positive integer representing the subtotal of the order in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
* @property int $amount_total Total order cost after discounts and taxes are applied. A positive integer representing the cost of the order in the <a href="https://stripe.com/docs/currencies#zero-decimal">smallest currency unit</a> (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency). To submit an order, the total must be either 0 or at least $0.50 USD or <a href="https://stripe.com/docs/currencies#minimum-and-maximum-charge-amounts">equivalent in charge currency</a>.
* @property null|string|\Stripe\StripeObject $application ID of the Connect application that created the Order, if any.
* @property \Stripe\StripeObject $automatic_tax
* @property null|\Stripe\StripeObject $billing_details Customer billing details associated with the order.
* @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\Customer $customer The customer used for the order.
* @property null|string $email The email address of the customer placing the order.
* @property string $external_coupon_code External coupon code to load for this order.
* @property \Stripe\OrderItem[] $items List of items constituting the order. An order can have up to 25 items.
* @property null|string|\Stripe\Customer $customer The customer which this orders belongs to.
* @property null|string $description An arbitrary string attached to the object. Often useful for displaying to users.
* @property null|(string|\Stripe\Discount)[] $discounts The discounts applied to the order. Use <code>expand[]=discounts</code> to expand each discount.
* @property null|string $ip_address A recent IP address of the purchaser used for tax reporting and tax location inference.
* @property \Stripe\Collection<\Stripe\LineItem> $line_items A list of line items the customer is ordering. Each line item includes information about the product, the quantity, and the resulting cost. There is a maximum of 100 line items.
* @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 null|\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 null|\Stripe\Collection<\Stripe\OrderReturn> $returns A list of returns that have taken place for this order.
* @property null|string $selected_shipping_method The shipping method that is currently selected for this order, if any. If present, it is equal to one of the <code>id</code>s of shipping methods in the <code>shipping_methods</code> array. At order creation time, if there are multiple shipping methods, Stripe will automatically selected the first method.
* @property null|\Stripe\StripeObject $shipping The shipping address for the order. Present if the order is for goods to be shipped.
* @property null|\Stripe\StripeObject[] $shipping_methods A list of supported shipping methods for this order. The desired shipping method can be specified either by updating the order, or when paying it.
* @property string $status Current order status. One of <code>created</code>, <code>paid</code>, <code>canceled</code>, <code>fulfilled</code>, or <code>returned</code>. More details in the <a href="https://stripe.com/docs/orders/guide#understanding-order-statuses">Orders Guide</a>.
* @property null|\Stripe\StripeObject $status_transitions The timestamps at which the order status was updated.
* @property null|int $updated Time at which the object was last updated. Measured in seconds since the Unix epoch.
* @property string $upstream_id The user's order ID if it is different from the Stripe order ID.
* @property \Stripe\StripeObject $payment
* @property null|\Stripe\StripeObject $shipping_cost The details of the customer cost of shipping, including the customer chosen ShippingRate.
* @property null|\Stripe\StripeObject $shipping_details Customer shipping information associated with the order.
* @property string $status The overall status of the order.
* @property \Stripe\StripeObject $tax_details
* @property \Stripe\StripeObject $total_details
*/
class Order extends ApiResource
{
Expand All @@ -46,20 +41,63 @@ class Order extends ApiResource
use ApiOperations\Retrieve;
use ApiOperations\Update;

const STATUS_CANCELED = 'canceled';
const STATUS_COMPLETE = 'complete';
const STATUS_OPEN = 'open';
const STATUS_PROCESSING = 'processing';
const STATUS_SUBMITTED = 'submitted';

/**
* @param null|array $params
* @param null|array|string $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\OrderReturn the newly created return
* @return \Stripe\Order the canceled order
*/
public function returnOrder($params = null, $opts = null)
public function cancel($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/returns';
$url = $this->instanceUrl() . '/cancel';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

return $this;
}

/**
* @param null|array $params
* @param null|array|string $opts
* @param mixed $id
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Collection<\Stripe\Order> list of LineItems
*/
public static function allLineItems($id, $params = null, $opts = null)
{
$url = static::resourceUrl($id) . '/line_items';
list($response, $opts) = static::_staticRequest('get', $url, $params, $opts);
$obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
$obj->setLastResponse($response);

return Util\Util::convertToStripeObject($response, $opts);
return $obj;
}

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

return $this;
}

/**
Expand All @@ -68,11 +106,11 @@ public function returnOrder($params = null, $opts = null)
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\Order the paid order
* @return \Stripe\Order the submited order
*/
public function pay($params = null, $opts = null)
public function submit($params = null, $opts = null)
{
$url = $this->instanceUrl() . '/pay';
$url = $this->instanceUrl() . '/submit';
list($response, $opts) = $this->_request('post', $url, $params, $opts);
$this->refreshFrom($response, $opts);

Expand Down
32 changes: 0 additions & 32 deletions lib/OrderReturn.php

This file was deleted.

2 changes: 0 additions & 2 deletions lib/Service/CoreServiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @property Issuing\IssuingServiceFactory $issuing
* @property MandateService $mandates
* @property OAuthService $oauth
* @property OrderReturnService $orderReturns
* @property OrderService $orders
* @property PaymentIntentService $paymentIntents
* @property PaymentLinkService $paymentLinks
Expand Down Expand Up @@ -98,7 +97,6 @@ class CoreServiceFactory extends \Stripe\Service\AbstractServiceFactory
'issuing' => Issuing\IssuingServiceFactory::class,
'mandates' => MandateService::class,
'oauth' => OAuthService::class,
'orderReturns' => OrderReturnService::class,
'orders' => OrderService::class,
'paymentIntents' => PaymentIntentService::class,
'paymentLinks' => PaymentLinkService::class,
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/CustomerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public function retrieveBalanceTransaction($parentId, $id, $params = null, $opts
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
* @return \Stripe\CashBalance
*/
public function retrieveCashBalance($parentId, $params = null, $opts = null)
{
Expand Down Expand Up @@ -401,7 +401,7 @@ public function updateBalanceTransaction($parentId, $id, $params = null, $opts =
*
* @throws \Stripe\Exception\ApiErrorException if the request fails
*
* @return \Stripe\cash_balance
* @return \Stripe\CashBalance
*/
public function updateCashBalance($parentId, $params = null, $opts = null)
{
Expand Down
42 changes: 0 additions & 42 deletions lib/Service/OrderReturnService.php

This file was deleted.

Loading