Skip to content

Commit

Permalink
Release v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mercado Pago committed Feb 3, 2025
1 parent 78fe7a0 commit 64a8129
Show file tree
Hide file tree
Showing 59 changed files with 244 additions and 81 deletions.
3 changes: 2 additions & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ PUBLIC_KEY=<Put your public_key test>
PUBLIC_KEY_3DS=<Put your public_key test>
NOTIFICATION_URL=<Put your notification_url>
APPLICATION_ID=<Put your application_id>
PRODUCT_ID=<Put a valid product_id>
PRODUCT_ID=<Put a valid product_id>
URIS_SCOPE=<Put beta if you want to test on beta URI scopes>
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## V3.0.0
### Added
- Add new parameter `uris_scope` on SDK instantiation to allow use of beta scopes on APIs calls

## V2.13.0
### Added
- Add new method to get onboarding data for the new credential autofill flow
Expand Down
31 changes: 17 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,19 @@ Para incluir a biblioteca em seu projeto, basta fazer o seguinte:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

```

Os parâmetros para instanciar a SDK são: Access Token, Platform ID, Product ID, Integrator ID, Public Key e URIs Scope que deve ser preenchido com `beta` caso queira que as URIs das APIs acessadas estejam em Beta.

## Criando um pagamento

```php
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$payment = $sdk->getPaymentInstance();

Expand All @@ -57,7 +59,7 @@ Para incluir a biblioteca em seu projeto, basta fazer o seguinte:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$payment = $sdk->getPaymentInstance();

Expand All @@ -70,7 +72,7 @@ Para incluir a biblioteca em seu projeto, basta fazer o seguinte:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$preference = $sdk->getPreferenceInstance();

Expand Down Expand Up @@ -104,7 +106,7 @@ O parâmetro para consulta deve seguir o modelo abaixo:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$notification = $sdk->getNotificationInstance();

Expand All @@ -118,7 +120,7 @@ O parâmetro para consulta deve seguir o modelo abaixo:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$datadogEvent = $sdk->getDatadogEventInstance();

Expand All @@ -145,7 +147,7 @@ O parâmetro para consulta deve seguir o modelo abaixo:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$registerErrorLog = $sdk->getRegisterErrorLogInstance();

Expand Down Expand Up @@ -175,7 +177,7 @@ O parâmetro para consulta deve seguir o modelo abaixo:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$paymentMethods = $sdk->getPaymentMethodsInstance();

Expand All @@ -191,7 +193,7 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$paymentMethods = $sdk->getPaymentMethodsInstance();

Expand All @@ -213,7 +215,7 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$merchantOrder = $sdk->getMerchantOrderInstance();

Expand All @@ -236,7 +238,7 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$createSellerFunnelBase = $sdk->getCreateSellerFunnelBaseInstance();

Expand Down Expand Up @@ -268,7 +270,7 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$updateSellerFunnelBase = $sdk->getUpdateSellerFunnelBaseInstance();

Expand All @@ -293,7 +295,7 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
<?php
require('vendor/autoload.php');

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$exchange = $sdk->getExchangeInstance();

Expand All @@ -309,7 +311,8 @@ Exemplo de requisição agrupando os meios de pagamento pelo campo id:
'platformId',
'productId',
'integratorId',
'publicKey'
'publicKey',
'urisScope'
);

$onboarding = $sdk->getOnboardingInstance();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mp-plugins/php-sdk",
"description": "Mercado Pago Plugins PHP-SDK",
"version": "2.13.0",
"version": "3.0.0",
"type": "library",
"scripts": {
"lint": "./vendor/bin/phpcs -q --report=checkstyle --standard=PSR2 src",
Expand Down
6 changes: 3 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function debug($value)
echo "</pre>";
}

$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey');
$sdk = new Sdk('accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope');

$exchange = $sdk->getExchangeInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/Multipayment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

