<?php
/**
 * UddoktaPay Payment Gateway International Gateway Class.
 *
 * This file contains the International Gateway class for the UddoktaPay Payment Gateway,
 * handling international payment transactions through multiple payment providers.
 *
 * @package UddoktaPayGateway
 * @since 1.0.0
 */

declare (strict_types = 1);

namespace UddoktaPay\UddoktaPayGateway;

// If this file is called directly, abort!!!
defined( 'ABSPATH' ) || exit( 'Direct access is not allowed.' );

/**
 * International Gateway Class
 *
 * Provides international payment options through UddoktaPay's global payment processors.
 *
 * @since 1.0.0
 */
class InternationalGateway extends AbstractGateway {

	/**
	 * Setup general properties for the gateway.
	 *
	 * @return void
	 */
	protected function setup_properties() {
		$this->id           = 'uddoktapayinternational';
		$this->icon         = (string) apply_filters( 'woocommerce_uddoktapay_icon', UDDOKTAPAY_URL . 'assets/images/nirapodpay-international.png' );
		$this->has_fields   = false;
		$this->method_title = __( 'NirapodPay International', 'uddoktapay-gateway' );

		$this->method_description = sprintf(
			/* translators: %s: URL for NirapodPay website */
			'%s<br/><a href="%s" target="_blank">%s</a>',
			__( 'Accept international payments via multiple gateways including PayPal, Stripe, Cards and more.', 'uddoktapay-gateway' ),
			esc_url( 'https://nirapodpay.com' ),
			__( 'Get your NirapodPay credentials from nirapodpay.com', 'uddoktapay-gateway' )
		);
		$this->supports = array(
			'products',
		);
	}

	/**
	 * Base currency the gateway charges in.
	 *
	 * @return string
	 */
	protected function get_base_currency() {
		return 'USD';
	}

	/**
	 * Order meta key used to store the payment data.
	 *
	 * @return string
	 */
	protected function get_payment_data_meta_key() {
		return 'uddoktapay_international_payment_data';
	}

	/**
	 * Default checkout title.
	 *
	 * @return string
	 */
	protected function get_default_title() {
		return __( 'NirapodPay International (Cards, PayPal, Stripe)', 'uddoktapay-gateway' );
	}

	/**
	 * Default checkout description.
	 *
	 * @return string
	 */
	protected function get_default_description() {
		return __( 'Pay securely via International Cards, PayPal, Stripe, and other global payment methods with NirapodPay.', 'uddoktapay-gateway' );
	}

	/**
	 * Enable/disable field label.
	 *
	 * @return string
	 */
	protected function get_enable_label() {
		return __( 'Enable NirapodPay International Payment', 'uddoktapay-gateway' );
	}

	/**
	 * Create a payment through the API for the given order.
	 *
	 * @param \WC_Order $order The order object.
	 * @param array     $metadata Payment metadata.
	 * @return object
	 */
	protected function create_payment_for_order( $order, $metadata ) {
		$webhook_url = $this->build_order_webhook_url( $order );

		return $this->get_api()->create_payment_international(
			$order->get_total(),
			$order->get_currency(),
			$order->get_billing_first_name(),
			$order->get_billing_email(),
			$order->get_billing_phone(),
			$metadata,
			$webhook_url,
			$order->get_cancel_order_url_raw(),
			$webhook_url,
			$this->exchange_rate
		);
	}
}
