From e3a96e77e1f5134c268644061b6b094350f08f46 Mon Sep 17 00:00:00 2001 From: Mario Dias Date: Thu, 27 May 2021 11:06:21 -0300 Subject: [PATCH 1/4] feat(Payment): adds a method to receive and return the customer device data --- src/Resource/Payment.php | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/Resource/Payment.php b/src/Resource/Payment.php index dcbfa47..92ee3f9 100755 --- a/src/Resource/Payment.php +++ b/src/Resource/Payment.php @@ -123,6 +123,7 @@ protected function initialize() $this->data = new stdClass(); $this->data->installmentCount = 1; $this->data->fundingInstrument = new stdClass(); + $this->data->device = new stdClass(); } /** @@ -189,6 +190,7 @@ protected function populate(stdClass $response) $payment->data->amount->currency = $this->getIfSet('currency', $response->amount); $payment->data->installmentCount = $this->getIfSet('installmentCount', $response); $payment->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); + $payment->data->device = $this->getIfSet('device', $response); $payment->data->payments = $this->getIfSet('payments', $response); $payment->data->escrows = $this->getIfSet('escrows', $response); $payment->data->fees = $this->getIfSet('fees', $response); @@ -267,6 +269,17 @@ public function getFundingInstrument() return $this->data->fundingInstrument; } + /** + * Returns the funding instrument. + * + * @return stdClass + */ + public function getDeviceFingerprint() + { + //todo: return a funding instrument object + return $this->data->device; + } + /** * Get href to Boleto * *. @@ -385,6 +398,20 @@ public function setFundingInstrument(stdClass $fundingInstrument) return $this; } + /** + * Set payment device. + * + * @param \stdClass $device + * + * @return $this + */ + public function setDevice(stdClass $device) + { + $this->data->device = $device; + + return $this; + } + /** * Set billet. * @@ -537,6 +564,30 @@ public function setStatementDescriptor($statementDescriptor) return $this; } + /** + * Set device fingerprint + * Customer device data used in the payment. + * + * @param string $ip Customer IP address + * @param float $latitude Customer latitude. + * @param float $longitude Customer longitude. + * @param string $userAgent Device userAgent. + * @param string $fingerprint Device fingerprint. + * + * @return $this + */ + public function setDeviceFingerprint($ip, $latitude, $longitude, $userAgent, $fingerprint) + { + $this->data->device->geolocation = new stdClass(); + $this->data->device->geolocation->latitude = $latitude; + $this->data->device->geolocation->longitude = $longitude; + $this->data->device->ip = $ip; + $this->data->device->userAgent = $userAgent; + $this->data->device->fingerprint = $fingerprint; + + return $this; + } + /** * Set payment means made available by banks. * From 44bc2eab105b6357c1e36f0366833ef6a07acae7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Dias?= Date: Fri, 4 Jun 2021 15:15:02 -0300 Subject: [PATCH 2/4] Revert "Feat/set fingerprint" --- .coveralls.yml | 0 .gitignore | 6 +- .travis.yml | 0 CHANGELOG.md | 0 CONTRIBUTING.md | 0 LICENSE | 0 README.en.md | 25 +- README.md | 4 +- circle.yml | 0 composer.json | 0 examples/ecommerce/simple_boleto_payment.php | 76 ++ .../ecommerce/simple_creditcard_payment.php | 80 ++ .../classical_moip_account_flow_part_1.php | 0 .../classical_moip_account_flow_part_2.php | 0 .../multiorder_and_multipayment.php | 0 .../transparent_moip_account_flow.php | 0 phpunit.xml | 0 src/Auth/BasicAuth.php | 0 src/Auth/Connect.php | 0 src/Auth/OAuth.php | 0 src/Contracts/Authentication.php | 0 src/Exceptions/Error.php | 0 src/Exceptions/InvalidArgumentException.php | 0 src/Exceptions/UnautorizedException.php | 0 src/Exceptions/UnexpectedException.php | 0 src/Exceptions/ValidationException.php | 0 src/Helper/Filters.php | 0 src/Helper/Links.php | 0 src/Helper/Pagination.php | 0 src/Helper/Utils.php | 0 src/Helper/helpers.php | 0 src/Moip.php | 0 src/Resource/Account.php | 0 src/Resource/Balances.php | 0 src/Resource/BankAccount.php | 0 src/Resource/BankAccountList.php | 0 src/Resource/Customer.php | 11 - src/Resource/CustomerCreditCard.php | 0 src/Resource/EntriesList.php | 82 -- src/Resource/Entry.php | 12 - src/Resource/Escrow.php | 0 src/Resource/Event.php | 0 src/Resource/Holder.php | 0 src/Resource/Keys.php | 0 src/Resource/MoipResource.php | 3 - src/Resource/Multiorders.php | 0 src/Resource/NotificationPreferences.php | 0 src/Resource/NotificationPreferencesList.php | 0 src/Resource/Orders.php | 0 src/Resource/OrdersList.php | 0 src/Resource/Payment.php | 65 +- src/Resource/Refund.php | 0 src/Resource/Transfers.php | 97 +-- src/Resource/TransfersList.php | 0 src/Resource/Webhook.php | 0 src/Resource/WebhookList.php | 0 tests/Helper/FiltersTest.php | 0 tests/Helper/LinksTest.php | 0 tests/MoipTest.php | 0 tests/Resource/AccountTest.php | 0 tests/Resource/BalancesTest.php | 0 tests/Resource/BankAccountListTest.php | 0 tests/Resource/BankAccountTest.php | 0 tests/Resource/CustomerTest.php | 14 - tests/Resource/EntriesListTest.php | 20 - tests/Resource/EscrowTest.php | 0 tests/Resource/KeyTest.php | 0 tests/Resource/MoipResourceTest.php | 0 .../NotificationPreferencesListTest.php | 0 .../Resource/NotificationPreferencesTest.php | 0 tests/Resource/OrdersListTest.php | 0 tests/Resource/OrdersTest.php | 0 tests/Resource/PaymentTest.php | 1 - tests/Resource/RefundTest.php | 0 tests/Resource/TransfersListTest.php | 0 tests/Resource/TransfersTest.php | 26 +- tests/Resource/WebhookListTest.php | 0 tests/TestCase.php | 18 +- tests/jsons/account/create.json | 0 tests/jsons/account/get.json | 0 tests/jsons/balances/get.json | 0 tests/jsons/bank_account/create.json | 0 tests/jsons/bank_account/list.json | 0 tests/jsons/bank_account/update.json | 0 tests/jsons/customer/add_credit_card.json | 0 tests/jsons/customer/create.json | 0 tests/jsons/customer/get.json | 65 -- tests/jsons/entries/list.json | 815 ------------------ tests/jsons/escrow/release.json | 0 tests/jsons/keys/get.json | 0 tests/jsons/multiorder/create.json | 0 .../multipayment/cancel_pre_authorized.json | 0 tests/jsons/multipayment/capture.json | 0 tests/jsons/multipayment/create_billet.json | 0 tests/jsons/multipayment/create_cc.json | 0 tests/jsons/multipayment/get.json | 0 tests/jsons/notification/create.json | 0 tests/jsons/notification/list.json | 0 tests/jsons/order/create.json | 0 tests/jsons/order/get_list.json | 0 .../jsons/payment/cancel_pre_authorized.json | 0 tests/jsons/payment/capture.json | 0 tests/jsons/payment/create_billet.json | 0 .../payment/create_cc_delay_capture.json | 0 tests/jsons/payment/create_cc_pci.json | 0 tests/jsons/payment/create_cc_pci_escrow.json | 0 tests/jsons/payment/create_cc_pci_store.json | 0 tests/jsons/payment/get.json | 0 .../jsons/refund/order_full_bankaccount.json | 0 tests/jsons/refund/order_full_cc.json | 0 .../refund/order_partial_bankaccount.json | 0 tests/jsons/refund/order_partial_cc.json | 0 .../refund/payment_full_bankaccount.json | 0 tests/jsons/refund/payment_full_cc.json | 0 .../refund/payment_partial_bankaccount.json | 0 tests/jsons/refund/payment_partial_cc.json | 0 .../{create_bankaccount.json => create.json} | 0 tests/jsons/transfers/create_moipaccount.json | 70 -- tests/jsons/transfers/list.json | 0 tests/jsons/transfers/revert.json | 0 tests/jsons/webhooks/get_all_filters.json | 0 tests/jsons/webhooks/get_no_filter.json | 0 tests/jsons/webhooks/get_pagination.json | 0 123 files changed, 200 insertions(+), 1290 deletions(-) mode change 100755 => 100644 .coveralls.yml mode change 100755 => 100644 .gitignore mode change 100755 => 100644 .travis.yml mode change 100755 => 100644 CHANGELOG.md mode change 100755 => 100644 CONTRIBUTING.md mode change 100755 => 100644 LICENSE mode change 100755 => 100644 README.en.md mode change 100755 => 100644 README.md mode change 100755 => 100644 circle.yml mode change 100755 => 100644 composer.json create mode 100644 examples/ecommerce/simple_boleto_payment.php create mode 100644 examples/ecommerce/simple_creditcard_payment.php mode change 100755 => 100644 examples/marketplace/classical_moip_account_flow_part_1.php mode change 100755 => 100644 examples/marketplace/classical_moip_account_flow_part_2.php mode change 100755 => 100644 examples/marketplace/multiorder_and_multipayment.php mode change 100755 => 100644 examples/marketplace/transparent_moip_account_flow.php mode change 100755 => 100644 phpunit.xml mode change 100755 => 100644 src/Auth/BasicAuth.php mode change 100755 => 100644 src/Auth/Connect.php mode change 100755 => 100644 src/Auth/OAuth.php mode change 100755 => 100644 src/Contracts/Authentication.php mode change 100755 => 100644 src/Exceptions/Error.php mode change 100755 => 100644 src/Exceptions/InvalidArgumentException.php mode change 100755 => 100644 src/Exceptions/UnautorizedException.php mode change 100755 => 100644 src/Exceptions/UnexpectedException.php mode change 100755 => 100644 src/Exceptions/ValidationException.php mode change 100755 => 100644 src/Helper/Filters.php mode change 100755 => 100644 src/Helper/Links.php mode change 100755 => 100644 src/Helper/Pagination.php mode change 100755 => 100644 src/Helper/Utils.php mode change 100755 => 100644 src/Helper/helpers.php mode change 100755 => 100644 src/Moip.php mode change 100755 => 100644 src/Resource/Account.php mode change 100755 => 100644 src/Resource/Balances.php mode change 100755 => 100644 src/Resource/BankAccount.php mode change 100755 => 100644 src/Resource/BankAccountList.php mode change 100755 => 100644 src/Resource/Customer.php mode change 100755 => 100644 src/Resource/CustomerCreditCard.php delete mode 100755 src/Resource/EntriesList.php mode change 100755 => 100644 src/Resource/Entry.php mode change 100755 => 100644 src/Resource/Escrow.php mode change 100755 => 100644 src/Resource/Event.php mode change 100755 => 100644 src/Resource/Holder.php mode change 100755 => 100644 src/Resource/Keys.php mode change 100755 => 100644 src/Resource/MoipResource.php mode change 100755 => 100644 src/Resource/Multiorders.php mode change 100755 => 100644 src/Resource/NotificationPreferences.php mode change 100755 => 100644 src/Resource/NotificationPreferencesList.php mode change 100755 => 100644 src/Resource/Orders.php mode change 100755 => 100644 src/Resource/OrdersList.php mode change 100755 => 100644 src/Resource/Payment.php mode change 100755 => 100644 src/Resource/Refund.php mode change 100755 => 100644 src/Resource/Transfers.php mode change 100755 => 100644 src/Resource/TransfersList.php mode change 100755 => 100644 src/Resource/Webhook.php mode change 100755 => 100644 src/Resource/WebhookList.php mode change 100755 => 100644 tests/Helper/FiltersTest.php mode change 100755 => 100644 tests/Helper/LinksTest.php mode change 100755 => 100644 tests/MoipTest.php mode change 100755 => 100644 tests/Resource/AccountTest.php mode change 100755 => 100644 tests/Resource/BalancesTest.php mode change 100755 => 100644 tests/Resource/BankAccountListTest.php mode change 100755 => 100644 tests/Resource/BankAccountTest.php mode change 100755 => 100644 tests/Resource/CustomerTest.php delete mode 100755 tests/Resource/EntriesListTest.php mode change 100755 => 100644 tests/Resource/EscrowTest.php mode change 100755 => 100644 tests/Resource/KeyTest.php mode change 100755 => 100644 tests/Resource/MoipResourceTest.php mode change 100755 => 100644 tests/Resource/NotificationPreferencesListTest.php mode change 100755 => 100644 tests/Resource/NotificationPreferencesTest.php mode change 100755 => 100644 tests/Resource/OrdersListTest.php mode change 100755 => 100644 tests/Resource/OrdersTest.php mode change 100755 => 100644 tests/Resource/PaymentTest.php mode change 100755 => 100644 tests/Resource/RefundTest.php mode change 100755 => 100644 tests/Resource/TransfersListTest.php mode change 100755 => 100644 tests/Resource/TransfersTest.php mode change 100755 => 100644 tests/Resource/WebhookListTest.php mode change 100755 => 100644 tests/TestCase.php mode change 100755 => 100644 tests/jsons/account/create.json mode change 100755 => 100644 tests/jsons/account/get.json mode change 100755 => 100644 tests/jsons/balances/get.json mode change 100755 => 100644 tests/jsons/bank_account/create.json mode change 100755 => 100644 tests/jsons/bank_account/list.json mode change 100755 => 100644 tests/jsons/bank_account/update.json mode change 100755 => 100644 tests/jsons/customer/add_credit_card.json mode change 100755 => 100644 tests/jsons/customer/create.json delete mode 100755 tests/jsons/customer/get.json delete mode 100755 tests/jsons/entries/list.json mode change 100755 => 100644 tests/jsons/escrow/release.json mode change 100755 => 100644 tests/jsons/keys/get.json mode change 100755 => 100644 tests/jsons/multiorder/create.json mode change 100755 => 100644 tests/jsons/multipayment/cancel_pre_authorized.json mode change 100755 => 100644 tests/jsons/multipayment/capture.json mode change 100755 => 100644 tests/jsons/multipayment/create_billet.json mode change 100755 => 100644 tests/jsons/multipayment/create_cc.json mode change 100755 => 100644 tests/jsons/multipayment/get.json mode change 100755 => 100644 tests/jsons/notification/create.json mode change 100755 => 100644 tests/jsons/notification/list.json mode change 100755 => 100644 tests/jsons/order/create.json mode change 100755 => 100644 tests/jsons/order/get_list.json mode change 100755 => 100644 tests/jsons/payment/cancel_pre_authorized.json mode change 100755 => 100644 tests/jsons/payment/capture.json mode change 100755 => 100644 tests/jsons/payment/create_billet.json mode change 100755 => 100644 tests/jsons/payment/create_cc_delay_capture.json mode change 100755 => 100644 tests/jsons/payment/create_cc_pci.json mode change 100755 => 100644 tests/jsons/payment/create_cc_pci_escrow.json mode change 100755 => 100644 tests/jsons/payment/create_cc_pci_store.json mode change 100755 => 100644 tests/jsons/payment/get.json mode change 100755 => 100644 tests/jsons/refund/order_full_bankaccount.json mode change 100755 => 100644 tests/jsons/refund/order_full_cc.json mode change 100755 => 100644 tests/jsons/refund/order_partial_bankaccount.json mode change 100755 => 100644 tests/jsons/refund/order_partial_cc.json mode change 100755 => 100644 tests/jsons/refund/payment_full_bankaccount.json mode change 100755 => 100644 tests/jsons/refund/payment_full_cc.json mode change 100755 => 100644 tests/jsons/refund/payment_partial_bankaccount.json mode change 100755 => 100644 tests/jsons/refund/payment_partial_cc.json rename tests/jsons/transfers/{create_bankaccount.json => create.json} (100%) mode change 100755 => 100644 delete mode 100644 tests/jsons/transfers/create_moipaccount.json mode change 100755 => 100644 tests/jsons/transfers/list.json mode change 100755 => 100644 tests/jsons/transfers/revert.json mode change 100755 => 100644 tests/jsons/webhooks/get_all_filters.json mode change 100755 => 100644 tests/jsons/webhooks/get_no_filter.json mode change 100755 => 100644 tests/jsons/webhooks/get_pagination.json diff --git a/.coveralls.yml b/.coveralls.yml old mode 100755 new mode 100644 diff --git a/.gitignore b/.gitignore old mode 100755 new mode 100644 index 83601c2..7be602c --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,4 @@ composer.lock vendor .idea/ -.DS_Store - -### VisualStudioCode ### -.vscode/ - +.DS_Store \ No newline at end of file diff --git a/.travis.yml b/.travis.yml old mode 100755 new mode 100644 diff --git a/CHANGELOG.md b/CHANGELOG.md old mode 100755 new mode 100644 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100755 new mode 100644 diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 diff --git a/README.en.md b/README.en.md old mode 100755 new mode 100644 index 65df494..e8bc051 --- a/README.en.md +++ b/README.en.md @@ -91,7 +91,6 @@ - [Transfers](#transfers) - [Create a Transfer](#create-a-transfer) - [Transfer to a Bank Account](#transfer-to-a-bank-account) - - [Transfer to a Moip Account](#transfer-to-a-moip-account) - [Get Transfer](#get-transfer) - [List Transfers](#list-transfers) - [List Transfers without pagination](#list-transfers-without-pagination) @@ -372,7 +371,7 @@ $payment = $order->payments() ->setCreditCardHash($hash, $holder) ->setInstallmentCount(3) ->setStatementDescriptor("Minha Loja") - ->setDelayCapture(true) + ->setDelayCapture() ->execute(); ``` @@ -777,31 +776,15 @@ $holderName = 'Nome do Portador'; $taxDocument = '22222222222'; $transfer = $moip->transfers() - ->setAmount($amount) - ->transferToBankAccount($bank_number, $agency_number, $agency_check_number, $account_number, $account_check_number) - ->setHolder($holder_name, $tax_document, $tax_document_pf) + ->setTransfers($amount, $bankNumber, $agencyNumber, $agencyCheckNumber, $accountNumber, $accountCheckNumber) + ->setHolder($holderName, $taxDocument) ->execute(); ``` To transfer using a previously created bank account: ```php -$amount = 500; -$id = 'BKA-HUGBGX2QT9JY'; - -$transfer = $moip->transfers() - ->setAmount($amount) - ->transferWithBankAccountId($id) - ->execute(); -``` - -#### Transfer to a Moip Account -```php -$amount = 1000; -$id = 'MPA-5E1C4C369E8C'; - $transfer = $moip->transfers() - ->setAmount($amount) - ->transferToMoipAccount($id) + ->setTransfersToBankAccount($amount, $bankAccountId) ->execute(); ``` diff --git a/README.md b/README.md old mode 100755 new mode 100644 index 70149bf..16376d7 --- a/README.md +++ b/README.md @@ -216,8 +216,6 @@ $order = $moip->orders()->setOwnId(uniqid()) ->addItem("bicicleta 9",1, "sku9", 18000) ->addItem("bicicleta 10",1, "sku10", 19000) ->setShippingAmount(3000)->setAddition(1000)->setDiscount(5000) - ->setUrlSuccess('https://sualoja.com.br/url-confirmacao-de-pagamento') - ->setUrlFailure('https://sualoja.com.br/url-falha-no-pagamento') ->setCustomer($customer) ->create(); print_r($order); @@ -790,4 +788,4 @@ vendor/bin/phpunit -c . ## Comunidade Slack [![Slack](https://user-images.githubusercontent.com/4432322/37355972-ba0e9f32-26c3-11e8-93d3-39917eb24109.png)](https://slackin-cqtchmfquq.now.sh) -Tem dúvidas? Fale com a gente no [Slack](https://slackin-cqtchmfquq.now.sh/)! +Tem dúvidas? Fale com a gente no [Slack](https://slackin-cqtchmfquq.now.sh/)! \ No newline at end of file diff --git a/circle.yml b/circle.yml old mode 100755 new mode 100644 diff --git a/composer.json b/composer.json old mode 100755 new mode 100644 diff --git a/examples/ecommerce/simple_boleto_payment.php b/examples/ecommerce/simple_boleto_payment.php new file mode 100644 index 0000000..2eff4b0 --- /dev/null +++ b/examples/ecommerce/simple_boleto_payment.php @@ -0,0 +1,76 @@ +customers()->setOwnId(uniqid()) + ->setFullname('Fulano de Tal') + ->setEmail('fulano@email.com') + ->setBirthDate('1988-12-30') + ->setTaxDocument('22222222222') + ->setPhone(11, 66778899) + ->addAddress('BILLING', + 'Rua de teste', 123, + 'Bairro', 'Sao Paulo', 'SP', + '01234567', 8) + ->addAddress('SHIPPING', + 'Rua de teste do SHIPPING', 123, + 'Bairro do SHIPPING', 'Sao Paulo', 'SP', + '01234567', 8) + ->create(); + + // Creating an order + $order = $moip->orders()->setOwnId(uniqid()) + ->addItem('bicicleta 1', 1, 'sku1', 10000) + ->addItem('bicicleta 2', 1, 'sku2', 11000) + ->addItem('bicicleta 3', 1, 'sku3', 12000) + ->addItem('bicicleta 4', 1, 'sku4', 13000) + ->addItem('bicicleta 5', 1, 'sku5', 14000) + ->addItem('bicicleta 6', 1, 'sku6', 15000) + ->addItem('bicicleta 7', 1, 'sku7', 16000) + ->addItem('bicicleta 8', 1, 'sku8', 17000) + ->addItem('bicicleta 9', 1, 'sku9', 18000) + ->addItem('bicicleta 10', 1, 'sku10', 19000) + ->setShippingAmount(3000)->setAddition(1000)->setDiscount(5000) + ->setCustomer($customer) + ->create(); + + $logo_uri = 'https://cdn.moip.com.br/wp-content/uploads/2016/05/02163352/logo-moip.png'; + $expiration_date = (new DateTime())->add(new DateInterval('P3D')); + $instruction_lines = ['INSTRUÇÃO 1', 'INSTRUÇÃO 2', 'INSTRUÇÃO 3']; + + // Creating payment to order + $payment = $order->payments() + ->setBoleto($expiration_date, $logo_uri, $instruction_lines) + ->execute(); + + echo 'Order ID: '.$order->getId().'
'; + echo 'Payment ID: '.$payment->getId().'
'; + echo 'Created at: '.$payment->getCreatedAt()->format('Y-m-d H:i:s').'
'; + echo 'Status: '.$payment->getStatus().'
'; + echo 'Amount: '.$payment->getAmount()->total.'
'; + echo 'Funding Instrument: '.$payment->getFundingInstrument()->method.'
'; +} catch (\Moip\Exceptions\UnautorizedException $e) { + echo $e->getMessage(); +} catch (\Moip\Exceptions\ValidationException $e) { + printf($e->__toString()); +} catch (\Moip\Exceptions\UnexpectedException $e) { + echo $e->getMessage(); +} diff --git a/examples/ecommerce/simple_creditcard_payment.php b/examples/ecommerce/simple_creditcard_payment.php new file mode 100644 index 0000000..3251f50 --- /dev/null +++ b/examples/ecommerce/simple_creditcard_payment.php @@ -0,0 +1,80 @@ +customers()->setOwnId(uniqid()) + ->setFullname('Fulano de Tal') + ->setEmail('fulano@email.com') + ->setBirthDate('1988-12-30') + ->setTaxDocument('22222222222') + ->setPhone(11, 66778899) + ->addAddress('BILLING', + 'Rua de teste', 123, + 'Bairro', 'Sao Paulo', 'SP', + '01234567', 8) + ->addAddress('SHIPPING', + 'Rua de teste do SHIPPING', 123, + 'Bairro do SHIPPING', 'Sao Paulo', 'SP', + '01234567', 8) + ->create(); + + // Creating an order + $order = $moip->orders()->setOwnId(uniqid()) + ->addItem('bicicleta 1', 1, 'sku1', 10000) + ->addItem('bicicleta 2', 1, 'sku2', 11000) + ->addItem('bicicleta 3', 1, 'sku3', 12000) + ->addItem('bicicleta 4', 1, 'sku4', 13000) + ->addItem('bicicleta 5', 1, 'sku5', 14000) + ->addItem('bicicleta 6', 1, 'sku6', 15000) + ->addItem('bicicleta 7', 1, 'sku7', 16000) + ->addItem('bicicleta 8', 1, 'sku8', 17000) + ->addItem('bicicleta 9', 1, 'sku9', 18000) + ->addItem('bicicleta 10', 1, 'sku10', 19000) + ->setShippingAmount(3000)->setAddition(1000)->setDiscount(5000) + ->setCustomer($customer) + ->create(); + + // Creating payment to order + $payment = $order->payments() + ->setCreditCardHash($hash, $customer) + ->setInstallmentCount(3) + ->setStatementDescriptor('teste de pag') + ->execute(); + + echo 'Order ID: '.$order->getId().'
'; + echo 'Payment ID: '.$payment->getId().'
'; + echo 'Created at: '.$payment->getCreatedAt()->format('Y-m-d H:i:s').'
'; + echo 'Status: '.$payment->getStatus().'
'; + echo 'Amount: '.$payment->getAmount()->total.'
'; + echo 'Funding Instrument: '.$payment->getFundingInstrument()->method.'
'; + echo 'Installment Count: '.$payment->getInstallmentCount().'
'; +} catch (\Moip\Exceptions\UnautorizedException $e) { + echo $e->getMessage(); +} catch (\Moip\Exceptions\ValidationException $e) { + printf($e->__toString()); +} catch (\Moip\Exceptions\UnexpectedException $e) { + echo $e->getMessage(); +} diff --git a/examples/marketplace/classical_moip_account_flow_part_1.php b/examples/marketplace/classical_moip_account_flow_part_1.php old mode 100755 new mode 100644 diff --git a/examples/marketplace/classical_moip_account_flow_part_2.php b/examples/marketplace/classical_moip_account_flow_part_2.php old mode 100755 new mode 100644 diff --git a/examples/marketplace/multiorder_and_multipayment.php b/examples/marketplace/multiorder_and_multipayment.php old mode 100755 new mode 100644 diff --git a/examples/marketplace/transparent_moip_account_flow.php b/examples/marketplace/transparent_moip_account_flow.php old mode 100755 new mode 100644 diff --git a/phpunit.xml b/phpunit.xml old mode 100755 new mode 100644 diff --git a/src/Auth/BasicAuth.php b/src/Auth/BasicAuth.php old mode 100755 new mode 100644 diff --git a/src/Auth/Connect.php b/src/Auth/Connect.php old mode 100755 new mode 100644 diff --git a/src/Auth/OAuth.php b/src/Auth/OAuth.php old mode 100755 new mode 100644 diff --git a/src/Contracts/Authentication.php b/src/Contracts/Authentication.php old mode 100755 new mode 100644 diff --git a/src/Exceptions/Error.php b/src/Exceptions/Error.php old mode 100755 new mode 100644 diff --git a/src/Exceptions/InvalidArgumentException.php b/src/Exceptions/InvalidArgumentException.php old mode 100755 new mode 100644 diff --git a/src/Exceptions/UnautorizedException.php b/src/Exceptions/UnautorizedException.php old mode 100755 new mode 100644 diff --git a/src/Exceptions/UnexpectedException.php b/src/Exceptions/UnexpectedException.php old mode 100755 new mode 100644 diff --git a/src/Exceptions/ValidationException.php b/src/Exceptions/ValidationException.php old mode 100755 new mode 100644 diff --git a/src/Helper/Filters.php b/src/Helper/Filters.php old mode 100755 new mode 100644 diff --git a/src/Helper/Links.php b/src/Helper/Links.php old mode 100755 new mode 100644 diff --git a/src/Helper/Pagination.php b/src/Helper/Pagination.php old mode 100755 new mode 100644 diff --git a/src/Helper/Utils.php b/src/Helper/Utils.php old mode 100755 new mode 100644 diff --git a/src/Helper/helpers.php b/src/Helper/helpers.php old mode 100755 new mode 100644 diff --git a/src/Moip.php b/src/Moip.php old mode 100755 new mode 100644 diff --git a/src/Resource/Account.php b/src/Resource/Account.php old mode 100755 new mode 100644 diff --git a/src/Resource/Balances.php b/src/Resource/Balances.php old mode 100755 new mode 100644 diff --git a/src/Resource/BankAccount.php b/src/Resource/BankAccount.php old mode 100755 new mode 100644 diff --git a/src/Resource/BankAccountList.php b/src/Resource/BankAccountList.php old mode 100755 new mode 100644 diff --git a/src/Resource/Customer.php b/src/Resource/Customer.php old mode 100755 new mode 100644 index 68a20fc..2dc86ee --- a/src/Resource/Customer.php +++ b/src/Resource/Customer.php @@ -234,16 +234,6 @@ public function getTaxDocumentNumber() return $this->getIfSet('number', $this->data->taxDocument); } - /** - * Get funding instruments from customer. - * - * @return array FundingInstruments. - */ - public function getFundingInstruments() - { - return $this->getIfSet('fundingInstruments'); - } - /** * Mount the buyer structure from customer. * @@ -274,7 +264,6 @@ protected function populate(stdClass $response) $customer->data->shippingAddress = $this->getIfSet('shippingAddress', $response); $customer->data->billingAddress = $this->getIfSet('billingAddress', $response); $customer->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); - $customer->data->fundingInstruments = $this->getIfSet('fundingInstruments', $response); $customer->data->_links = $this->getIfSet('_links', $response); diff --git a/src/Resource/CustomerCreditCard.php b/src/Resource/CustomerCreditCard.php old mode 100755 new mode 100644 diff --git a/src/Resource/EntriesList.php b/src/Resource/EntriesList.php deleted file mode 100755 index c79314b..0000000 --- a/src/Resource/EntriesList.php +++ /dev/null @@ -1,82 +0,0 @@ -data = new stdClass(); - $this->data->summary = new stdClass(); - $this->data->_links = new stdClass(); - $this->data->entries = []; - } - - /** - * Get summary. - * - * @return stdClass - */ - public function getSummary() - { - return $this->getIfSet('summary'); - } - - /** - * Get _links. - * - * @return stdClass - */ - public function getLinks() - { - return $this->getIfSet('_links'); - } - - /** - * Get entries. - * - * @return array - */ - public function getEntries() - { - return $this->getIfSet('entries'); - } - - /** - * Get a entries list. - * - * @return stdClass - */ - public function get() - { - $path = sprintf('/%s/%s', MoipResource::VERSION, self::PATH); - - return $this->getByPath($path, ['Accept' => static::ACCEPT_VERSION]); - } - - protected function populate(stdClass $response) - { - $entriesList = clone $this; - - $entriesList->data->summary->amount = $response->summary->amount; - - $entriesList->data->summary->count = $response->summary->count; - - $entriesList->data->_links->previous = new stdClass(); - $entriesList->data->_links->previous->href = $response->_links->previous->href; - - $entriesList->data->_links->next = new stdClass(); - $entriesList->data->_links->next->href = $response->_links->next->href; - - $entriesList->data->entries = $response->entries; - - return $entriesList; - } -} diff --git a/src/Resource/Entry.php b/src/Resource/Entry.php old mode 100755 new mode 100644 index 578419d..1cb8085 --- a/src/Resource/Entry.php +++ b/src/Resource/Entry.php @@ -73,18 +73,6 @@ public function get($id_moip) return $this->getByPath(sprintf('/%s/%s/%s/', MoipResource::VERSION, self::PATH, $id_moip)); } - /** - * Create a new Entries List instance. - * - * @return \Moip\Resource\EntriesList - */ - public function getList() - { - $entriesList = new EntriesList($this->moip); - - return $entriesList->get(); - } - /** * Get id from entry. * diff --git a/src/Resource/Escrow.php b/src/Resource/Escrow.php old mode 100755 new mode 100644 diff --git a/src/Resource/Event.php b/src/Resource/Event.php old mode 100755 new mode 100644 diff --git a/src/Resource/Holder.php b/src/Resource/Holder.php old mode 100755 new mode 100644 diff --git a/src/Resource/Keys.php b/src/Resource/Keys.php old mode 100755 new mode 100644 diff --git a/src/Resource/MoipResource.php b/src/Resource/MoipResource.php old mode 100755 new mode 100644 index 09e0df1..a73ca3c --- a/src/Resource/MoipResource.php +++ b/src/Resource/MoipResource.php @@ -138,8 +138,6 @@ protected function getIfSetDate($key, stdClass $data = null) */ protected function getIfSetDateTime($key, stdClass $data = null) { - date_default_timezone_set('Brazil/East'); - $rawDateTime = $this->getIfSet($key, $data); $dateTime = null; @@ -223,7 +221,6 @@ public function generateListPath(Pagination $pagination = null, Filters $filters * @param string $method http method * @param mixed|null $payload request body * @param array $headers request headers - * @param string $accept * * @throws Exceptions\ValidationException if the API returns a 4xx http status code. Usually means invalid data was sent. * @throws Exceptions\UnautorizedException if the API returns a 401 http status code. Check API token and key. diff --git a/src/Resource/Multiorders.php b/src/Resource/Multiorders.php old mode 100755 new mode 100644 diff --git a/src/Resource/NotificationPreferences.php b/src/Resource/NotificationPreferences.php old mode 100755 new mode 100644 diff --git a/src/Resource/NotificationPreferencesList.php b/src/Resource/NotificationPreferencesList.php old mode 100755 new mode 100644 diff --git a/src/Resource/Orders.php b/src/Resource/Orders.php old mode 100755 new mode 100644 diff --git a/src/Resource/OrdersList.php b/src/Resource/OrdersList.php old mode 100755 new mode 100644 diff --git a/src/Resource/Payment.php b/src/Resource/Payment.php old mode 100755 new mode 100644 index 92ee3f9..89f99df --- a/src/Resource/Payment.php +++ b/src/Resource/Payment.php @@ -123,7 +123,6 @@ protected function initialize() $this->data = new stdClass(); $this->data->installmentCount = 1; $this->data->fundingInstrument = new stdClass(); - $this->data->device = new stdClass(); } /** @@ -190,7 +189,6 @@ protected function populate(stdClass $response) $payment->data->amount->currency = $this->getIfSet('currency', $response->amount); $payment->data->installmentCount = $this->getIfSet('installmentCount', $response); $payment->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); - $payment->data->device = $this->getIfSet('device', $response); $payment->data->payments = $this->getIfSet('payments', $response); $payment->data->escrows = $this->getIfSet('escrows', $response); $payment->data->fees = $this->getIfSet('fees', $response); @@ -269,17 +267,6 @@ public function getFundingInstrument() return $this->data->fundingInstrument; } - /** - * Returns the funding instrument. - * - * @return stdClass - */ - public function getDeviceFingerprint() - { - //todo: return a funding instrument object - return $this->data->device; - } - /** * Get href to Boleto * *. @@ -334,16 +321,6 @@ public function getAmount() return $this->data->amount; } - /** - * Returns delay capture. - * - * @return stdClass - */ - public function getDelayCapture() - { - return $this->data->delayCapture; - } - /** * Returns escrow. * @@ -398,20 +375,6 @@ public function setFundingInstrument(stdClass $fundingInstrument) return $this; } - /** - * Set payment device. - * - * @param \stdClass $device - * - * @return $this - */ - public function setDevice(stdClass $device) - { - $this->data->device = $device; - - return $this; - } - /** * Set billet. * @@ -564,30 +527,6 @@ public function setStatementDescriptor($statementDescriptor) return $this; } - /** - * Set device fingerprint - * Customer device data used in the payment. - * - * @param string $ip Customer IP address - * @param float $latitude Customer latitude. - * @param float $longitude Customer longitude. - * @param string $userAgent Device userAgent. - * @param string $fingerprint Device fingerprint. - * - * @return $this - */ - public function setDeviceFingerprint($ip, $latitude, $longitude, $userAgent, $fingerprint) - { - $this->data->device->geolocation = new stdClass(); - $this->data->device->geolocation->latitude = $latitude; - $this->data->device->geolocation->longitude = $longitude; - $this->data->device->ip = $ip; - $this->data->device->userAgent = $userAgent; - $this->data->device->fingerprint = $fingerprint; - - return $this; - } - /** * Set payment means made available by banks. * @@ -644,9 +583,9 @@ public function setOrder(Orders $order) * * @return $this */ - public function setDelayCapture($delayCapture = true) + public function setDelayCapture() { - $this->data->delayCapture = $delayCapture; + $this->data->delayCapture = true; return $this; } diff --git a/src/Resource/Refund.php b/src/Resource/Refund.php old mode 100755 new mode 100644 diff --git a/src/Resource/Transfers.php b/src/Resource/Transfers.php old mode 100755 new mode 100644 index 8f4f477..404c4a0 --- a/src/Resource/Transfers.php +++ b/src/Resource/Transfers.php @@ -20,17 +20,17 @@ class Transfers extends MoipResource /** * @const string */ - const METHOD_BKA = 'BANK_ACCOUNT'; + const METHOD = 'BANK_ACCOUNT'; /** * @const string */ - const METHOD_MPA = 'MOIP_ACCOUNT'; + const TYPE = 'CHECKING'; /** * @const string */ - const TYPE = 'CHECKING'; + const TYPE_HOLD = 'CPF'; /** * Initializes new instances. @@ -39,7 +39,6 @@ protected function initialize() { $this->data = new stdClass(); $this->data->transferInstrument = new stdClass(); - $this->data->transferInstrument->moipAccount = new stdClass(); $this->data->transferInstrument->bankAccount = new stdClass(); $this->data->transferInstrument->bankAccount->holder = new stdClass(); $this->data->transferInstrument->bankAccount->holder->taxDocument = new stdClass(); @@ -58,25 +57,21 @@ protected function populate(stdClass $response) $transfers->data->ownId = $this->getIfSet('ownId', $response); $transfers->data->amount = $this->getIfSet('amount', $response); - $transferInstrument = $this->getIfSet('transferInstrument', $response); + $transfer_instrument = $this->getIfSet('transferInstrument', $response); $transfers->data->transferInstrument = new stdClass(); - $transfers->data->transferInstrument->method = $this->getIfSet('method', $transferInstrument); + $transfers->data->transferInstrument->method = $this->getIfSet('method', $transfer_instrument); - $moipAccount = $this->getIfSet('moipAccount', $transferInstrument); - $transfers->data->transferInstrument->moipAccount = new stdClass(); - $transfers->data->transferInstrument->moipAccount->id = $this->getIfSet('id', $moipAccount); - - $bankAccount = $this->getIfSet('bankAccount', $transferInstrument); + $bank_account = $this->getIfSet('bankAccount', $transfer_instrument); $transfers->data->transferInstrument->bankAccount = new stdClass(); - $transfers->data->transferInstrument->bankAccount->id = $this->getIfSet('id', $bankAccount); - $transfers->data->transferInstrument->bankAccount->type = $this->getIfSet('type', $bankAccount); - $transfers->data->transferInstrument->bankAccount->bankNumber = $this->getIfSet('bankNumber', $bankAccount); - $transfers->data->transferInstrument->bankAccount->agencyNumber = $this->getIfSet('agencyNumber', $bankAccount); - $transfers->data->transferInstrument->bankAccount->agencyCheckNumber = $this->getIfSet('agencyCheckNumber', $bankAccount); - $transfers->data->transferInstrument->bankAccount->accountNumber = $this->getIfSet('accountNumber', $bankAccount); - $transfers->data->transferInstrument->bankAccount->accountCheckNumber = $this->getIfSet('accountCheckNumber', $bankAccount); - - $holder = $this->getIfSet('holder', $bankAccount); + $transfers->data->transferInstrument->bankAccount->id = $this->getIfSet('id', $bank_account); + $transfers->data->transferInstrument->bankAccount->type = $this->getIfSet('type', $bank_account); + $transfers->data->transferInstrument->bankAccount->bankNumber = $this->getIfSet('bankNumber', $bank_account); + $transfers->data->transferInstrument->bankAccount->agencyNumber = $this->getIfSet('agencyNumber', $bank_account); + $transfers->data->transferInstrument->bankAccount->agencyCheckNumber = $this->getIfSet('agencyCheckNumber', $bank_account); + $transfers->data->transferInstrument->bankAccount->accountNumber = $this->getIfSet('accountNumber', $bank_account); + $transfers->data->transferInstrument->bankAccount->accountCheckNumber = $this->getIfSet('accountCheckNumber', $bank_account); + + $holder = $this->getIfSet('holder', $bank_account); $transfers->data->transferInstrument->bankAccount->holder = new stdClass(); $transfers->data->transferInstrument->bankAccount->holder->fullname = $this->getIfSet('fullname', $holder); @@ -89,32 +84,9 @@ protected function populate(stdClass $response) } /** - * Set the amount of transfer. - * - * @param int $amount - * - * @return $this - */ - public function setAmount($amount) - { - $this->data->amount = $amount; - - return $this; - } - - /** - * Returns amount. - * - * @return amount - */ - public function getAmount() - { - return $this->data->amount; - } - - /** - * Set the bank accout transfer. + * Set info of transfers. * + * @param int $amount * @param string $bankNumber Bank number. possible values: 001, 237, 341, 041. * @param int $agencyNumber * @param int $agencyCheckNumber @@ -123,14 +95,16 @@ public function getAmount() * * @return $this */ - public function transferToBankAccount( + public function setTransfers( + $amount, $bankNumber, $agencyNumber, $agencyCheckNumber, $accountNumber, $accountCheckNumber ) { - $this->data->transferInstrument->method = self::METHOD_BKA; + $this->data->amount = $amount; + $this->data->transferInstrument->method = self::METHOD; $this->data->transferInstrument->bankAccount->type = self::TYPE; $this->data->transferInstrument->bankAccount->bankNumber = $bankNumber; $this->data->transferInstrument->bankAccount->agencyNumber = $agencyNumber; @@ -142,33 +116,22 @@ public function transferToBankAccount( } /** - * Set the ID of a saved bank account. + * Set info of transfers to a saved bank account. * - * @param string $bankAccountId Saved bank account ID (BKA-XXXXXXX). + * @param int $amount Amount + * @param string $bankAccountId Saved bank account id. * * @return $this */ - public function transferWithBankAccountId($bankAccountId) + public function setTransfersToBankAccount($amount, $bankAccountId) { - $this->data->transferInstrument->method = self::METHOD_BKA; + $this->data->amount = $amount; + $this->data->transferInstrument->method = self::METHOD; $this->data->transferInstrument->bankAccount->id = $bankAccountId; return $this; } - /** - * Set the Moip Account ID to create a transfer to this account. - * - * @param string $moipAccountId The Moip Account ID (MPA-XXXXXXX) - */ - public function transferToMoipAccount($moipAccountId) - { - $this->data->transferInstrument->method = self::METHOD_MPA; - $this->data->transferInstrument->moipAccount->id = $moipAccountId; - - return $this; - } - /** * Returns transfer. * @@ -201,11 +164,11 @@ public function setOwnId($ownId) * * @return $this */ - public function setHolder($fullname, $taxDocumentNumber, $taxDocumentType = 'CPF') + public function setHolder($fullname, $taxDocument) { $this->data->transferInstrument->bankAccount->holder->fullname = $fullname; - $this->data->transferInstrument->bankAccount->holder->taxDocument->type = $taxDocumentType; - $this->data->transferInstrument->bankAccount->holder->taxDocument->number = $taxDocumentNumber; + $this->data->transferInstrument->bankAccount->holder->taxDocument->type = self::TYPE_HOLD; + $this->data->transferInstrument->bankAccount->holder->taxDocument->number = $taxDocument; return $this; } diff --git a/src/Resource/TransfersList.php b/src/Resource/TransfersList.php old mode 100755 new mode 100644 diff --git a/src/Resource/Webhook.php b/src/Resource/Webhook.php old mode 100755 new mode 100644 diff --git a/src/Resource/WebhookList.php b/src/Resource/WebhookList.php old mode 100755 new mode 100644 diff --git a/tests/Helper/FiltersTest.php b/tests/Helper/FiltersTest.php old mode 100755 new mode 100644 diff --git a/tests/Helper/LinksTest.php b/tests/Helper/LinksTest.php old mode 100755 new mode 100644 diff --git a/tests/MoipTest.php b/tests/MoipTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/AccountTest.php b/tests/Resource/AccountTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/BalancesTest.php b/tests/Resource/BalancesTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/BankAccountListTest.php b/tests/Resource/BankAccountListTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/BankAccountTest.php b/tests/Resource/BankAccountTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/CustomerTest.php b/tests/Resource/CustomerTest.php old mode 100755 new mode 100644 index b5d048e..9ae8fc6 --- a/tests/Resource/CustomerTest.php +++ b/tests/Resource/CustomerTest.php @@ -94,18 +94,4 @@ public function testCreateCreditCard() $this->assertEquals($creditCard->getFirst6(), '401200'); $this->assertEquals($creditCard->getLast4(), '1112'); } - - /** - * MoipTest get credit cards for customer. - */ - public function testFundingInstruments() - { - $this->mockHttpSession($this->body_get_customer); - $getCustomer = $this->moip->customers()->get('CUS-Q273W8ZY54IV'); - - $this->assertEquals($getCustomer->getFundingInstruments()[0]->creditCard->id, 'CRC-7LKWIS07IETJ'); - $this->assertEquals($getCustomer->getFundingInstruments()[0]->creditCard->brand, 'VISA'); - $this->assertEquals($getCustomer->getFundingInstruments()[0]->creditCard->first6, '411111'); - $this->assertEquals($getCustomer->getFundingInstruments()[0]->creditCard->last4, '1111'); - } } diff --git a/tests/Resource/EntriesListTest.php b/tests/Resource/EntriesListTest.php deleted file mode 100755 index e0ab71d..0000000 --- a/tests/Resource/EntriesListTest.php +++ /dev/null @@ -1,20 +0,0 @@ -mockHttpSession($this->body_entries_list); - - $entries = $this->moip->entries()->getList(); - - $this->assertEquals(67958700, $entries->getSummary()->amount); - $this->assertEquals('https://sandbox.moip.com.br/v2/entries?offset=0&limit=20', $entries->getLinks()->previous->href); - $this->assertNotNull($entries->getEntries()); - $this->assertEquals('ENT-PA0KQG8CCI4O', $entries->getEntries()[0]->id); - } -} diff --git a/tests/Resource/EscrowTest.php b/tests/Resource/EscrowTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/KeyTest.php b/tests/Resource/KeyTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/MoipResourceTest.php b/tests/Resource/MoipResourceTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/NotificationPreferencesListTest.php b/tests/Resource/NotificationPreferencesListTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/NotificationPreferencesTest.php b/tests/Resource/NotificationPreferencesTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/OrdersListTest.php b/tests/Resource/OrdersListTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/OrdersTest.php b/tests/Resource/OrdersTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/PaymentTest.php b/tests/Resource/PaymentTest.php old mode 100755 new mode 100644 index 8a778b9..955abc6 --- a/tests/Resource/PaymentTest.php +++ b/tests/Resource/PaymentTest.php @@ -104,7 +104,6 @@ public function testCapturePreAuthorizedPayment() $captured_payment = $payment->capture(); $this->assertEquals('AUTHORIZED', $captured_payment->getStatus()); - $this->assertEquals(true, $captured_payment->getDelayCapture()); } public function testCapturePreAuthorizedMultiPayment() diff --git a/tests/Resource/RefundTest.php b/tests/Resource/RefundTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/TransfersListTest.php b/tests/Resource/TransfersListTest.php old mode 100755 new mode 100644 diff --git a/tests/Resource/TransfersTest.php b/tests/Resource/TransfersTest.php old mode 100755 new mode 100644 index c6d37d0..ca9ba3a --- a/tests/Resource/TransfersTest.php +++ b/tests/Resource/TransfersTest.php @@ -8,7 +8,7 @@ class TransfersTest extends TestCase { private function createTransfer() { - $this->mockHttpSession($this->body_transfers_bankaccount_create); + $this->mockHttpSession($this->body_transfers_create); $amount = 500; $bank_number = '001'; @@ -19,8 +19,7 @@ private function createTransfer() $holder_name = 'Integração Taxa por canal'; $tax_document = '033.575.852-51'; $transfer = $this->moip->transfers() - ->setAmount($amount) - ->transferToBankAccount($bank_number, $agency_number, $agency_check_number, $account_number, $account_check_number) + ->setTransfers($amount, $bank_number, $agency_number, $agency_check_number, $account_number, $account_check_number) ->setHolder($holder_name, $tax_document) ->execute(); @@ -56,36 +55,21 @@ public function testShouldCreateTransferWithBankAccountId() { $bank_account = $this->createBankAccount(); - $this->mockHttpSession($this->body_transfers_bankaccount_create); + $this->mockHttpSession($this->body_transfers_create); $amount = 500; $transfer = $this->moip->transfers() - ->setAmount($amount) - ->transferWithBankAccountId($bank_account->getId()) + ->setTransfersToBankAccount($amount, $bank_account->getId()) ->execute(); $this->assertNotEmpty($transfer->getId()); } - public function testShouldCreateTransferWithMoipAccountId() - { - $this->mockHttpSession($this->body_transfers_moipaccount_create); - - $ammount = 500; - $moipAccountId = 'MPA-5E1C4C369E8C'; - $transfer = $this->moip->transfers() - ->setAmount($ammount) - ->transferToMoipAccount($moipAccountId) - ->execute(); - - $this->assertNotEmpty($transfer->getAmount()); - } - public function testShouldGetTransfer() { $transfer_id = $this->createTransfer()->getId(); - $this->mockHttpSession($this->body_transfers_bankaccount_create); + $this->mockHttpSession($this->body_transfers_create); $transfer = $this->moip->transfers()->get($transfer_id); $this->assertEquals($transfer_id, $transfer->getId()); diff --git a/tests/Resource/WebhookListTest.php b/tests/Resource/WebhookListTest.php old mode 100755 new mode 100644 diff --git a/tests/TestCase.php b/tests/TestCase.php old mode 100755 new mode 100644 index a721624..afa8ccb --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -146,16 +146,6 @@ abstract class TestCase extends BaseTestCase */ protected $body_balances; - /** - * @var string response from moip API. - */ - protected $body_get_customer; - - /** - * @var string response from moip API. - */ - protected $body_entries_list; - /** * @var string holds the last generated customer ownId. In mock mode it'll be always the default, but it changes on sandbox mode. */ @@ -229,9 +219,7 @@ public function __construct() $this->body_keys = $this->readJsonFile('jsons/keys/get'); - $this->body_transfers_bankaccount_create = $this->readJsonFile('jsons/transfers/create_bankaccount'); - - $this->body_transfers_moipaccount_create = $this->readJsonFile('jsons/transfers/create_moipaccount'); + $this->body_transfers_create = $this->readJsonFile('jsons/transfers/create'); $this->body_transfers_list = $this->readJsonFile('jsons/transfers/list'); @@ -262,10 +250,6 @@ public function __construct() $this->body_bank_account_update = $this->readJsonFile('jsons/bank_account/update'); $this->body_balances = $this->readJsonFile('jsons/balances/get'); - - $this->body_entries_list = $this->readJsonFile('jsons/entries/list'); - - $this->body_get_customer = $this->readJsonFile('jsons/customer/get'); } /** diff --git a/tests/jsons/account/create.json b/tests/jsons/account/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/account/get.json b/tests/jsons/account/get.json old mode 100755 new mode 100644 diff --git a/tests/jsons/balances/get.json b/tests/jsons/balances/get.json old mode 100755 new mode 100644 diff --git a/tests/jsons/bank_account/create.json b/tests/jsons/bank_account/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/bank_account/list.json b/tests/jsons/bank_account/list.json old mode 100755 new mode 100644 diff --git a/tests/jsons/bank_account/update.json b/tests/jsons/bank_account/update.json old mode 100755 new mode 100644 diff --git a/tests/jsons/customer/add_credit_card.json b/tests/jsons/customer/add_credit_card.json old mode 100755 new mode 100644 diff --git a/tests/jsons/customer/create.json b/tests/jsons/customer/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/customer/get.json b/tests/jsons/customer/get.json deleted file mode 100755 index dd1d5bd..0000000 --- a/tests/jsons/customer/get.json +++ /dev/null @@ -1,65 +0,0 @@ -{ - "id": "CUS-Q273W8ZY54IV", - "ownId": "david-luis-da-silva-1463665041046", - "fullname": "David Luis da Silva", - "createdAt": "2016-05-19T00:00:00.000-03", - "updatedAt": "2018-05-17T11:13:31.000-03", - "birthDate": "1986-01-12", - "email": "dluis@dluis.com", - "fundingInstrument": { - "creditCard": { - "id": "CRC-4AQHX4AOL42B", - "brand": "VISA", - "first6": "407302", - "last4": "0002", - "store": true - }, - "method": "CREDIT_CARD" - }, - "phone": { - "countryCode": "55", - "areaCode": "1)", - "number": "88886666" - }, - "taxDocument": { - "type": "CPF", - "number": "22222222222" - }, - "billingAddress": { - "zipCode": "45555400", - "street": "Rua dos Jogadores", - "streetNumber": "123", - "complement": "cobertura", - "city": "São Paulo", - "district": "Jd. das Mamgabeiras", - "state": "São Paulo", - "country": "Brasil" - }, - "_links": { - "self": { - "href": "https://sandbox.moip.com.br/v2/customers/CUS-Q273W8ZY54IV" - } - }, - "fundingInstruments": [ - { - "creditCard": { - "id": "CRC-7LKWIS07IETJ", - "brand": "VISA", - "first6": "411111", - "last4": "1111", - "store": true - }, - "method": "CREDIT_CARD" - }, - { - "creditCard": { - "id": "CRC-4AQHX4AOL42B", - "brand": "VISA", - "first6": "407302", - "last4": "0002", - "store": true - }, - "method": "CREDIT_CARD" - } - ] -} \ No newline at end of file diff --git a/tests/jsons/entries/list.json b/tests/jsons/entries/list.json deleted file mode 100755 index 3ab6ded..0000000 --- a/tests/jsons/entries/list.json +++ /dev/null @@ -1,815 +0,0 @@ -{ - "summary":{ - "amount":67958700, - "count":254 - }, - "_links":{ - "previous":{ - "href":"https://sandbox.moip.com.br/v2/entries?offset=0&limit=20" - }, - "next":{ - "href":"https://sandbox.moip.com.br/v2/entries?offset=20&limit=20" - } - }, - "entries":[ - { - "reschedule":[ - - ], - "scheduledFor":"2017-07-20T16:54:00.000Z", - "status":"SCHEDULED", - "_links":{ - "order":{ - "title":"ORD-ZNCBW32Q46FK", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-ZNCBW32Q46FK" - }, - "payment":{ - "title":"PAY-4C6FWZ9P05HZ", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-4C6FWZ9P05HZ" - }, - "self":{ - "title":"ENT-PA0KQG8CCI4O", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-PA0KQG8CCI4O" - } - }, - "type":"CREDIT_CARD", - "ownId":"seu_identificador_proprio", - "updatedAt":"2017-07-06T13:54:01.000Z", - "id":"ENT-PA0KQG8CCI4O", - "amount":{ - "fee":179, - "total":2000, - "liquid":1821, - "currency":"BRL" - }, - "operation":"CREDIT", - "event":"PAY-4C6FWZ9P05HZ", - "description":"Cartao de credito - Pedido PAY-4C6FWZ9P05HZ", - "createdAt":"2017-07-06T13:54:01.000Z", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "additionalId":36494111 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-08-17T16:58:08.000Z", - "status":"SETTLED", - "_links":{ - "self":{ - "title":"ENT-3QEC6KYWLA7E", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-3QEC6KYWLA7E" - } - }, - "type":"AMOUNT_BLOCKED", - "ownId":"", - "updatedAt":"2017-08-17T13:58:08.000Z", - "id":"ENT-3QEC6KYWLA7E", - "amount":{ - "fee":0, - "total":-14107, - "liquid":-14107, - "currency":"BRL" - }, - "operation":"DEBIT", - "createdAt":"2017-08-17T13:58:08.000Z", - "event":"PAY-Z9B2ZSKZ6MEW", - "description":"Cartao de credito - Pedido PAY-Z9B2ZSKZ6MEW", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-08-17T13:58:08.000Z", - "additionalId":36528311 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-08-25T14:22:09.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-0Q2WZLHFFHOY", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-0Q2WZLHFFHOY" - }, - "payment":{ - "title":"PAY-10C3S84K4C42", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-10C3S84K4C42" - }, - "self":{ - "title":"ENT-P2X6WSVJ4ZSB", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-P2X6WSVJ4ZSB" - } - }, - "type":"CREDIT_CARD", - "ownId":"seu_identificador_proprio", - "updatedAt":"2017-08-25T00:20:17.000Z", - "id":"ENT-P2X6WSVJ4ZSB", - "amount":{ - "fee":0, - "total":1400, - "liquid":1400, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-11T14:22:10.000Z", - "event":"PAY-10C3S84K4C42", - "description":"Cartao de credito - Pedido PAY-10C3S84K4C42", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-08-25T00:20:17.000Z", - "additionalId":36523551 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-08-25T17:10:11.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-0KPVXM1EFT64", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-0KPVXM1EFT64" - }, - "payment":{ - "title":"PAY-K59ZJX9HTS0G", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-K59ZJX9HTS0G" - }, - "self":{ - "title":"ENT-AOFGIDXJR54L", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-AOFGIDXJR54L" - } - }, - "type":"CREDIT_CARD", - "ownId":"seu_identificador_proprio", - "updatedAt":"2017-08-25T00:20:16.000Z", - "id":"ENT-AOFGIDXJR54L", - "amount":{ - "fee":0, - "total":1400, - "liquid":1400, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-11T14:10:12.000Z", - "event":"PAY-K59ZJX9HTS0G", - "description":"Cartao de credito - Pedido PAY-K59ZJX9HTS0G", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-08-25T00:20:16.000Z", - "additionalId":36523463 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-08-31T14:28:50.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-XBQTYRTKWBCY", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-XBQTYRTKWBCY" - }, - "payment":{ - "title":"PAY-Z9B2ZSKZ6MEW", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-Z9B2ZSKZ6MEW" - }, - "self":{ - "title":"ENT-BCBGE6L1H7M5", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-BCBGE6L1H7M5" - } - }, - "type":"CREDIT_CARD", - "ownId":"Teste", - "updatedAt":"2017-08-17T16:58:08.000Z", - "id":"ENT-BCBGE6L1H7M5", - "amount":{ - "fee":893, - "total":15000, - "liquid":14107, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-17T11:28:51.000Z", - "event":"PAY-Z9B2ZSKZ6MEW", - "description":"Cartao de credito - Pedido PAY-Z9B2ZSKZ6MEW", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-08-17T16:58:08.000Z", - "additionalId":36527982 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-02T03:00:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-SNRXTZOCM2CI", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-SNRXTZOCM2CI" - }, - "self":{ - "title":"ENT-XHBKH8GXQ5IY", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-XHBKH8GXQ5IY" - } - }, - "type":"CREDIT_CARD", - "ownId":"null", - "updatedAt":"2017-09-02T00:20:08.000Z", - "id":"ENT-XHBKH8GXQ5IY", - "amount":{ - "fee":96, - "total":500, - "liquid":404, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-21T13:22:21.000Z", - "event":"PAY-FSCC1UB6SQH9", - "description":"Cartao de credito - Pedido ORD-SNRXTZOCM2CI", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-02T00:20:08.000Z", - "additionalId":36531393 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-02T03:00:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-TOGQOL3UL355", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-TOGQOL3UL355" - }, - "self":{ - "title":"ENT-4TBGZONW5QUQ", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-4TBGZONW5QUQ" - } - }, - "type":"CREDIT_CARD", - "ownId":"null", - "updatedAt":"2017-09-02T00:20:07.000Z", - "id":"ENT-4TBGZONW5QUQ", - "amount":{ - "fee":96, - "total":500, - "liquid":404, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-21T13:22:21.000Z", - "event":"PAY-B7BDFH7EQSN6", - "description":"Cartao de credito - Pedido ORD-TOGQOL3UL355", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-02T00:20:07.000Z", - "additionalId":36531372 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-03T00:00:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-53XZ7YAP1VDY", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-53XZ7YAP1VDY" - }, - "self":{ - "title":"ENT-Y80GKB1A4VPL", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-Y80GKB1A4VPL" - } - }, - "type":"CREDIT_CARD", - "ownId":"null", - "updatedAt":"2017-09-03T00:20:05.000Z", - "id":"ENT-Y80GKB1A4VPL", - "amount":{ - "fee":96, - "total":500, - "liquid":404, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-21T13:22:23.000Z", - "event":"PAY-LS0DT9P1HT71", - "description":"Cartao de credito - Pedido ORD-53XZ7YAP1VDY", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-03T00:20:05.000Z", - "additionalId":36531488 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-03T03:00:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-EYJIE95YXJ4J", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-EYJIE95YXJ4J" - }, - "self":{ - "title":"ENT-VUT8V6F9RKR3", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-VUT8V6F9RKR3" - } - }, - "type":"CREDIT_CARD", - "ownId":"null", - "updatedAt":"2017-09-03T00:20:06.000Z", - "id":"ENT-VUT8V6F9RKR3", - "amount":{ - "fee":96, - "total":500, - "liquid":404, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-21T13:22:23.000Z", - "event":"PAY-P5FITFFCNA96", - "description":"Cartao de credito - Pedido ORD-EYJIE95YXJ4J", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-03T00:20:06.000Z", - "additionalId":36531526 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-08T17:24:24.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-AOY2IS0G5ANL", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-AOY2IS0G5ANL" - }, - "payment":{ - "title":"PAY-QXJHUN4GUP4X", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-QXJHUN4GUP4X" - }, - "self":{ - "title":"ENT-9CZJ2LN423T0", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-9CZJ2LN423T0" - } - }, - "type":"CREDIT_CARD", - "ownId":"078e3f69c751940e1346e5ad06ca21e59e805899", - "updatedAt":"2017-09-08T00:20:42.000Z", - "id":"ENT-9CZJ2LN423T0", - "amount":{ - "fee":11689, - "total":80577, - "liquid":68888, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-25T14:24:25.000Z", - "event":"PAY-QXJHUN4GUP4X", - "description":"Cartao de credito - Pedido PAY-QXJHUN4GUP4X", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-08T00:20:42.000Z", - "additionalId":36540819 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-12T12:02:13.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-UBX2GBZG33FK", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-UBX2GBZG33FK" - }, - "payment":{ - "title":"PAY-3MS6WORMH8DI", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-3MS6WORMH8DI" - }, - "self":{ - "title":"ENT-QL45ISIGQCG1", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-QL45ISIGQCG1" - } - }, - "type":"CREDIT_CARD", - "ownId":"22c8c9295de9997f887f6d72e92775738f6cc0e2", - "updatedAt":"2017-09-12T00:20:12.000Z", - "id":"ENT-QL45ISIGQCG1", - "amount":{ - "fee":17727, - "total":114278, - "liquid":96551, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-08-29T09:02:14.000Z", - "event":"PAY-3MS6WORMH8DI", - "description":"Cartao de credito - Pedido PAY-3MS6WORMH8DI", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-12T00:20:12.000Z", - "additionalId":36543194 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-22T16:21:23.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-K9YKBLYXQ8RN", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-K9YKBLYXQ8RN" - }, - "payment":{ - "title":"PAY-JIZTK9VIZPHE", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-JIZTK9VIZPHE" - }, - "self":{ - "title":"ENT-QDFOG120NNU2", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-QDFOG120NNU2" - } - }, - "type":"CREDIT_CARD", - "ownId":"identificador_proprio", - "updatedAt":"2017-09-22T00:20:21.000Z", - "id":"ENT-QDFOG120NNU2", - "amount":{ - "fee":179, - "total":2000, - "liquid":1821, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-09-08T13:21:24.000Z", - "event":"PAY-JIZTK9VIZPHE", - "description":"Cartao de credito - Pedido PAY-JIZTK9VIZPHE", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-22T00:20:21.000Z", - "additionalId":36554486 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-22T16:23:41.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-5VIYKTMY5KEV", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-5VIYKTMY5KEV" - }, - "payment":{ - "title":"PAY-ZKVQTVMD8SJ4", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-ZKVQTVMD8SJ4" - }, - "self":{ - "title":"ENT-E50Q8XJJ275K", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-E50Q8XJJ275K" - } - }, - "type":"CREDIT_CARD", - "ownId":"identificador_proprio2", - "updatedAt":"2017-09-22T00:20:21.000Z", - "id":"ENT-E50Q8XJJ275K", - "amount":{ - "fee":179, - "total":2000, - "liquid":1821, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-09-08T13:23:42.000Z", - "event":"PAY-ZKVQTVMD8SJ4", - "description":"Cartao de credito - Pedido PAY-ZKVQTVMD8SJ4", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-22T00:20:21.000Z", - "additionalId":36554489 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-28T19:26:17.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-PBTN7AI02SFF", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-PBTN7AI02SFF" - }, - "payment":{ - "title":"PAY-1RPZO7YWZROC", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-1RPZO7YWZROC" - }, - "self":{ - "title":"ENT-RU6GRG5OHBXQ", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-RU6GRG5OHBXQ" - } - }, - "type":"CREDIT_CARD", - "ownId":"2268", - "updatedAt":"2017-09-28T00:20:24.000Z", - "id":"ENT-RU6GRG5OHBXQ", - "amount":{ - "fee":453, - "total":7000, - "liquid":6547, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-09-14T16:26:17.000Z", - "event":"PAY-1RPZO7YWZROC", - "description":"Cartao de credito - Pedido PAY-1RPZO7YWZROC", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-28T00:20:24.000Z", - "additionalId":36559382 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-09-29T16:24:40.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-B8MOAUFKN7PJ", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-B8MOAUFKN7PJ" - }, - "payment":{ - "title":"PAY-5E330RWMYRW0", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-5E330RWMYRW0" - }, - "self":{ - "title":"ENT-9QQ7M3YVFHU2", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-9QQ7M3YVFHU2" - } - }, - "type":"CREDIT_CARD", - "ownId":"seu_identificador_propriosss", - "updatedAt":"2017-09-29T00:20:17.000Z", - "id":"ENT-9QQ7M3YVFHU2", - "amount":{ - "fee":179, - "total":2000, - "liquid":1821, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-09-15T13:24:41.000Z", - "event":"PAY-5E330RWMYRW0", - "description":"Cartao de credito - Pedido PAY-5E330RWMYRW0", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-09-29T00:20:17.000Z", - "additionalId":36560079 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-10-24T08:43:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-7N0DTC9WDTM6", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-7N0DTC9WDTM6" - }, - "payment":{ - "title":"PAY-2A82U10PCWCY", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-2A82U10PCWCY" - }, - "self":{ - "title":"ENT-XYVK45APLP4X", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-XYVK45APLP4X" - } - }, - "type":"COMMISSION", - "ownId":"", - "updatedAt":"2017-10-24T00:20:04.000Z", - "id":"ENT-XYVK45APLP4X", - "amount":{ - "fee":0, - "total":55, - "liquid":55, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-10-10T08:43:01.000Z", - "event":"PAY-2A82U10PCWCY", - "description":"Recebedor secundario - Pedido PAY-2A82U10PCWCY", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-10-24T00:20:04.000Z", - "additionalId":36587721 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-10-24T08:43:00.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-4GHL70Y4P2HQ", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-4GHL70Y4P2HQ" - }, - "payment":{ - "title":"PAY-2QFHVUE7DLOY", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-2QFHVUE7DLOY" - }, - "self":{ - "title":"ENT-2CMLE4TLSNB0", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-2CMLE4TLSNB0" - } - }, - "type":"COMMISSION", - "ownId":"", - "updatedAt":"2017-10-24T00:20:04.000Z", - "id":"ENT-2CMLE4TLSNB0", - "amount":{ - "fee":0, - "total":55, - "liquid":55, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-10-10T08:43:01.000Z", - "event":"PAY-2QFHVUE7DLOY", - "description":"Recebedor secundario - Pedido PAY-2QFHVUE7DLOY", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-10-24T00:20:04.000Z", - "additionalId":36587723 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-10-25T08:38:27.000Z", - "status":"SETTLED", - "_links":{ - "order":{ - "title":"ORD-B3ZR1HULRQT5", - "href":"https://sandbox.moip.com.br/v2/orders/ORD-B3ZR1HULRQT5" - }, - "payment":{ - "title":"PAY-3FDV42D6N5AD", - "href":"https://sandbox.moip.com.br/v2/payments/PAY-3FDV42D6N5AD" - }, - "self":{ - "title":"ENT-UQXVJ9P0HIJ4", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-UQXVJ9P0HIJ4" - } - }, - "type":"CREDIT_CARD", - "ownId":"testeCheckout", - "updatedAt":"2017-10-25T00:20:07.000Z", - "id":"ENT-UQXVJ9P0HIJ4", - "amount":{ - "fee":179, - "total":2000, - "liquid":1821, - "currency":"BRL" - }, - "operation":"CREDIT", - "createdAt":"2017-10-11T08:38:27.000Z", - "event":"PAY-3FDV42D6N5AD", - "description":"Cartao de credito - Pedido PAY-3FDV42D6N5AD", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-10-25T00:20:07.000Z", - "additionalId":36590609 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-10-26T09:17:25.000Z", - "status":"SETTLED", - "_links":{ - "self":{ - "title":"ENT-3COM135CBUIW", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-3COM135CBUIW" - } - }, - "type":"TRANSFER_TO_BANK_ACCOUNT", - "ownId":"", - "updatedAt":"2017-10-26T09:17:26.000Z", - "id":"ENT-3COM135CBUIW", - "amount":{ - "fee":0, - "total":-500, - "liquid":-500, - "currency":"BRL" - }, - "operation":"DEBIT", - "createdAt":"2017-10-26T09:17:25.000Z", - "event":"TRA-Q3FAM5S6JPG7", - "description":"Transferencia para conta bancaria - TRA-Q3FAM5S6JPG7", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-10-26T09:17:26.000Z", - "additionalId":36605837 - }, - { - "reschedule":[ - - ], - "scheduledFor":"2017-10-26T09:18:24.000Z", - "status":"SETTLED", - "_links":{ - "self":{ - "title":"ENT-X0JNERLAZ7BP", - "href":"https://sandbox.moip.com.br/v2/entries/ENT-X0JNERLAZ7BP" - } - }, - "type":"TRANSFER_TO_BANK_ACCOUNT", - "ownId":"", - "updatedAt":"2017-10-26T09:18:24.000Z", - "id":"ENT-X0JNERLAZ7BP", - "amount":{ - "fee":0, - "total":-500, - "liquid":-500, - "currency":"BRL" - }, - "operation":"DEBIT", - "createdAt":"2017-10-26T09:18:24.000Z", - "event":"TRA-CCGUEVQ8HTFW", - "description":"Transferencia para conta bancaria - TRA-CCGUEVQ8HTFW", - "occurrence":{ - "to":1, - "in":1 - }, - "blocked":false, - "settledAt":"2017-10-26T09:18:24.000Z", - "additionalId":36605842 - } - ] - } \ No newline at end of file diff --git a/tests/jsons/escrow/release.json b/tests/jsons/escrow/release.json old mode 100755 new mode 100644 diff --git a/tests/jsons/keys/get.json b/tests/jsons/keys/get.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multiorder/create.json b/tests/jsons/multiorder/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multipayment/cancel_pre_authorized.json b/tests/jsons/multipayment/cancel_pre_authorized.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multipayment/capture.json b/tests/jsons/multipayment/capture.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multipayment/create_billet.json b/tests/jsons/multipayment/create_billet.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multipayment/create_cc.json b/tests/jsons/multipayment/create_cc.json old mode 100755 new mode 100644 diff --git a/tests/jsons/multipayment/get.json b/tests/jsons/multipayment/get.json old mode 100755 new mode 100644 diff --git a/tests/jsons/notification/create.json b/tests/jsons/notification/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/notification/list.json b/tests/jsons/notification/list.json old mode 100755 new mode 100644 diff --git a/tests/jsons/order/create.json b/tests/jsons/order/create.json old mode 100755 new mode 100644 diff --git a/tests/jsons/order/get_list.json b/tests/jsons/order/get_list.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/cancel_pre_authorized.json b/tests/jsons/payment/cancel_pre_authorized.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/capture.json b/tests/jsons/payment/capture.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/create_billet.json b/tests/jsons/payment/create_billet.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/create_cc_delay_capture.json b/tests/jsons/payment/create_cc_delay_capture.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/create_cc_pci.json b/tests/jsons/payment/create_cc_pci.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/create_cc_pci_escrow.json b/tests/jsons/payment/create_cc_pci_escrow.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/create_cc_pci_store.json b/tests/jsons/payment/create_cc_pci_store.json old mode 100755 new mode 100644 diff --git a/tests/jsons/payment/get.json b/tests/jsons/payment/get.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/order_full_bankaccount.json b/tests/jsons/refund/order_full_bankaccount.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/order_full_cc.json b/tests/jsons/refund/order_full_cc.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/order_partial_bankaccount.json b/tests/jsons/refund/order_partial_bankaccount.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/order_partial_cc.json b/tests/jsons/refund/order_partial_cc.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/payment_full_bankaccount.json b/tests/jsons/refund/payment_full_bankaccount.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/payment_full_cc.json b/tests/jsons/refund/payment_full_cc.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/payment_partial_bankaccount.json b/tests/jsons/refund/payment_partial_bankaccount.json old mode 100755 new mode 100644 diff --git a/tests/jsons/refund/payment_partial_cc.json b/tests/jsons/refund/payment_partial_cc.json old mode 100755 new mode 100644 diff --git a/tests/jsons/transfers/create_bankaccount.json b/tests/jsons/transfers/create.json old mode 100755 new mode 100644 similarity index 100% rename from tests/jsons/transfers/create_bankaccount.json rename to tests/jsons/transfers/create.json diff --git a/tests/jsons/transfers/create_moipaccount.json b/tests/jsons/transfers/create_moipaccount.json deleted file mode 100644 index d921ebf..0000000 --- a/tests/jsons/transfers/create_moipaccount.json +++ /dev/null @@ -1,70 +0,0 @@ -{ - "fee": 0, - "amount": 500, - "updatedAt": "2018-05-18T12:36:28.111Z", - "id": "TRA-H4NPGQGSNWRA", - "transferInstrument": { - "moipAccount": { - "id": "MPA-5E1C4C369E8C", - "email": "meu.cliente3@mailinator.com", - "login": "meu.cliente3@mailinator.com", - "fullname": "Meu Cliente 3" - }, - "senderAccountId": "MPA-5D5053C0B4A4", - "method": "MOIP_ACCOUNT" - }, - "status": "COMPLETED", - "events": [ - { - "createdAt": "2018-05-18T12:36:28.000Z", - "description": "Requested", - "type": "TRANSFER.REQUESTED" - }, - { - "createdAt": "2018-05-18T12:36:28.000Z", - "description": "Completed", - "type": "TRANSFER.COMPLETED" - } - ], - "description": "Descrição da transferência", - "createdAt": "2018-05-18T12:36:28.111Z", - "entries": [ - { - "external_id": "ENT-GQ9QH84IM7PI", - "reschedule": [], - "scheduledFor": "2018-05-18T12:36:28.000Z", - "status": "SETTLED", - "moipAccount": { - "account": "MPA-5D5053C0B4A4" - }, - "fees": [], - "type": "TRANSFER_TO_MOIP_ACCOUNT_PAID", - "grossAmount": -500, - "moipAccountId": 260863, - "updatedAt": "2018-05-18T12:36:28.378Z", - "id": 36792359, - "installment": { - "amount": 1, - "number": 1 - }, - "references": [ - { - "value": "APP-QGAGZRIX1CUF", - "type": "CHANNEL" - } - ], - "eventId": "TRA-H4NPGQGSNWRA", - "createdAt": "2018-05-18T12:36:28.331Z", - "description": "Transferencia entre contas Moip realizada - TRA-H4NPGQGSNWRA", - "blocked": false, - "settledAt": "2018-05-18T12:36:28.378Z", - "liquidAmount": -500 - } - ], - "role": "PAYER", - "_links": { - "self": { - "href": "https://sandbox.moip.com.br/v2/transfers/TRA-H4NPGQGSNWRA" - } - } -} \ No newline at end of file diff --git a/tests/jsons/transfers/list.json b/tests/jsons/transfers/list.json old mode 100755 new mode 100644 diff --git a/tests/jsons/transfers/revert.json b/tests/jsons/transfers/revert.json old mode 100755 new mode 100644 diff --git a/tests/jsons/webhooks/get_all_filters.json b/tests/jsons/webhooks/get_all_filters.json old mode 100755 new mode 100644 diff --git a/tests/jsons/webhooks/get_no_filter.json b/tests/jsons/webhooks/get_no_filter.json old mode 100755 new mode 100644 diff --git a/tests/jsons/webhooks/get_pagination.json b/tests/jsons/webhooks/get_pagination.json old mode 100755 new mode 100644 From 3c09b4699e45f4687e8900c106129ceb17cf298f Mon Sep 17 00:00:00 2001 From: Mario Dias Date: Fri, 4 Jun 2021 15:43:35 -0300 Subject: [PATCH 3/4] feat(Payment): adds a method to receive and return the customer device data --- src/Resource/Payment.php | 64 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/src/Resource/Payment.php b/src/Resource/Payment.php index 89f99df..8bfabd8 100644 --- a/src/Resource/Payment.php +++ b/src/Resource/Payment.php @@ -123,6 +123,7 @@ protected function initialize() $this->data = new stdClass(); $this->data->installmentCount = 1; $this->data->fundingInstrument = new stdClass(); + $this->data->device = new stdClass(); } /** @@ -189,6 +190,7 @@ protected function populate(stdClass $response) $payment->data->amount->currency = $this->getIfSet('currency', $response->amount); $payment->data->installmentCount = $this->getIfSet('installmentCount', $response); $payment->data->fundingInstrument = $this->getIfSet('fundingInstrument', $response); + $payment->data->device = $this->getIfSet('device', $response); $payment->data->payments = $this->getIfSet('payments', $response); $payment->data->escrows = $this->getIfSet('escrows', $response); $payment->data->fees = $this->getIfSet('fees', $response); @@ -267,6 +269,16 @@ public function getFundingInstrument() return $this->data->fundingInstrument; } + /** + * Returns the device fingerprint data. + * + * @return stdClass + */ + public function getDeviceFingerprint() + { + return $this->data->device; + } + /** * Get href to Boleto * *. @@ -321,6 +333,16 @@ public function getAmount() return $this->data->amount; } + /** + * Returns delay capture. + * + * @return stdClass + */ + public function getDelayCapture() + { + return $this->data->delayCapture; + } + /** * Returns escrow. * @@ -375,6 +397,20 @@ public function setFundingInstrument(stdClass $fundingInstrument) return $this; } + /** + * Set payment device. + * + * @param \stdClass $device + * + * @return $this + */ + public function setDevice(stdClass $device) + { + $this->data->device = $device; + + return $this; + } + /** * Set billet. * @@ -527,6 +563,30 @@ public function setStatementDescriptor($statementDescriptor) return $this; } + /** + * Set device fingerprint + * Customer device data used in the payment. + * + * @param string $ip Customer IP address + * @param float $latitude Customer latitude. + * @param float $longitude Customer longitude. + * @param string $userAgent Device userAgent. + * @param string $fingerprint Device fingerprint. + * + * @return $this + */ + public function setDeviceFingerprint($ip, $latitude, $longitude, $userAgent, $fingerprint) + { + $this->data->device->geolocation = new stdClass(); + $this->data->device->geolocation->latitude = $latitude; + $this->data->device->geolocation->longitude = $longitude; + $this->data->device->ip = $ip; + $this->data->device->userAgent = $userAgent; + $this->data->device->fingerprint = $fingerprint; + + return $this; + } + /** * Set payment means made available by banks. * @@ -583,9 +643,9 @@ public function setOrder(Orders $order) * * @return $this */ - public function setDelayCapture() + public function setDelayCapture($delayCapture = true) { - $this->data->delayCapture = true; + $this->data->delayCapture = $delayCapture; return $this; } From 1052631375f2f6c8993ee44b37b2426ce5742194 Mon Sep 17 00:00:00 2001 From: Mila Date: Thu, 25 Nov 2021 09:19:41 -0300 Subject: [PATCH 4/4] update rmccue/requests version to be compatible with Moip\Auth\BasicAuth::register --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index afd74a5..64fda72 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ ], "require": { "php": ">=5.5", - "rmccue/requests": ">=1.0" + "rmccue/requests": ">=1.8.0" }, "require-dev": { "phpunit/phpunit": "~4.8.35 || ^5.7 || ^6.4",