mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
24 lines
639 B
PHP
24 lines
639 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Inpsyde\PayPalCommerce\ApiClient\Factory;
|
|
|
|
use Inpsyde\PayPalCommerce\ApiClient\Entity\Payee;
|
|
use Inpsyde\PayPalCommerce\ApiClient\Exception\RuntimeException;
|
|
|
|
class PayeeFactory
|
|
{
|
|
|
|
public function fromPayPalResponse(\stdClass $data): ?Payee
|
|
{
|
|
if (! isset($data->email_address)) {
|
|
throw new RuntimeException(
|
|
__("No email for payee given.", "woocommerce-paypal-commerce-gateway")
|
|
);
|
|
}
|
|
|
|
$merchantId = (isset($data->merchant_id)) ? $data->merchant_id : '';
|
|
return new Payee($data->email_address, $merchantId);
|
|
}
|
|
}
|