Skip to content

Commit 9c7fa16

Browse files
Merge pull request #74 from pagarme/develop
## 🐛 Bug fixes - Fix allowing checkout when shipping is empty - Fix editing customer through admin ## 🚀 Improvements - Update Mundi Api to Pagar.me Api
2 parents b971ef7 + be47860 commit 9c7fa16

33 files changed

+78
-76
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ composer update pagarme/ecommerce-module-core
3030

3131
## API Reference
3232

33-
[http://docs.mundipagg.com](http://docs.mundipagg.com)
33+
[https://docs.pagar.me](https://docs.pagar.me)
3434

3535
## Contributting
3636
Please, refer to [CONTRIBUTING](.github/CONTRIBUTING.md)

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "pagarme/ecommerce-module-core",
33
"description": "Core component for Pagar.me e-commerce platform modules.",
44
"license": "MIT",
5-
"version": "1.1.5",
5+
"version": "1.2.0",
66
"authors": [
77
{
88
"name":"Open Source Team"
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": ">=7.1",
1414
"monolog/monolog": "*",
15-
"mundipagg/mundiapi": "^3.0",
15+
"pagarme/pagarmecoreapi": "^5.7",
1616
"ext-json": "*"
1717
},
1818
"require-dev": {

src/Kernel/Abstractions/AbstractModuleCoreSetup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use Pagarme\Core\Kernel\Aggregates\Configuration;
66
use Pagarme\Core\Kernel\Repositories\ConfigurationRepository;
7-
use MundiAPILib\Configuration as MundiAPIConfiguration;
7+
use PagarmeCoreApiLib\Configuration as PagarmeCoreAPIConfiguration;
88
use ReflectionClass;
99

1010
abstract class AbstractModuleCoreSetup
@@ -81,7 +81,7 @@ public static function bootstrap($platformRoot = null)
8181
protected static function setApiBaseUrl()
8282
{
8383
if (static::$moduleConfig->isHubEnabled()) {
84-
MundiAPIConfiguration::$BASEURI = 'https://hubapi.mundipagg.com/core/v1';
84+
PagarmeCoreAPIConfiguration::$BASEURI = 'https://hubapi.mundipagg.com/core/v1';
8585
}
8686
}
8787

src/Kernel/Services/APIService.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
namespace Pagarme\Core\Kernel\Services;
44

55
use Exception;
6-
use MundiAPILib\APIException;
7-
use MundiAPILib\Configuration;
8-
use MundiAPILib\Controllers\ChargesController;
9-
use MundiAPILib\Controllers\CustomersController;
10-
use MundiAPILib\Controllers\OrdersController;
11-
use MundiAPILib\Exceptions\ErrorException;
12-
use MundiAPILib\Models\CreateCancelChargeRequest;
13-
use MundiAPILib\Models\CreateCaptureChargeRequest;
14-
use MundiAPILib\Models\CreateOrderRequest;
15-
use MundiAPILib\MundiAPIClient;
6+
use PagarmeCoreApiLib\APIException;
7+
use PagarmeCoreApiLib\Configuration;
8+
use PagarmeCoreApiLib\Controllers\ChargesController;
9+
use PagarmeCoreApiLib\Controllers\CustomersController;
10+
use PagarmeCoreApiLib\Controllers\OrdersController;
11+
use PagarmeCoreApiLib\Exceptions\ErrorException;
12+
use PagarmeCoreApiLib\Models\CreateCancelChargeRequest;
13+
use PagarmeCoreApiLib\Models\CreateCaptureChargeRequest;
14+
use PagarmeCoreApiLib\Models\CreateOrderRequest;
15+
use PagarmeCoreApiLib\PagarmeCoreApiClient;
1616
use Pagarme\Core\Kernel\Abstractions\AbstractEntity;
1717
use Pagarme\Core\Kernel\Abstractions\AbstractModuleCoreSetup as MPSetup;
1818
use Pagarme\Core\Kernel\Aggregates\Charge;
@@ -32,7 +32,7 @@
3232
class APIService
3333
{
3434
/**
35-
* @var MundiAPIClient
35+
* @var PagarmeCoreApiClient
3636
*/
3737
private $apiClient;
3838

@@ -53,7 +53,7 @@ class APIService
5353

5454
public function __construct()
5555
{
56-
$this->apiClient = $this->getMundiPaggApiClient();
56+
$this->apiClient = $this->getPagarmeCoreApiClient();
5757
$this->logService = new OrderLogService(2);
5858
$this->configInfoService = new ConfigInfoRetrieverService();
5959
$this->orderCreationService = new OrderCreationService($this->apiClient);
@@ -221,7 +221,7 @@ private function getCustomerController()
221221
return $this->apiClient->getCustomers();
222222
}
223223

224-
private function getMundiPaggApiClient()
224+
private function getPagarmeCoreApiClient()
225225
{
226226
$i18n = new LocalizationService();
227227
$config = MPSetup::getModuleConfiguration();
@@ -243,7 +243,7 @@ private function getMundiPaggApiClient()
243243

244244
Configuration::$basicAuthPassword = '';
245245

246-
return new MundiAPIClient($secretKey, $password);
246+
return new PagarmeCoreApiClient($secretKey, $password);
247247
}
248248

249249
private function getAPIBaseEndpoint()

src/Kernel/Services/ChargeService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pagarme\Core\Kernel\Services;
44

5-
use MundiAPILib\Models\GetChargeResponse;
5+
use PagarmeCoreApiLib\Models\GetChargeResponse;
66
use Pagarme\Core\Kernel\Aggregates\Charge;
77
use Pagarme\Core\Kernel\Exceptions\InvalidParamException;
88
use Pagarme\Core\Kernel\Interfaces\ChargeInterface;

src/Kernel/Services/OrderCreationService.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
namespace Pagarme\Core\Kernel\Services;
44

55
use Exception;
6-
use MundiAPILib\Models\CreateOrderRequest;
7-
use MundiAPILib\MundiAPIClient;
6+
use PagarmeCoreApiLib\Models\CreateOrderRequest;
7+
use PagarmeCoreApiLib\PagarmeCoreApiClient;
88

99
class OrderCreationService
1010
{
1111
/**
12-
* @var MundiAPIClient
12+
* @var PagarmeCoreApiClient
1313
*/
14-
private $mundiAPIClient;
14+
private $pagarmeCoreAPIClient;
1515

1616
/**
1717
* @var OrderLogService
@@ -23,9 +23,9 @@ class OrderCreationService
2323
*/
2424
private $generalAttempt = 1;
2525

26-
public function __construct(MundiAPIClient $mundiAPIClient)
26+
public function __construct(PagarmeCoreApiClient $pagarmeCoreAPIClient)
2727
{
28-
$this->mundiAPIClient = $mundiAPIClient;
28+
$this->pagarmeCoreAPIClient = $pagarmeCoreAPIClient;
2929
$this->logService = new OrderLogService(2);
3030
}
3131

@@ -45,7 +45,7 @@ public function createOrder(
4545
$response = null;
4646
$messageLog = "";
4747

48-
$orderController = $this->mundiAPIClient->getOrders();
48+
$orderController = $this->pagarmeCoreAPIClient->getOrders();
4949

5050
try {
5151
$response = $orderController->createOrder($orderRequest, $idempotencyKey);

src/Kernel/Services/OrderService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ public function extractPaymentOrderFromPlatformOrder(
394394
$order->setCode($platformOrder->getCode());
395395

396396
$shipping = $platformOrder->getShipping();
397-
if ($shipping !== null) {
397+
if (!$shipping && $shipping !== null) {
398398
$order->setShipping($shipping);
399399
}
400400

src/Payment/Aggregates/Address.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pagarme\Core\Payment\Aggregates;
44

5-
use MundiAPILib\Models\CreateAddressRequest;
5+
use PagarmeCoreApiLib\Models\CreateAddressRequest;
66
use Pagarme\Core\Kernel\Abstractions\AbstractEntity;
77
use Pagarme\Core\Kernel\Helper\StringFunctionsHelper;
88
use Pagarme\Core\Kernel\Services\LocalizationService;

src/Payment/Aggregates/Customer.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pagarme\Core\Payment\Aggregates;
44

5-
use MundiAPILib\Models\CreateCustomerRequest;
5+
use PagarmeCoreApiLib\Models\CreateCustomerRequest;
66
use Pagarme\Core\Kernel\Abstractions\AbstractEntity;
77
use Pagarme\Core\Kernel\Services\LocalizationService;
88
use Pagarme\Core\Payment\Interfaces\ConvertibleToSDKRequestsInterface;
@@ -124,8 +124,7 @@ public function setDocument($document)
124124
{
125125
$this->document = $this->formatDocument($document);
126126

127-
if (empty($this->document)) {
128-
127+
if (empty($this->document) && empty($this->getPagarmeId())) {
129128
$inputName = $this->i18n->getDashboard('document');
130129
$message = $this->i18n->getDashboard(
131130
"The %s should not be empty!",
@@ -228,8 +227,11 @@ public function convertToSDKRequest()
228227
$customerRequest->code = $this->getCode();
229228
$customerRequest->name = $this->getName();
230229
$customerRequest->email = $this->getEmail();
231-
$customerRequest->document = $this->getDocument();
232-
$customerRequest->type = $this->getTypeValue();
230+
if ($this->getDocument()) {
231+
$customerRequest->document = $this->getDocument();
232+
$customerRequest->type = $this->getTypeValue();
233+
}
234+
233235
$customerRequest->address = $this->getAddressToSDK();
234236
$customerRequest->phones = $this->getPhonesToSDK();
235237

src/Payment/Aggregates/Item.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Pagarme\Core\Payment\Aggregates;
44

5-
use MundiAPILib\Models\CreateOrderItemRequest;
5+
use PagarmeCoreApiLib\Models\CreateOrderItemRequest;
66
use Pagarme\Core\Kernel\Abstractions\AbstractEntity;
77
use Pagarme\Core\Kernel\Exceptions\InvalidParamException;
88
use Pagarme\Core\Payment\Interfaces\ConvertibleToSDKRequestsInterface;

0 commit comments

Comments
 (0)