| 1 |
<?php |
| 2 |
|
| 3 |
namespace Hyperpay\Gateways\Brands; |
| 4 |
|
| 5 |
use Hyperpay\Gateways\App\DefaultGateway; |
| 6 |
use WC_Order; |
| 7 |
|
| 8 |
|
| 9 |
class Tabby extends DefaultGateway |
| 10 |
{ |
| 11 |
|
| 12 |
|
| 13 |
public $server_to_server = true; |
| 14 |
|
| 15 |
public $trans_mode = 'EXTERNAL'; |
| 16 |
|
| 17 |
/** |
| 18 |
* should be lower case and unique |
| 19 |
* @var string $id |
| 20 |
*/ |
| 21 |
public $id = "hyperpay_tabby"; |
| 22 |
|
| 23 |
/** |
| 24 |
* The title which appear next to gateway on setting page |
| 25 |
* @var string $method_title |
| 26 |
*/ |
| 27 |
public $method_title = "Tabby"; |
| 28 |
|
| 29 |
/** |
| 30 |
* Description of gateways which will appear next to title |
| 31 |
* @var string $method_description |
| 32 |
*/ |
| 33 |
public $method_description = "Tabby Plugin for Woocommerce"; |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* |
| 38 |
* the Brands supported by the gateway |
| 39 |
* @var array $supported_brands |
| 40 |
*/ |
| 41 |
protected $supported_brands = [ |
| 42 |
"TABBY" => "Tabby", |
| 43 |
]; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
/** |
| 48 |
* to set extra parameter on requested data to connector |
| 49 |
* just uncomment the function below |
| 50 |
* |
| 51 |
* @param object $order |
| 52 |
* @return array |
| 53 |
*/ |
| 54 |
|
| 55 |
public function setExtraData(WC_Order $order): array |
| 56 |
{ |
| 57 |
global $woocommerce; |
| 58 |
|
| 59 |
$data = [ |
| 60 |
"customer.mobile" => $order->get_billing_phone() |
| 61 |
]; |
| 62 |
|
| 63 |
if ($this->testMode) { |
| 64 |
$data["customer.email"] = "card.success@tabby.ai"; |
| 65 |
$data["customer.mobile"] = "0500000001"; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
$cart_index = 0; |
| 71 |
|
| 72 |
foreach ($woocommerce->cart->get_cart() as $cart_item) { |
| 73 |
$data["cart.items[$cart_index].name"] = $cart_item['data']->get_title(); |
| 74 |
$data["cart.items[$cart_index].price"] = number_format((float)$cart_item['data']->get_price(), 2, '.', ''); |
| 75 |
$data["cart.items[$cart_index].quantity"] = $cart_item['quantity']; |
| 76 |
$data["cart.items[$cart_index].sku"] = wp_rand(111111, 99999); |
| 77 |
|
| 78 |
$cart_index++; |
| 79 |
} |
| 80 |
|
| 81 |
return ['body' => $data]; |
| 82 |
} |
| 83 |
} |
| 84 |
|