From 747cc7f4c0964c8fe7d7177b6bee470fdf6ce166 Mon Sep 17 00:00:00 2001 From: Danielen Cestari Nunes Date: Wed, 18 Sep 2024 16:40:33 -0300 Subject: [PATCH 1/3] update payments --- index.php | 51 +++++++++++++++++ .../Resources/Common/Passenger.php | 13 +++++ src/MercadoPago/Resources/Common/Route.php | 22 +++++++ src/MercadoPago/Resources/Payment.php | 3 + .../Resources/Payment/AdditionalInfo.php | 8 ++- .../Resources/Payment/CategoryDescriptor.php | 32 +++++++++++ src/MercadoPago/Resources/Payment/Items.php | 57 +++++++++++++++++++ src/MercadoPago/Resources/Payment/Payer.php | 12 ++++ .../Resources/Payment/PaymentMethodData.php | 1 + .../Resources/Payment/ReceiverAddress.php | 3 + 10 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 index.php create mode 100644 src/MercadoPago/Resources/Common/Passenger.php create mode 100644 src/MercadoPago/Resources/Common/Route.php create mode 100644 src/MercadoPago/Resources/Payment/CategoryDescriptor.php create mode 100644 src/MercadoPago/Resources/Payment/Items.php diff --git a/index.php b/index.php new file mode 100644 index 00000000..f7d8b714 --- /dev/null +++ b/index.php @@ -0,0 +1,51 @@ + (float) '100', + "description" => 'teste', + "payment_method_id" => 'bolbradesco', + "payer" => [ + "first_name" => "uhsausha", + "last_name" => "yhduajisf", + "email" => 'test_user_11264832@testuser.com', + "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(); +// } diff --git a/src/MercadoPago/Resources/Common/Passenger.php b/src/MercadoPago/Resources/Common/Passenger.php new file mode 100644 index 00000000..e38d5f13 --- /dev/null +++ b/src/MercadoPago/Resources/Common/Passenger.php @@ -0,0 +1,13 @@ + "MercadoPago\Resources\Payment\AdditionalInfoPayer", - "shipments" => "MercadoPago\Resources\Payment\Shipments" + "shipments" => "MercadoPago\Resources\Payment\Shipments", + "items" => "MercadoPago\Resources\Payment\Items" ]; /** diff --git a/src/MercadoPago/Resources/Payment/CategoryDescriptor.php b/src/MercadoPago/Resources/Payment/CategoryDescriptor.php new file mode 100644 index 00000000..b8b2f9ef --- /dev/null +++ b/src/MercadoPago/Resources/Payment/CategoryDescriptor.php @@ -0,0 +1,32 @@ + "MercadoPago\Resources\Common\Passenger", + "route" => "MercadoPago\Resources\Common\Route", + ]; + + /** + * Method responsible for getting map of entities. + */ + public function getMap(): array + { + return $this->map; + } +} diff --git a/src/MercadoPago/Resources/Payment/Items.php b/src/MercadoPago/Resources/Payment/Items.php new file mode 100644 index 00000000..20663875 --- /dev/null +++ b/src/MercadoPago/Resources/Payment/Items.php @@ -0,0 +1,57 @@ + "MercadoPago\Resources\Payment\CategoryDescriptor", + ]; + + /** + * Method responsible for getting map of entities. + */ + public function getMap(): array + { + return $this->map; + } +} diff --git a/src/MercadoPago/Resources/Payment/Payer.php b/src/MercadoPago/Resources/Payment/Payer.php index 8226c9ba..efddbfa6 100644 --- a/src/MercadoPago/Resources/Payment/Payer.php +++ b/src/MercadoPago/Resources/Payment/Payer.php @@ -37,6 +37,18 @@ class Payer /** Operator ID */ public ?string $operator_id; + /** Buyer registration date on your website */ + public ?string $registration_date; + + public ?string $is_prime_user; + + public ?string $is_first_purchase_online; + + public ?string $last_purchase; + + public ?string $authentication_type; + + private $map = [ "identification" => "MercadoPago\Resources\Common\Identification", "phone" => "MercadoPago\Resources\Common\Phone" diff --git a/src/MercadoPago/Resources/Payment/PaymentMethodData.php b/src/MercadoPago/Resources/Payment/PaymentMethodData.php index 8e2b1980..d83f40a6 100644 --- a/src/MercadoPago/Resources/Payment/PaymentMethodData.php +++ b/src/MercadoPago/Resources/Payment/PaymentMethodData.php @@ -22,6 +22,7 @@ class PaymentMethodData /** External Resource URL. */ public ?string $external_resource_url; + private $map = [ "rules" => "MercadoPago\Resources\Payment\PaymentMethodRules", ]; diff --git a/src/MercadoPago/Resources/Payment/ReceiverAddress.php b/src/MercadoPago/Resources/Payment/ReceiverAddress.php index b42859f1..749851da 100644 --- a/src/MercadoPago/Resources/Payment/ReceiverAddress.php +++ b/src/MercadoPago/Resources/Payment/ReceiverAddress.php @@ -18,4 +18,7 @@ class ReceiverAddress extends Address /** Floor. */ public ?string $floor; + + /** Província */ + public ?string $state_name; } From 89554ca0b727f50816019dcb83ff3fe8668c6349 Mon Sep 17 00:00:00 2001 From: Danielen Cestari Nunes Date: Thu, 19 Sep 2024 18:02:55 -0300 Subject: [PATCH 2/3] update payments --- .../Resources/Common/BusinessInfo.php | 16 ++++ src/MercadoPago/Resources/Common/Location.php | 12 +++ src/MercadoPago/Resources/Payment.php | 82 ++++++++++--------- src/MercadoPago/Resources/Payment/Card.php | 4 + .../Resources/Payment/Cardholder.php | 2 +- .../Resources/Payment/PointOfInteraction.php | 8 ++ 6 files changed, 84 insertions(+), 40 deletions(-) create mode 100644 src/MercadoPago/Resources/Common/BusinessInfo.php create mode 100644 src/MercadoPago/Resources/Common/Location.php diff --git a/src/MercadoPago/Resources/Common/BusinessInfo.php b/src/MercadoPago/Resources/Common/BusinessInfo.php new file mode 100644 index 00000000..0ec8b36e --- /dev/null +++ b/src/MercadoPago/Resources/Common/BusinessInfo.php @@ -0,0 +1,16 @@ + "MercadoPago\Resources\Payment\ForwardData", "payer" => "MercadoPago\Resources\Payment\Payer", @@ -238,6 +241,7 @@ 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", ]; /** diff --git a/src/MercadoPago/Resources/Payment/Card.php b/src/MercadoPago/Resources/Payment/Card.php index b7054f07..4e03595c 100644 --- a/src/MercadoPago/Resources/Payment/Card.php +++ b/src/MercadoPago/Resources/Payment/Card.php @@ -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; diff --git a/src/MercadoPago/Resources/Payment/Cardholder.php b/src/MercadoPago/Resources/Payment/Cardholder.php index 977797aa..cca3b585 100644 --- a/src/MercadoPago/Resources/Payment/Cardholder.php +++ b/src/MercadoPago/Resources/Payment/Cardholder.php @@ -17,7 +17,7 @@ class Cardholder public array|object|null $identification; private $map = [ - "identification" => "MercadoPago\Resources\Payment\Identification" + "identification" => "MercadoPago\Resources\Common\Identification" ]; /** diff --git a/src/MercadoPago/Resources/Payment/PointOfInteraction.php b/src/MercadoPago/Resources/Payment/PointOfInteraction.php index fc50af33..48474f66 100644 --- a/src/MercadoPago/Resources/Payment/PointOfInteraction.php +++ b/src/MercadoPago/Resources/Payment/PointOfInteraction.php @@ -22,9 +22,17 @@ class PointOfInteraction /** Transaction data. */ public array|object|null $transaction_data; + public array|object|null $business_info; + + public array|object|null $location; + + public ?string $release_info; + private $map = [ "application_data" => "MercadoPago\Resources\Payment\ApplicationData", "transaction_data" => "MercadoPago\Resources\Payment\TransactionData", + "business_info" => "MercadoPago\Resources\Common\BussinessInfo", + "location" => "MercadoPago\Resources\Common\Location", ]; /** From 749953241cb2183d2eda1510103e1b6977a1b7ff Mon Sep 17 00:00:00 2001 From: Danielen Cestari Nunes Date: Thu, 19 Sep 2024 18:29:14 -0300 Subject: [PATCH 3/3] update payments --- src/MercadoPago/Resources/Payment.php | 6 +++++- src/MercadoPago/Resources/Payment/Order.php | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/MercadoPago/Resources/Payment/Order.php diff --git a/src/MercadoPago/Resources/Payment.php b/src/MercadoPago/Resources/Payment.php index cba572ab..39dd515d 100644 --- a/src/MercadoPago/Resources/Payment.php +++ b/src/MercadoPago/Resources/Payment.php @@ -72,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; @@ -203,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; @@ -242,6 +245,7 @@ class Payment extends MPResource "metadata" => "MercadoPago\Resources\Payment\Metadata", "three_ds_info" => "MercadoPago\Resources\Payment\ThreeDSInfo", "barcode" => "MercadoPago\Resources\Payment\Barcode", + "order" => "MercadoPago\Resources\Payment\Order" ]; /** diff --git a/src/MercadoPago/Resources/Payment/Order.php b/src/MercadoPago/Resources/Payment/Order.php new file mode 100644 index 00000000..69a6d8e3 --- /dev/null +++ b/src/MercadoPago/Resources/Payment/Order.php @@ -0,0 +1,18 @@ +