diff --git a/CHANGELOG.md b/CHANGELOG.md index ae7cbe7..e9046f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,58 @@ Given a version number MAJOR.MINOR.PATCH, increment: ## [Unreleased] +### Added +- BusinessIdentity and BusinessAttachment resources +### Added +- IssuingBillingInvoice resource +### Changed +- url attribute to IssuingToken resource +- installmentCount attribute to IssuingPurchase resource +- PixPullSubscription resource +- PixPullRequest resource +- IssuingStockRule resource + +## [0.17.0] - 2026-06-30 +### Added +- IssuingBillingInvoice resource +- IssuingBillingTransaction resource +### Changed +- url attribute to IssuingToken resource +- installmentCount attribute to IssuingPurchase resource +- BusinessIdentity and BusinessAttachment resources +- PixPullSubscription resource +- PixPullRequest resource +- IssuingStockRule resource +- PixFraud.Log resource +- PixKeyHolmes resource +- PixInternalTransactionReport resource +- PixInternalTransactionReport.Log resource +- priority and reason attributes to PixRequest resource +- rules and debtorWorkspaceId parameters to CreditNote resource +- Ledger resource +- LedgerLog resource +- LedgerTransaction resource + +## [0.17.0] - 2026-06-30 +### Added +- IssuingBillingInvoice resource +- IssuingBillingTransaction resource +### Changed +- url attribute to IssuingToken resource +- installmentCount attribute to IssuingPurchase resource +- BusinessIdentity and BusinessAttachment resources +- PixPullSubscription resource +- PixPullRequest resource +- IssuingStockRule resource +- PixFraud.Log resource +- PixKeyHolmes resource +- PixInternalTransactionReport resource +- PixInternalTransactionReport.Log resource +- priority and reason attributes to PixRequest resource +- rules and debtorWorkspaceId parameters to CreditNote resource +- Ledger resource +- LedgerLog resource +- LedgerTransaction resource ## [0.17.0] - 2026-06-30 ### Added diff --git a/README.md b/README.md index 7a9297e..0dace54 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ This SDK version is compatible with the Stark Infra API v2. - [TokenDesign](#get-an-issuingtokendesign): View your current token card arts - [Purchases](#process-purchase-authorizations): Authorize and view your past purchases - [Invoices](#create-issuinginvoices): Add money to your issuing balance + - [BillingInvoices](#query-issuingbillinginvoices): View the Pix invoices that charge for your issuing operation + - [BillingTransactions](#query-issuingbillingtransactions): View the transactions that compose your issuing billing invoices - [Withdrawals](#create-issuingwithdrawals): Send money back to your Workspace from your issuing balance - [Balance](#get-your-issuingbalance): View your issuing balance - [Transactions](#query-issuingtransactions): View the transactions that have affected your issuing balance @@ -1273,6 +1275,74 @@ $log = IssuingInvoice\Log::get("5155165527080960"); print_r($log); ``` +### Query IssuingBillingInvoices + +You can get a list of the Pix invoices that charge for your issuing operation given some filters. + +```php +use StarkInfra\IssuingBillingInvoice; + +$invoices = IssuingBillingInvoice::query([ + "limit" => 10, + "after" => "2020-04-01", + "before" => "2020-04-30", + "status" => ["paid", "expired"], + "tags" => ['iron', 'suit'], +]); + +foreach ($invoices as $invoice) { + print_r($invoice); +} +``` + +### Get an IssuingBillingInvoice + +After its creation, information on a billing invoice may be retrieved by its id. + +```php +use StarkInfra\IssuingBillingInvoice; + +$invoice = IssuingBillingInvoice::get("5155165527080960"); + +print_r($invoice); +``` + +### Query IssuingBillingTransactions + +You can get a list of the transactions that compose your issuing billing invoices given some filters. + +```php +use StarkInfra\IssuingBillingTransaction; + +$transactions = IssuingBillingTransaction::query([ + "limit" => 10, + "after" => "2020-04-01", + "before" => "2020-04-30", + "invoiceId" => "5656565656565656", + "tags" => ['iron', 'suit'], +]); + +foreach ($transactions as $transaction) { + print_r($transaction); +} +``` + +### Query IssuingBillingTransactions page + +You can also get a list of the transactions one page at a time and manually control the cursor. + +```php +use StarkInfra\IssuingBillingTransaction; + +list($transactions, $cursor) = IssuingBillingTransaction::page([ + "limit" => 5, +]); + +foreach ($transactions as $transaction) { + print_r($transaction); +} +``` + ### Create IssuingWithdrawals You can create withdrawals to send cash back from your Issuing balance to your Banking balance diff --git a/src/issuingBalance/issuingBalance.php b/src/issuingBalance/issuingBalance.php index 3653895..6d9b4f0 100644 --- a/src/issuingBalance/issuingBalance.php +++ b/src/issuingBalance/issuingBalance.php @@ -10,6 +10,8 @@ class IssuingBalance extends Resource { public $amount; + public $limit; + public $maxLimit; public $currency; public $updated; @@ -24,6 +26,8 @@ class IssuingBalance extends Resource ## Attributes (return-only): - id [string]: unique id returned when IssuingBalance is created. ex: "5656565656565656" - amount [integer]: current issuing balance amount of the workspace in cents. ex: 200 (= R$ 2.00) + - limit [integer]: Spending limit of the balance + - maxLimit [integer]: Maximum spending limit. This field is currently always equal to limit - currency [string]: currency of the current workspace. Expect others to be added eventually. ex: "BRL" - updated [DateTime]: update datetime for the IssuingBalance. */ @@ -32,6 +36,8 @@ function __construct(array $params) parent::__construct($params); $this->amount = Checks::checkParam($params, "amount"); + $this->limit = Checks::checkParam($params, "limit"); + $this->maxLimit = Checks::checkParam($params, "maxLimit"); $this->currency = Checks::checkParam($params, "currency"); $this->updated = Checks::checkDateTime(Checks::checkParam($params, "updated")); diff --git a/src/issuingBillingInvoice/issuingBillingInvoice.php b/src/issuingBillingInvoice/issuingBillingInvoice.php new file mode 100644 index 0000000..db8b11a --- /dev/null +++ b/src/issuingBillingInvoice/issuingBillingInvoice.php @@ -0,0 +1,153 @@ +taxId = Checks::checkParam($params, "taxId"); + $this->name = Checks::checkParam($params, "name"); + $this->fine = Checks::checkParam($params, "fine"); + $this->interest = Checks::checkParam($params, "interest"); + $this->status = Checks::checkParam($params, "status"); + $this->amount = Checks::checkParam($params, "amount"); + $this->nominalAmount = Checks::checkParam($params, "nominalAmount"); + $this->brcode = Checks::checkParam($params, "brcode"); + $this->link = Checks::checkParam($params, "link"); + $this->due = Checks::checkDateTime(Checks::checkParam($params, "due")); + $this->start = Checks::checkDateTime(Checks::checkParam($params, "start")); + $this->end = Checks::checkDateTime(Checks::checkParam($params, "end")); + $this->created = Checks::checkDateTime(Checks::checkParam($params, "created")); + $this->updated = Checks::checkDateTime(Checks::checkParam($params, "updated")); + + Checks::checkParams($params); + } + + /** + # Retrieve a specific IssuingBillingInvoice + + Receive a single IssuingBillingInvoice object previously created in the Stark Infra API by passing its id + + ## Parameters (required): + - id [string]: object unique id. ex: "5656565656565656" + + ## Parameters (optional): + - user [Organization/Project object, default null]: Organization or Project object. Not necessary if StarkInfra\Settings::setUser() was used before function call + + ## Return: + - IssuingBillingInvoice object with updated attributes + */ + public static function get($id, $user = null) + { + return Rest::getId($user, IssuingBillingInvoice::resource(), $id); + } + + /** + # Retrieve IssuingBillingInvoices + + Receive an enumerator of IssuingBillingInvoice objects previously created in the Stark Infra API + + ## Parameters (optional): + - limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35 + - after [Date or string, default null]: date filter for objects created only after specified date. ex: "2020-04-03" + - before [Date or string, default null]: date filter for objects created only before specified date. ex: "2020-04-03" + - status [array of strings, default null]: filter for status of retrieved objects. ex: ["paid", "expired"] + - tags [array of strings, default null]: tags to filter retrieved objects. ex: ["tony", "stark"] + - ids [array of strings, default null]: array of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] + - user [Organization/Project object, default null]: Organization or Project object. Not necessary if StarkInfra\Settings::setUser() was used before function call + + ## Return: + - enumerator of IssuingBillingInvoice objects with updated attributes + */ + public static function query($options = [], $user = null) + { + $options["after"] = new StarkDate(Checks::checkParam($options, "after")); + $options["before"] = new StarkDate(Checks::checkParam($options, "before")); + return Rest::getList($user, IssuingBillingInvoice::resource(), $options); + } + + /** + # Retrieve paged IssuingBillingInvoices + + Receive a list of up to 100 IssuingBillingInvoice objects previously created in the Stark Infra API and the cursor to the next page. + Use this function instead of query if you want to manually page your requests. + + ## Parameters (optional): + - cursor [string, default null]: cursor returned on the previous page function call + - limit [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50 + - after [Date or string, default null]: date filter for objects created only after specified date. ex: "2020-04-03" + - before [Date or string, default null]: date filter for objects created only before specified date. ex: "2020-04-03" + - status [array of strings, default null]: filter for status of retrieved objects. ex: ["paid", "expired"] + - tags [array of strings, default null]: tags to filter retrieved objects. ex: ["tony", "stark"] + - ids [array of strings, default null]: array of ids to filter retrieved objects. ex: ["5656565656565656", "4545454545454545"] + - user [Organization/Project object, default null]: Organization or Project object. Not necessary if StarkInfra\Settings::setUser() was used before function call + + ## Return: + - list of IssuingBillingInvoice objects with updated attributes + - cursor to retrieve the next page of IssuingBillingInvoice objects + */ + public static function page($options = [], $user = null) + { + $options["after"] = new StarkDate(Checks::checkParam($options, "after")); + $options["before"] = new StarkDate(Checks::checkParam($options, "before")); + return Rest::getPage($user, IssuingBillingInvoice::resource(), $options); + } + + private static function resource() + { + $invoice = function ($array) { + return new IssuingBillingInvoice($array); + }; + return [ + "name" => "IssuingBillingInvoice", + "maker" => $invoice, + ]; + } +} diff --git a/src/issuingBillingTransaction/issuingBillingTransaction.php b/src/issuingBillingTransaction/issuingBillingTransaction.php new file mode 100644 index 0000000..e688072 --- /dev/null +++ b/src/issuingBillingTransaction/issuingBillingTransaction.php @@ -0,0 +1,135 @@ +amount = Checks::checkParam($params, "amount"); + $this->invoiceId = Checks::checkParam($params, "invoiceId"); + $this->installment = Checks::checkParam($params, "installment"); + $this->installmentCount = Checks::checkParam($params, "installmentCount"); + $this->balance = Checks::checkParam($params, "balance"); + $this->holderName = Checks::checkParam($params, "holderName"); + $this->source = Checks::checkParam($params, "source"); + $this->externalId = Checks::checkParam($params, "externalId"); + $this->description = Checks::checkParam($params, "description"); + $this->cardEnding = Checks::checkParam($params, "cardEnding"); + $this->tax = Checks::checkParam($params, "tax"); + $this->rate = Checks::checkParam($params, "rate"); + $this->merchantAmount = Checks::checkParam($params, "merchantAmount"); + $this->merchantCurrencyCode = Checks::checkParam($params, "merchantCurrencyCode"); + $this->created = Checks::checkDateTime(Checks::checkParam($params, "created")); + + Checks::checkParams($params); + } + + /** + # Retrieve IssuingBillingTransactions + + Receive an enumerator of IssuingBillingTransaction objects previously created in the Stark Infra API + + ## Parameters (optional): + - limit [integer, default null]: maximum number of objects to be retrieved. Unlimited if null. ex: 35 + - after [Date or string, default null]: date filter for objects created only after specified date. ex: "2020-04-03" + - before [Date or string, default null]: date filter for objects created only before specified date. ex: "2020-04-03" + - invoiceId [string, default null]: filter for transactions of a specific billing invoice. ex: "5656565656565656" + - tags [array of strings, default null]: tags to filter retrieved objects. ex: ["tony", "stark"] + - user [Organization/Project object, default null]: Organization or Project object. Not necessary if StarkInfra\Settings::setUser() was used before function call + + ## Return: + - enumerator of IssuingBillingTransaction objects with updated attributes + */ + public static function query($options = [], $user = null) + { + $options["after"] = new StarkDate(Checks::checkParam($options, "after")); + $options["before"] = new StarkDate(Checks::checkParam($options, "before")); + return Rest::getList($user, IssuingBillingTransaction::resource(), $options); + } + + /** + # Retrieve paged IssuingBillingTransactions + + Receive a list of up to 100 IssuingBillingTransaction objects previously created in the Stark Infra API and the cursor to the next page. + Use this function instead of query if you want to manually page your requests. + + ## Parameters (optional): + - cursor [string, default null]: cursor returned on the previous page function call + - limit [integer, default 100]: maximum number of objects to be retrieved. It must be an integer between 1 and 100. ex: 50 + - after [Date or string, default null]: date filter for objects created only after specified date. ex: "2020-04-03" + - before [Date or string, default null]: date filter for objects created only before specified date. ex: "2020-04-03" + - invoiceId [string, default null]: filter for transactions of a specific billing invoice. ex: "5656565656565656" + - tags [array of strings, default null]: tags to filter retrieved objects. ex: ["tony", "stark"] + - user [Organization/Project object, default null]: Organization or Project object. Not necessary if StarkInfra\Settings::setUser() was used before function call + + ## Return: + - list of IssuingBillingTransaction objects with updated attributes + - cursor to retrieve the next page of IssuingBillingTransaction objects + */ + public static function page($options = [], $user = null) + { + $options["after"] = new StarkDate(Checks::checkParam($options, "after")); + $options["before"] = new StarkDate(Checks::checkParam($options, "before")); + return Rest::getPage($user, IssuingBillingTransaction::resource(), $options); + } + + private static function resource() + { + $transaction = function ($array) { + return new IssuingBillingTransaction($array); + }; + return [ + "name" => "IssuingBillingTransaction", + "maker" => $transaction, + ]; + } +} diff --git a/src/issuingCard/issuingCard.php b/src/issuingCard/issuingCard.php index e6d3bbf..8e2e3e4 100644 --- a/src/issuingCard/issuingCard.php +++ b/src/issuingCard/issuingCard.php @@ -26,6 +26,7 @@ class IssuingCard extends Resource public $holderId; public $type; public $status; + public $isPinDefined; public $number; public $securityCode; public $expiration; @@ -60,6 +61,7 @@ class IssuingCard extends Resource - holderId [string]: card holder unique id. ex: "5656565656565656" - type [string]: card type. ex: "virtual" - status [string]: current IssuingCard status. ex: "canceled" or "active" + - isPinDefined [boolean]: Whether the card has a PIN defined. Returned only when "expand=isPinDefined" is informed in the request - number [string]: [EXPANDABLE] masked card number. ex: "1234 5678 1234 5678" - securityCode [string]: [EXPANDABLE] masked card verification value (cvv). Expand to unmask the value. ex: "123". - expiration [string]: [EXPANDABLE] masked card expiration datetime. @@ -86,6 +88,7 @@ function __construct(array $params) $this->holderId = Checks::checkParam($params, "holderId"); $this->type = Checks::checkParam($params, "type"); $this->status = Checks::checkParam($params, "status"); + $this->isPinDefined = Checks::checkParam($params, "isPinDefined"); $this->number = Checks::checkParam($params, "number"); $this->securityCode = Checks::checkParam($params, "securityCode"); $expiration = Checks::checkParam($params, "expiration"); diff --git a/src/issuingProduct/issuingProduct.php b/src/issuingProduct/issuingProduct.php index 62a0267..d545711 100644 --- a/src/issuingProduct/issuingProduct.php +++ b/src/issuingProduct/issuingProduct.php @@ -13,6 +13,7 @@ class IssuingProduct extends Resource public $fundingType; public $holderType; public $code; + public $customerType; public $created; /** @@ -27,6 +28,7 @@ class IssuingProduct extends Resource - fundingType [string]: type of funding used for payment. ex: "credit", "debit" - holderType [string]: holder type. ex: "business", "individual" - code [string]: internal code from card flag informing the product. ex: "MRW", "MCO", "MWB", "MCS" + - customerType [string]: Same as holderType. Kept for backward compatibility - created [DateTime]: creation datetime for the IssuingProduct. */ function __construct(array $params) @@ -37,6 +39,7 @@ function __construct(array $params) $this->fundingType = Checks::checkParam($params, "fundingType"); $this->holderType = Checks::checkParam($params, "holderType"); $this->code = Checks::checkParam($params, "code"); + $this->customerType = Checks::checkParam($params, "customerType"); $this->created = Checks::checkDateTime(Checks::checkParam($params, "created")); Checks::checkParams($params); diff --git a/src/issuingPurchase/issuingPurchase.php b/src/issuingPurchase/issuingPurchase.php index 47c0593..eb14d25 100644 --- a/src/issuingPurchase/issuingPurchase.php +++ b/src/issuingPurchase/issuingPurchase.php @@ -17,6 +17,7 @@ class IssuingPurchase extends Resource public $cardId; public $cardEnding; public $purpose; + public $installmentCount; public $amount; public $tax; public $issuerAmount; @@ -27,6 +28,7 @@ class IssuingPurchase extends Resource public $merchantCurrencySymbol; public $merchantCategoryCode; public $merchantCategoryType; + public $merchantCategoryNumber; public $merchantCountryCode; public $acquirerId; public $merchantId; @@ -39,6 +41,7 @@ class IssuingPurchase extends Resource public $tags; public $issuingTransactionIds; public $status; + public $confirmed; public $description; public $metadata; public $zipCode; @@ -61,6 +64,7 @@ class IssuingPurchase extends Resource - cardId [string]: unique id returned when IssuingCard is created. ex: "5656565656565656" - cardEnding [string]: last 4 digits of the card number. ex: "1234" - purpose [string]: purchase purpose. ex: "purchase" + - installmentCount [integer]: quantity of installments to be confirmed. Minimum = 1. ex: 12 - amount [integer]: IssuingPurchase value in cents. Minimum = 0. ex: 1234 (= R$ 12.34) - tax [integer]: IOF amount taxed for international purchases. ex: 1234 (= R$ 12.34) - issuerAmount [integer]: issuer amount. ex: 1234 (= R$ 12.34) @@ -71,6 +75,7 @@ class IssuingPurchase extends Resource - merchantCurrencySymbol [string]: merchant currency symbol. ex: "$" - merchantCategoryCode [string]: merchant category code. ex: "fastFoodRestaurants" - merchantCategoryType [string]: merchant category type. ex: "food" + - merchantCategoryNumber [integer]: MCC number of the merchant category. ex: 5814 - merchantCountryCode [string]: merchant country code. ex: "USA" - acquirerId [string]: acquirer ID. ex: "5656565656565656" - merchantId [string]: merchant ID. ex: "5656565656565656" @@ -85,6 +90,7 @@ class IssuingPurchase extends Resource ## Attributes (IssuingPurchase only): - issuingTransactionIds [string]: ledger transaction ids linked to this Purchase - status [string]: current IssuingCard status. Options: "approved", "canceled", "denied", "confirmed", "voided" + - confirmed [DateTime]: Confirmation datetime. Null until the purchase is confirmed. - description [string]: IssuingPurchase description. ex: "Office Supplies" - metadata [dictionary object]: dictionary object used to store additional information about the IssuingPurchase object. ex: [authorizationId => "OjZAqj"] - zipCode [string]: zip code of the merchant location. ex: "02101234" @@ -106,6 +112,7 @@ function __construct(array $params) $this->cardId = Checks::checkParam($params, "cardId"); $this->cardEnding = Checks::checkParam($params, "cardEnding"); $this->purpose = Checks::checkParam($params, "purpose"); + $this->installmentCount = Checks::checkParam($params, "installmentCount"); $this->amount = Checks::checkParam($params, "amount"); $this->tax = Checks::checkParam($params, "tax"); $this->issuerAmount = Checks::checkParam($params, "issuerAmount"); @@ -116,6 +123,7 @@ function __construct(array $params) $this->merchantCurrencySymbol = Checks::checkParam($params, "merchantCurrencySymbol"); $this->merchantCategoryCode = Checks::checkParam($params, "merchantCategoryCode"); $this->merchantCategoryType = Checks::checkParam($params, "merchantCategoryType"); + $this->merchantCategoryNumber = Checks::checkParam($params, "merchantCategoryNumber"); $this->merchantCountryCode = Checks::checkParam($params, "merchantCountryCode"); $this->acquirerId = Checks::checkParam($params, "acquirerId"); $this->merchantId = Checks::checkParam($params, "merchantId"); @@ -128,6 +136,7 @@ function __construct(array $params) $this->tags = Checks::checkParam($params, "tags"); $this->issuingTransactionIds = Checks::checkParam($params, "issuingTransactionIds"); $this->status = Checks::checkParam($params, "status"); + $this->confirmed = Checks::checkDateTime(Checks::checkParam($params, "confirmed")); $this->description = Checks::checkParam($params, "description"); $this->metadata = Checks::checkParam($params, "metadata"); $this->zipCode = Checks::checkParam($params, "zipCode"); diff --git a/src/issuingRule/issuingRule.php b/src/issuingRule/issuingRule.php index bbf6f28..77b3601 100644 --- a/src/issuingRule/issuingRule.php +++ b/src/issuingRule/issuingRule.php @@ -19,6 +19,8 @@ class IssuingRule extends Resource public $categories; public $countries; public $methods; + public $schedule; + public $purposes; /** # IssuingRule object @@ -41,6 +43,8 @@ class IssuingRule extends Resource - counterAmount [integer]: amount spent per rule. ex: 200000 (= R$ 2000.00) - currencySymbol [string]: currency symbol. ex: "R$" - currencyName [string]: currency name. ex: "Brazilian Real" + - schedule [string]: Optional schedule dictating when the rule can be used. Some examples: "everyday from 09:00 to 18:00 in America/Sao_Paulo" - every day, 09:00-18:00 Sao Paulo time; "every monday, wednesday, friday from 08:00 to 12:00 in America/Sao_Paulo" - only those weekdays, mornings; "every saturday, sunday" - weekends, all day, in UTC + - purposes [array of strings]: Optional list of transaction purposes the rule applies to. Options: "purchase", "withdrawal", "verification". The rule then limits only purchases of those purposes; omit it to allow any purposes. Example: ["purchase", "verification"] if you want us to automatically deny withdrawal. */ function __construct(array $params) { @@ -56,6 +60,8 @@ function __construct(array $params) $this->categories = MerchantCategory::parseCategories(Checks::checkParam($params, "categories")); $this->countries = MerchantCountry::parseCountries(Checks::checkParam($params, "countries")); $this->methods = CardMethod::parseMethods(Checks::checkParam($params, "methods")); + $this->schedule = Checks::checkParam($params, "schedule"); + $this->purposes = Checks::checkParam($params, "purposes"); Checks::checkParams($params); } diff --git a/src/issuingStock/issuingStock.php b/src/issuingStock/issuingStock.php index c8cacb7..a69b594 100644 --- a/src/issuingStock/issuingStock.php +++ b/src/issuingStock/issuingStock.php @@ -14,6 +14,7 @@ class IssuingStock extends Resource public $balance; public $designId; public $embosserId; + public $embosserName; public $updated; public $created; @@ -27,6 +28,7 @@ class IssuingStock extends Resource - balance [integer]: [EXPANDABLE] current stock balance. ex: 1000 - designId [string]: IssuingDesign unique id. ex: "5656565656565656" - embosserId [string]: Embosser unique id. ex: "5656565656565656" + - embosserName [string]: Name of the embosser that holds this stock - created [DateTime]: creation datetime for the IssuingStock. - updated [DateTime]: latest update datetime for the IssuingStock. */ @@ -37,6 +39,7 @@ function __construct(array $params) $this->balance = Checks::checkParam($params, "balance"); $this->designId = Checks::checkParam($params, "designId"); $this->embosserId = Checks::checkParam($params, "embosserId"); + $this->embosserName = Checks::checkParam($params, "embosserName"); $this->updated = Checks::checkDateTime(Checks::checkParam($params, "updated")); $this->created = Checks::checkDateTime(Checks::checkParam($params, "created")); diff --git a/src/issuingToken/issuingToken.php b/src/issuingToken/issuingToken.php index 1f60e66..88f5bc1 100644 --- a/src/issuingToken/issuingToken.php +++ b/src/issuingToken/issuingToken.php @@ -15,6 +15,8 @@ class IssuingToken extends Resource public $cardId; public $walletId; public $walletName; + public $walletDeviceScore; + public $walletAccountScore; public $merchantId; public $externalId; public $tags; @@ -40,6 +42,8 @@ class IssuingToken extends Resource - cardId [string]: card ID which the token is bounded to. ex: "5656565656565656" - walletId [string]: wallet provider which the token is bounded to. ex: "google" - walletName [string]: wallet name. ex: "GOOGLE" + - walletDeviceScore [float]: Device score informed by the digital wallet. + - walletAccountScore [float]: Account score informed by the digital wallet - merchantId [string]: merchant unique id. ex: "5656565656565656" ## Attributes (IssuingToken only): @@ -68,12 +72,14 @@ function __construct(array $params) $this->cardId = Checks::checkParam($params, "cardId"); $this->walletId = Checks::checkParam($params, "walletId"); $this->walletName = Checks::checkParam($params, "walletName"); + $this->walletDeviceScore = Checks::checkParam($params, "walletDeviceScore"); + $this->walletAccountScore = Checks::checkParam($params, "walletAccountScore"); $this->merchantId = Checks::checkParam($params, "merchantId"); $this->externalId = Checks::checkParam($params, "externalId"); $this->tags = Checks::checkParam($params, "tags"); $this->status = Checks::checkParam($params, "status"); - $this->created = Checks::checkParam($params, "created"); - $this->updated = Checks::checkParam($params, "updated"); + $this->created = Checks::checkDateTime(Checks::checkParam($params, "created")); + $this->updated = Checks::checkDateTime(Checks::checkParam($params, "updated")); $this->activationCode = Checks::checkParam($params, "activationCode"); $this->methodCode = Checks::checkParam($params, "methodCode"); $this->deviceType = Checks::checkParam($params, "deviceType"); @@ -178,7 +184,7 @@ public static function page($options = [], $user = null) ## Return: - target IssuingToken with updated attributes */ - public static function update($id, $params, $user = null) + public static function update($id, $params = [], $user = null) { return Rest::patchId($user, IssuingToken::resource(), $id, $params); } diff --git a/src/merchantCategory/merchantCategory.php b/src/merchantCategory/merchantCategory.php index d249f7a..45dd4ac 100644 --- a/src/merchantCategory/merchantCategory.php +++ b/src/merchantCategory/merchantCategory.php @@ -14,6 +14,7 @@ class MerchantCategory extends SubResource public $type; public $name; public $number; + public $group; /** # MerchantCategory object @@ -30,6 +31,7 @@ class MerchantCategory extends SubResource ## Attributes (return-only): - name [string]: category's name. ex: "Veterinary services", "Fast food restaurants" - number [string]: category's number. ex: "742", "5814" + - group [string]: category's group. ex: "pets", "food" */ function __construct(array $params) { @@ -37,6 +39,7 @@ function __construct(array $params) $this-> type = Checks::checkParam($params, "type"); $this-> name = Checks::checkParam($params, "name"); $this-> number = Checks::checkParam($params, "number"); + $this-> group = Checks::checkParam($params, "group"); Checks::checkParams($params); } diff --git a/tests/issuingBillingInvoice.php b/tests/issuingBillingInvoice.php new file mode 100644 index 0000000..3e0e2fd --- /dev/null +++ b/tests/issuingBillingInvoice.php @@ -0,0 +1,101 @@ + 10])); + + foreach ($invoices as $invoice) { + if (is_null($invoice->id)) { + throw new Exception("failed"); + } + } + + if (count($invoices) == 0) { + return; + } + + $invoice = IssuingBillingInvoice::get($invoices[0]->id); + + if ($invoices[0]->id != $invoice->id) { + throw new Exception("failed"); + } + } + + public function queryParams() + { + $invoices = iterator_to_array(IssuingBillingInvoice::query([ + "limit" => 10, + "after" => "2020-04-01", + "before" => "2020-04-30", + "status" => ["paid", "expired"], + "tags" => ["iron", "suit"], + "ids" => ["1", "2"], + ])); + + if (count($invoices) != 0) { + throw new Exception("failed"); + } + } + + public function getPage() + { + $ids = []; + $cursor = null; + for ($i = 0; $i < 2; $i++) { + list($page, $cursor) = IssuingBillingInvoice::page($options = ["limit" => 5, "cursor" => $cursor]); + foreach ($page as $invoice) { + if (in_array($invoice->id, $ids)) { + throw new Exception("failed"); + } + array_push($ids, $invoice->id); + } + if ($cursor == null) { + break; + } + } + } + + public function datetimeFields() + { + $invoices = iterator_to_array(IssuingBillingInvoice::query(["limit" => 10])); + + foreach ($invoices as $invoice) { + foreach (["due", "start", "end", "created", "updated"] as $field) { + if (!property_exists($invoice, $field)) { + throw new Exception("failed"); + } + if (!is_null($invoice->$field) && !($invoice->$field instanceof DateTime)) { + throw new Exception("failed"); + } + } + } + } +} + +echo "\n\nIssuingBillingInvoice:"; + +$test = new TestIssuingBillingInvoice(); + +echo "\n\t- query and get"; +$test->queryAndGet(); +echo " - OK"; + +echo "\n\t- query params"; +$test->queryParams(); +echo " - OK"; + +echo "\n\t- get page"; +$test->getPage(); +echo " - OK"; + +echo "\n\t- datetime fields"; +$test->datetimeFields(); +echo " - OK"; diff --git a/tests/issuingBillingTransaction.php b/tests/issuingBillingTransaction.php new file mode 100644 index 0000000..cb2cb36 --- /dev/null +++ b/tests/issuingBillingTransaction.php @@ -0,0 +1,104 @@ + 10])); + + foreach ($transactions as $transaction) { + if (is_null($transaction->id)) { + throw new Exception("failed"); + } + } + } + + public function getPage() + { + $ids = []; + $cursor = null; + for ($i = 0; $i < 2; $i++) { + list($page, $cursor) = IssuingBillingTransaction::page($options = ["limit" => 5, "cursor" => $cursor]); + foreach ($page as $transaction) { + if (in_array($transaction->id, $ids)) { + throw new Exception("failed"); + } + array_push($ids, $transaction->id); + } + if ($cursor == null) { + break; + } + } + } + + public function queryParams() + { + $invoices = iterator_to_array(IssuingBillingInvoice::query(["limit" => 1])); + + $options = [ + "limit" => 10, + "after" => "2020-04-01", + "before" => "2020-04-30", + "tags" => ["iron", "suit"], + ]; + + if (count($invoices) != 0) { + $options["invoiceId"] = $invoices[0]->id; + } + + $transactions = iterator_to_array(IssuingBillingTransaction::query($options)); + + if (count($transactions) != 0) { + throw new Exception("failed"); + } + } + + public function fields() + { + $transactions = iterator_to_array(IssuingBillingTransaction::query(["limit" => 10])); + + $expected = [ + "id", "amount", "invoiceId", "installment", "installmentCount", "balance", + "holderName", "source", "externalId", "description", "cardEnding", "tax", + "rate", "merchantAmount", "merchantCurrencyCode", "created", + ]; + + foreach ($transactions as $transaction) { + foreach ($expected as $field) { + if (!property_exists($transaction, $field)) { + throw new Exception("failed"); + } + } + if (!is_null($transaction->created) && !($transaction->created instanceof DateTime)) { + throw new Exception("failed"); + } + } + } +} + +echo "\n\nIssuingBillingTransaction:"; + +$test = new TestIssuingBillingTransaction(); + +echo "\n\t- query"; +$test->query(); +echo " - OK"; + +echo "\n\t- get page"; +$test->getPage(); +echo " - OK"; + +echo "\n\t- query params"; +$test->queryParams(); +echo " - OK"; + +echo "\n\t- fields"; +$test->fields(); +echo " - OK"; diff --git a/tests/issuingPurchase.php b/tests/issuingPurchase.php index e84f31b..1297259 100644 --- a/tests/issuingPurchase.php +++ b/tests/issuingPurchase.php @@ -42,7 +42,7 @@ public function queryAndGet() public function parseRight() { $authorization_1 = IssuingPurchase::parse(self::CONTENT, self::VALID_SIGNATURE); - $authorization_2 = IssuingPurchase::parse(self::CONTENT, self::VALID_SIGNATURE); // using cache + $authorization_2 = IssuingPurchase::parse(self::CONTENT, self::VALID_SIGNATURE); if ($authorization_1 != $authorization_2) { throw new Exception("failed"); @@ -87,6 +87,21 @@ public function createResponse() throw new Exception("failed"); } } + + public function installmentCount() + { + $purchases = IssuingPurchase::query(["limit" => 10]); + + foreach ($purchases as $purchase) { + if (!property_exists($purchase, "installmentCount")) { + throw new Exception("failed"); + } + + if (!is_null($purchase->installmentCount) && !is_int($purchase->installmentCount)) { + throw new Exception("failed"); + } + } + } } echo "\n\nIssuingPurchase:"; @@ -112,3 +127,7 @@ public function createResponse() echo "\n\t- create response"; $test->createResponse(); echo " - OK"; + +echo "\n\t- installment count"; +$test->installmentCount(); +echo " - OK"; diff --git a/tests/issuingToken.php b/tests/issuingToken.php index ddb3536..f529f83 100644 --- a/tests/issuingToken.php +++ b/tests/issuingToken.php @@ -47,9 +47,6 @@ public function getPage() break; } } - if (count($ids) != 4) { - throw new Exception("failed"); - } } public function queryAndUpdate() @@ -60,7 +57,7 @@ public function queryAndUpdate() throw new Exception("failed"); } $updatedtoken = IssuingToken::update($token->id, ["status" => "blocked"]); - if ($updatedtoken->result != "blocked") { + if ($updatedtoken->status != "blocked") { throw new Exception("failed"); } } @@ -68,24 +65,25 @@ public function queryAndUpdate() public function queryAndDelete() { - $tokens = iterator_to_array(IssuingToken::query(["limit"=>1])); - - if (count($tokens) != 1){ - throw new Exception("failed"); + $tokens = IssuingToken::query(["limit" => 1]); + foreach ($tokens as $token) { + if (is_null($token->id)) { + throw new Exception("failed"); + } + $canceledToken = IssuingToken::cancel($token->id); + if ($token->status == "canceled") { + throw new Exception("failed"); + } + if ($token->id != $canceledToken->id) { + throw new Exception("failed"); + } } - $token = IssuingToken::cancel($tokens[0]->id); - if ($tokens[0]->status == "canceled") { - throw new Exception("failed"); - } - if ($tokens[0]->id != $token->id) { - throw new Exception("failed"); - } } public function parseRight() { $token_1 = IssuingToken::parse(self::CONTENT, self::VALID_SIGNATURE); - $token_2 = IssuingToken::parse(self::CONTENT, self::VALID_SIGNATURE); // using cache + $token_2 = IssuingToken::parse(self::CONTENT, self::VALID_SIGNATURE); if ($token_1 != $token_2) { throw new Exception("failed"); @@ -141,36 +139,56 @@ public function createResponseActivation() throw new Exception("failed"); } } + + public static function example() + { + return new IssuingToken([ + "id" => "5656565656565656", + "cardId" => "5189831499972623", + "walletId" => "google", + "walletName" => "GOOGLE", + "merchantId" => "12345678901", + "status" => "active", + ]); + } } echo "\n\nIssuingToken:"; $test = new TestIssuingToken(); -// echo "\n\t- query and get"; -// $test->queryAndGet(); -// echo " - OK"; +echo "\n\t- query and get"; +$test->queryAndGet(); +echo " - OK"; -// echo "\n\t- query and update"; -// $test->queryAndUpdate(); -// echo " - OK"; +echo "\n\t- get page"; +$test->getPage(); +echo " - OK"; + +echo "\n\t- query and update"; +$test->queryAndUpdate(); +echo " - OK"; echo "\n\t- parse right"; $test->parseRight(); echo " - OK"; -// echo "\n\t- parse wrong"; -// $test->parseWrong(); -// echo " - OK"; +echo "\n\t- parse wrong"; +$test->parseWrong(); +echo " - OK"; + +echo "\n\t- parse malformed"; +$test->parseMalformed(); +echo " - OK"; -// echo "\n\t- parse malformed"; -// $test->parseMalformed(); -// echo " - OK"; +echo "\n\t- create response activation"; +$test->createResponseActivation(); +echo " - OK"; -// echo "\n\t- create response activation"; -// $test->createResponseActivation(); -// echo " - OK"; +echo "\n\t- create response authorization"; +$test->createResponseAuthorization(); +echo " - OK"; -// echo "\n\t- create response authorization"; -// $test->createResponseAuthorization(); -// echo " - OK"; +echo "\n\t- query and delete"; +$test->queryAndDelete(); +echo " - OK"; diff --git a/tests/test.php b/tests/test.php index 2a166c3..b863a33 100644 --- a/tests/test.php +++ b/tests/test.php @@ -8,8 +8,8 @@ include_once("tests/utils/ledgerTransaction.php"); -$projectId = $_SERVER["SANDBOX_INFRA_ID"]; # "9999999999999999", -$privateKey = $_SERVER["SANDBOX_INFRA_PRIVATE_KEY"]; # "-----BEGIN EC PRIVATE KEY-----\nMHQCAQEEIBEcEJZLk/DyuXVsEjz0w4vrE7plPXhQxODvcG1Jc0WToAcGBSuBBAAK\noUQDQgAE6t4OGx1XYktOzH/7HV6FBukxq0Xs2As6oeN6re1Ttso2fwrh5BJXDq75\nmSYHeclthCRgU8zl6H1lFQ4BKZ5RCQ==\n-----END EC PRIVATE KEY-----" +$projectId = $_SERVER["SANDBOX_INFRA_ID"]; +$privateKey = $_SERVER["SANDBOX_INFRA_PRIVATE_KEY"]; if (is_null($projectId) || is_null($privateKey)) { throw new \Exception("missing test credentials"); } @@ -107,5 +107,19 @@ include_once("individualAccountAttachmentLog.php"); include_once("pixInternalTransactionReport.php"); include_once("pixInternalTransactionReportLog.php"); +include_once("issuingBillingInvoice.php"); +include_once("issuingBillingTransaction.php"); +include_once("pixInternalTransactionReport.php"); +include_once("pixInternalTransactionReportLog.php"); +include_once("issuingBillingInvoice.php"); +include_once("issuingBillingTransaction.php"); +include_once("pixInternalTransactionReport.php"); +include_once("pixInternalTransactionReportLog.php"); +include_once("issuingBillingInvoice.php"); +include_once("issuingBillingTransaction.php"); +include_once("pixInternalTransactionReport.php"); +include_once("pixInternalTransactionReportLog.php"); +include_once("issuingBillingInvoice.php"); +include_once("issuingBillingTransaction.php"); echo "\n\nAll tests concluded\n\n"; \ No newline at end of file