Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping Payments #532

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

require 'vendor/autoload.php';

use MercadoPago\Client\Payment\PaymentClient;
use MercadoPago\Client\Common\RequestOptions;
use MercadoPago\MercadoPagoConfig;

MercadoPagoConfig::setAccessToken("TEST-8934915144594052-072012-1f7d378cec605ce3b38da7510838bd3f-692582067");
$client = new PaymentClient();

$request_options = new RequestOptions();
$request = [
"transaction_amount" => (float) '100',
"description" => 'teste',
"payment_method_id" => 'bolbradesco',
"payer" => [
"first_name" => "uhsausha",
"last_name" => "yhduajisf",
"email" => '[email protected]',
"identification" => [
"type" => "CPF",
"number" => 19119119100
],
"address" => [
"zip_code" => "83471648",
"street_name" => "endereco",
"street_number" => "456",
"neighborhood" => "bairro",
"city" => "Floripa",
"federal_unit" => "SC"
]]
];

try {
$payment = $client->create($request, $request_options);
var_dump($payment);

} catch (MPApiException $e) {
var_dump($e);
} catch (\Exception $e) {
// Handle all other exceptions
var_dump($e);
}
// echo "Content: ";
// var_dump($e->getApiResponse()->getContent());
// echo "\n";
// } catch (\Exception $e) {
// // Handle all other exceptions
// echo $e->getMessage();
// }
16 changes: 16 additions & 0 deletions src/MercadoPago/Resources/Common/BusinessInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace MercadoPago\Resources\Common;

/** BussinessInfo class. */
class BussinessInfo
{
/** For example: Merchant Services */
public ?string $branch;

/** Foe example: online_payments*/
public ?string $unit;

/** for exemple: default */
public ?string $sub_unit;
}
12 changes: 12 additions & 0 deletions src/MercadoPago/Resources/Common/Location.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace MercadoPago\Resources\Common;

/** Location class. */
class Location
{
public ?string $state_id;


public ?string $source;
}
13 changes: 13 additions & 0 deletions src/MercadoPago/Resources/Common/Passenger.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace MercadoPago\Resources\Common;

/** Passenger class. */
class Passenger
{
/** Passenger's first name. */
public ?string $first_name;

/** Passenger's last name. */
public ?string $last_name;
}
22 changes: 22 additions & 0 deletions src/MercadoPago/Resources/Common/Route.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace MercadoPago\Resources\Common;

/** Route class. */
class Route
{
/** Departure city. */
public ?string $departure;

/** Destination city. */
public ?string $destination;

/** Departure date and time. The valid format is as follows - "yyyy-MM-ddTHH:mm:ss.sssZ". Example - 2023-12-31T09:37:52.000-04:00.*/
public ?string $departure_date_time;

/** Arrival date and time. The valid format is as follows - "yyyy-MM-ddTHH:mm:ss.sssZ". Example - 2023-12-31T09:37:52.000-04:00.*/
public ?string $arrival_date_time;

/** Company name. */
public ?string $company;
}
91 changes: 51 additions & 40 deletions src/MercadoPago/Resources/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,48 @@ class Payment extends MPResource
/** Payment ID. */
public ?int $id;

/** Status. */
public ?string $status;

/** Status detail. */
public ?string $status_detail;

/** Payment type ID. */
public ?string $payment_type_id;

/** Date created. */
public ?string $date_created;

/** Approval date. */
public ?string $date_approved;

/** Last modified date. */
public ?string $date_last_updated;

/** Currency ID. */
public ?string $currency_id;

/** Description. */
public ?string $description;

/** Collector ID. */
public ?int $collector_id;

/** Payer. */
public array|object|null $payer;

/** Transaction amount. */
public ?float $transaction_amount;

/** Transaction details. */
public array|object|null $transaction_details;

/** Installments. */
public ?int $installments;

/** Acquirer. */
public ?array $acquirer;

/** Acquirer reconciliation. */
public ?array $acquirer_reconciliation;

Expand All @@ -30,7 +72,7 @@ class Payment extends MPResource
public ?int $order_id;

/** Order. */
public ?array $order;
public array|object|null $order;

/** Brand ID. */
public ?string $brand_id;
Expand All @@ -47,36 +89,21 @@ class Payment extends MPResource
/** Financing group. */
public ?string $financing_group;

/** Status. */
public ?string $status;

/** Status detail. */
public ?string $status_detail;

/** Store ID. */
public ?string $store_id;

/** Taxes amount. */
public ?int $taxes_amount;

/** Date created. */
public ?string $date_created;

/** Live Mode. */
public ?bool $live_mode;

/** Last modified date. */
public ?string $date_last_updated;

