<?php
namespace Laravel\Socialite;
use ArrayAccess;
use Laravel\Socialite\Contracts\User;
abstract class AbstractUser implements ArrayAccess, User
{
/**
* The unique identifier for the user.
*
* @var mixed
*/
public $id;
/**
* The user's nickname / username.
*
* @var string
*/
public $nickname;
/**
* The user's full name.
*
* @var string
*/
public $name;
/**
* The user's e-mail address.
*
* @var string
*/
public $email;
/**
* The user's avatar image URL.
*
* @var string
*/
public $avatar;
/**
* The user's raw attributes.
*
* @var array
*/
public $user;
/**
* The user's other attributes.
*
* @var array
*/
public $attributes = [];
/**
* Get the unique identifier for the user.
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* Get the nickname / username for the user.
*
* @return string|null
*/
public function getNickname()
{
return $this->nickname;
}
/**
* Get the full name of the user.
*
* @return string|null
*/
public function getName()
{
return $this->name;
}
/**
* Get the e-mail address of the user.
*
* @return string|null
*/
public function getEmail()
{
return $this->email;
}
/**
* Get the avatar / image URL for the user.
*
* @return string|null
*/
public function getAvatar()
{
return $this->avatar;
}
/**
* Get the raw user array.
*
* @return array
*/
public function getRaw()
{
return $this->user;
}
/**
* Set the raw user array from the provider.
*
* @param array $user
* @return $this
*/
public function setRaw(array $user)
{
$this->user = $user;
return $this;
}
/**
* Map the given array onto the user's properties.
*
* @param array $attributes
* @return $this
*/
public function map(array $attributes)
{
$this->attributes = $attributes;
foreach ($attributes as $key => $value) {
if (property_exists($this, $key)) {
$this->{$key} = $value;
}
}
return $this;
}
/**
* Determine if the given raw user attribute exists.
*
* @param string $offset
* @return bool
*/
#[\ReturnTypeWillChange]
public function offsetExists($offset)
{
return array_key_exists($offset, $this->user);
}
/**
* Get the given key from the raw user.
*
* @param string $offset
* @return mixed
*/
#[\ReturnTypeWillChange]
public function offsetGet($offset)
{
return $this->user[$offset];
}
/**
* Set the given attribute on the raw user array.
*
* @param string $offset
* @param mixed $value
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetSet($offset, $value)
{
$this->user[$offset] = $value;
}
/**
* Unset the given value from the raw user array.
*
* @param string $offset
* @return void
*/
#[\ReturnTypeWillChange]
public function offsetUnset($offset)
{
unset($this->user[$offset]);
}
/**
* Get a user attribute value dynamically.
*
* @param string $key
* @return void
*/
public function __get($key)
{
return $this->attributes[$key] ?? null;
}
}
Initiates a new payment transaction.
create-order
| Parameter | Type | Details |
|---|---|---|
| amount | decimal | Your Amount , Must be rounded at 2 precision. |
| currency | string | Currency Code, Must be in Upper Case (Alpha-3 code) |
| success_url | string | Enter your return or success URL |
| cancel_url | string (optional) | Enter your cancel or failed URL |
Request Example (guzzle)
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', $base_url.'create-order', [
'headers' => [
'Authorization' => 'Bearer '. $authorizationToken,
'accept' => 'application/json',
'content-type' => 'application/json',
],
'form_params' => [
'amount' => '$amount',
'currency' => 'currency',
'success_url' => 'success_url',
'cancel_url' => 'cancel_url',
],
]);
echo $response->getBody();
**Response: SUCCESS (200 OK)**
{
"message": {
"success": [
"Order created successfully."
]
},
"data": {
"redirect_url":"https://example.com/login/OISADFDFSDFSF",
"order_details":{
"amount" : "10",
"fixed_charge" : 2,
"percent_charge" : 1,
"total_charge" : 3,
"total_payable" : 13,
"currency" : "USD",
"expiry_time": "2024-04-25T06:48:35.984285Z",
"success_url": "http://127.0.0.1/nfcpay/user/transaction/success",
"cancel_url": "http://127.0.0.1/nfcpay/user/transaction/cancel"
}
},
"type": "success"
}
**Response: ERROR (400 FAILED)**
{
"message": {
"error": [
"Invalid token."
]
},
"data": null,
"type": "error"
}