Skip to content

Commit

Permalink
Added PayPay (#372)
Browse files Browse the repository at this point in the history
* added pay pay

* update paypay logo
  • Loading branch information
ajzkk authored Apr 28, 2023
1 parent bc6bbbf commit 15ec030
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 1 deletion.
Binary file added assets/images/paypay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion includes/class-omise-payment-factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ class Omise_Payment_Factory {
'Omise_Payment_Maybank_QR',
'Omise_Payment_DuitNow_QR',
'Omise_Payment_DuitNow_OBW',
'Omise_Payment_Atome'
'Omise_Payment_Atome',
'Omise_Payment_PayPay'
);

/**
Expand Down
86 changes: 86 additions & 0 deletions includes/gateway/class-omise-payment-paypay.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php
defined( 'ABSPATH' ) or die( 'No direct script access allowed.' );

class Omise_Payment_PayPay extends Omise_Payment_Offsite {
public function __construct() {
parent::__construct();

$this->id = 'omise_paypay';
$this->has_fields = false;
$this->method_title = __( 'Opn Payments PayPay', 'omise' );
$this->method_description = __( 'Accept payment through <strong>PayPay</strong> via Opn Payments payment gateway.', 'omise' );
$this->supports = array( 'products', 'refunds' );

$this->init_form_fields();
$this->init_settings();

$this->title = $this->get_option( 'title' );
$this->description = $this->get_option( 'description' );
$this->restricted_countries = array( 'JP' );
$this->source_type = 'paypay';

add_action( 'woocommerce_api_' . $this->id . '_callback', 'Omise_Callback::execute' );
add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
add_action( 'woocommerce_order_action_' . $this->id . '_sync_payment', array( $this, 'sync_payment' ) );
}

/**
* @see WC_Settings_API::init_form_fields()
* @see woocommerce/includes/abstracts/abstract-wc-settings-api.php
*/
public function init_form_fields() {
$this->form_fields = array(
'enabled' => array(
'title' => __( 'Enable/Disable', 'omise' ),
'type' => 'checkbox',
'label' => __( 'Enable Opn Payments PayPay Payment', 'omise' ),
'default' => 'no'
),

'title' => array(
'title' => __( 'Title', 'omise' ),
'type' => 'text',
'description' => __( 'This controls the title the user sees during checkout.', 'omise' ),
'default' => __( 'PayPay', 'omise' ),
),

'description' => array(
'title' => __( 'Description', 'omise' ),
'type' => 'textarea',
'description' => __( 'This controls the description the user sees during checkout.', 'omise' )
),
);
}

/**
* @inheritdoc
*/
public function charge($order_id, $order)
{
$currency = $order->get_currency();
return OmiseCharge::create([
'amount' => Omise_Money::to_subunit($order->get_total(), $currency),
'currency' => $currency,
'description' => apply_filters('omise_charge_params_description', 'WooCommerce Order id ' . $order_id, $order),
'source' => ['type' => $this->source_type],
'return_uri' => $this->getRedirectUrl('omise_paypay_callback', $order_id, $order),
'metadata' => $this->getMetadata($order_id, $order)
]);
}

/**
* Get icons
*
* @see WC_Payment_Gateway::get_icon()
*/
public function get_icon()
{
$icon = Omise_Image::get_image([
'file' => 'paypay.png',
'alternate_text' => 'PayPay',
'width' => 18,
'height' => 18,
]);
return apply_filters( 'woocommerce_gateway_icon', $icon, $this->id );
}
}
1 change: 1 addition & 0 deletions omise-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ private function include_classes()
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-touch-n-go.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-atome.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/gateway/class-omise-payment-paypay.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/libraries/omise-php/lib/Omise.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/libraries/omise-plugin/Omise.php';
require_once OMISE_WOOCOMMERCE_PLUGIN_PATH . '/includes/class-omise-ajax-actions.php';
Expand Down

0 comments on commit 15ec030

Please sign in to comment.