//Payment with two Cards
$multipayment = $sdk->getMultipaymentInstance();
Expand Down
2 changes: 1 addition & 1 deletion examples/createSellerFunnelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$createSellerFunnelBase = $sdk->getCreateSellerFunnelBaseInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/datadog_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$datadogEvent = $sdk->getDatadogEventInstance();

Expand Down
3 changes: 2 additions & 1 deletion examples/getOnboardingData.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ function debug($value){
'platformId',
'productId',
'integratorId',
'publicKey'
'publicKey',
'urisScope'
);

$onboarding = $sdk->getOnboardingInstance();
Expand Down
2 changes: 1 addition & 1 deletion examples/groupedPaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$paymentMethods = $sdk->getPaymentMethodsInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/merchantOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$merchantOrder = $sdk->getMerchantOrderInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/monitoring_register_log.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function debug($value)
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$registerErrorLog = $sdk->getRegisterErrorLogInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$notification = $sdk->getNotificationInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$payment = $sdk->getPaymentInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/paymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$paymentMethods = $sdk->getPaymentMethodsInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/payment_3ds.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$payment = $sdk->getPaymentInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/preference.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$preference = $sdk->getPreferenceInstance();

Expand Down
2 changes: 1 addition & 1 deletion examples/updateSellerFunnelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function debug($value){
echo "</pre>";
}

$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey' );
$sdk = new Sdk( 'accessToken', 'platformId', 'productId', 'integratorId', 'publicKey', 'urisScope' );

$updateSellerFunnelBase = $sdk->getUpdateSellerFunnelBaseInstance();

Expand Down
12 changes: 10 additions & 2 deletions src/Common/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@ class Config
*/
private $integrator_id;

/**
/**
* @var string
*/
private $public_key;

/**
* @var string
*/
private $uris_scope;

/**
* Config constructor.
*
Expand All @@ -42,19 +47,22 @@ class Config
* @param string|null $product_id
* @param string|null $integrator_id
* @param string|null $public_key
* @param string|null $uris_scope
*/
public function __construct(
string $access_token = null,
string $platform_id = null,
string $product_id = null,
string $integrator_id = null,
string $public_key = null
string $public_key = null,
string $uris_scope = null
) {
$this->access_token = $access_token;
$this->platform_id = $platform_id;
$this->product_id = $product_id;
$this->integrator_id = $integrator_id;
$this->public_key = $public_key;
$this->uris_scope = $uris_scope;
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/Common/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public function execute(AbstractEntity $entity, string $uri, string $method = 'g
public function getEntityUri(AbstractEntity $entity, string $method, array $params = [], array $queryStrings = [])
{
if (method_exists($entity, 'getUris')) {
$uri = $entity->getUris()[$method];
$uris_scope = $this->config->__get('uris_scope');
$uri = $entity->getUris($uris_scope)[$method];
$matches = [];
preg_match_all('/\\:\\w+/', $uri, $matches);

Expand Down
6 changes: 4 additions & 2 deletions src/Entity/Exchange/Exchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ public function getHeaders(): array
*
* @return array
*/
public function getUris(): array
public function getUris(string $uris_scope = null): array
{
$scope_ppcore = $uris_scope === 'beta' ? 'beta' : 'prod';

return array(
'get' => '/ppcore/prod/payment-methods/v1/exchange',
'get' => '/ppcore/' . $scope_ppcore . '/payment-methods/v1/exchange',
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/Entity/Identification/CreateSellerFunnelBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,12 @@ public function __construct($manager)
*
* @return array
*/
public function getUris(): array
public function getUris(string $uris_scope = null): array
{
$scope_ppcore = $uris_scope === 'beta' ? 'beta' : 'v1';

return array(
'post' => '/v1/eplatforms/core/identification/seller-configuration/start-integration',
'post' => '/' . $scope_ppcore . '/eplatforms/core/identification/seller-configuration/start-integration',
);
}

Expand Down
Loading

0 comments on commit 64a8129

Please sign in to comment.