/** Date of expiration. */
public ?string $date_of_expiration;

/** Deduction schema. */
public ?string $deduction_schema;

/** Approval date. */
public ?string $date_approved;

/** Money release date. */
public ?string $money_release_date;

Expand All @@ -86,24 +113,12 @@ class Payment extends MPResource
/** Money release status. */
public ?string $money_release_status;

/** Currency ID. */
public ?string $currency_id;

/** Transaction amount. */
public ?float $transaction_amount;

/** Transaction amount refunded. */
public ?float $transaction_amount_refunded;

/** Payer. */
public array|object|null $payer;

/** ForwardData. */
public array|object|null $forward_data;

/** Collector ID. */
public ?int $collector_id;

/** Counter currency. */
public ?string $counter_currency;

Expand All @@ -113,15 +128,9 @@ class Payment extends MPResource
/** Payment method. */
public array|object|null $payment_method;

/** Payment type ID. */
public ?string $payment_type_id;

/** Pos ID. */
public ?string $pos_id;

/** Transaction details. */
public array|object|null $transaction_details;

/** Fee details. */
public ?array $fee_details;

Expand Down Expand Up @@ -155,15 +164,9 @@ class Payment extends MPResource
/** Coupon amount. */
public ?float $coupon_amount;

/** Installments. */
public ?int $installments;

/** Token. */
public ?string $token;

/** Description. */
public ?string $description;

/** Notification url. */
public ?string $notification_url;

Expand Down Expand Up @@ -200,6 +203,9 @@ class Payment extends MPResource
/** Platform ID. */
public ?string $platform_id;

/** Payer email */
public ?string $payer_email;

/** Charges details. */
public ?array $charges_details;

Expand All @@ -224,6 +230,9 @@ class Payment extends MPResource
/** 3DS info. */
public array|object|null $three_ds_info;

/** Barcode info. */
public array|object|null $barcode;

private $map = [
"forward_data" => "MercadoPago\Resources\Payment\ForwardData",
"payer" => "MercadoPago\Resources\Payment\Payer",
Expand All @@ -235,6 +244,8 @@ class Payment extends MPResource
"payment_method" => "MercadoPago\Resources\Payment\PaymentMethod",
"metadata" => "MercadoPago\Resources\Payment\Metadata",
"three_ds_info" => "MercadoPago\Resources\Payment\ThreeDSInfo",
"barcode" => "MercadoPago\Resources\Payment\Barcode",
"order" => "MercadoPago\Resources\Payment\Order"
];

/**
Expand Down
8 changes: 6 additions & 2 deletions src/MercadoPago/Resources/Payment/AdditionalInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ class AdditionalInfo
/** Class mapper. */
use Mapper;

/** Unique payment identifier, automatically generated by Mercado Pago.*/
public ?int $id;

/** IP from where the request comes from (only for bank transfers). */
public ?string $ip_address;

/** List of items to be paid. */
public ?array $items;
public array|object|null $items;

/** Payer's information. */
public array|object|null $payer;
Expand All @@ -33,7 +36,8 @@ class AdditionalInfo

private $map = [
"payer" => "MercadoPago\Resources\Payment\AdditionalInfoPayer",
"shipments" => "MercadoPago\Resources\Payment\Shipments"
"shipments" => "MercadoPago\Resources\Payment\Shipments",
"items" => "MercadoPago\Resources\Payment\Items"
];

/**
Expand Down
4 changes: 4 additions & 0 deletions src/MercadoPago/Resources/Payment/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Card
/** Last update of data from the card. */
public ?string $date_last_updated;

public ?string $country;

public ?string $tags;

/** Card's owner data. */
public array|object|null $cardholder;

Expand Down
2 changes: 1 addition & 1 deletion src/MercadoPago/Resources/Payment/Cardholder.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Cardholder
public array|object|null $identification;

private $map = [
"identification" => "MercadoPago\Resources\Payment\Identification"
"identification" => "MercadoPago\Resources\Common\Identification"
];

/**
Expand Down
32 changes: 32 additions & 0 deletions src/MercadoPago/Resources/Payment/CategoryDescriptor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace MercadoPago\Resources\Payment;

use MercadoPago\Serialization\Mapper;

/** CategoryDescriptor class. */
class CategoryDescriptor
{
/** Class mapper. */
use Mapper;

/** Object passenger */
public array|object|null $passenger;

/** Object Route*/
public array|object|null $route;


private $map = [
"passenger" => "MercadoPago\Resources\Common\Passenger",
"route" => "MercadoPago\Resources\Common\Route",
];

/**
* Method responsible for getting map of entities.
*/
public function getMap(): array
{
return $this->map;
}
}
Loading
Loading