paymod_id = 'paidy';
$this->pay_method = array(
'acting_paidy',
);
$this->acting_name = 'ペイディ';
$this->acting_formal_name = 'あと払い(ペイディ)';
$this->acting_company_url = 'https://paidy.com/';
$this->initialize_data();
if ( is_admin() ) {
add_action( 'admin_print_footer_scripts', array( $this, 'admin_scripts' ) );
add_action( 'usces_action_admin_settlement_update', array( $this, 'settlement_update' ) );
add_action( 'usces_action_settlement_tab_title', array( $this, 'settlement_tab_title' ) );
add_action( 'usces_action_settlement_tab_body', array( $this, 'settlement_tab_body' ) );
add_action( 'usces_filter_add_payment_method', array( $this, 'add_payment_method' ) );
add_action( 'usces_filter_up_payment_method', array( $this, 'up_payment_method' ) );
}
if ( $this->is_validity_acting() ) {
add_action( 'init', array( $this, 'acting_transaction' ) );
add_filter( 'usces_filter_is_complete_settlement', array( $this, 'is_complete_settlement' ), 10, 3 );
if ( is_admin() ) {
add_action( 'usces_action_admin_ajax', array( $this, 'admin_ajax' ) );
add_filter( 'usces_filter_orderlist_detail_value', array( $this, 'orderlist_settlement_status' ), 10, 4 );
add_action( 'usces_action_order_edit_form_status_block_middle', array( $this, 'settlement_status' ), 10, 3 );
add_action( 'usces_action_order_edit_form_settle_info', array( $this, 'settlement_information' ), 10, 2 );
add_action( 'usces_action_endof_order_edit_form', array( $this, 'settlement_dialog' ), 10, 2 );
add_filter( 'usces_filter_settle_info_field_meta_keys', array( $this, 'settlement_info_field_meta_keys' ) );
add_filter( 'usces_filter_settle_info_field_keys', array( $this, 'settlement_info_field_keys' ), 10, 2 );
add_filter( 'usces_filter_settle_info_field_value', array( $this, 'settlement_info_field_value' ), 10, 3 );
add_filter( 'usces_filter_get_link_key', array( $this, 'get_link_key' ), 10, 2 );
add_action( 'usces_action_revival_order_data', array( $this, 'revival_orderdata' ), 10, 3 );
} else {
add_action( 'wp_print_footer_scripts', array( $this, 'footer_scripts' ), 9 );
add_filter( 'usces_filter_confirm_inform', array( $this, 'confirm_inform' ), 10, 5 );
add_action( 'usces_action_acting_processing', array( $this, 'acting_processing' ), 10, 2 );
add_filter( 'usces_filter_check_acting_return_results', array( $this, 'acting_return' ) );
add_filter( 'usces_filter_check_acting_return_duplicate', array( $this, 'check_acting_return_duplicate' ), 10, 2 );
add_action( 'usces_action_reg_orderdata', array( $this, 'register_orderdata' ) );
add_filter( 'usces_filter_get_error_settlement', array( $this, 'error_page_message' ) );
}
}
}
/**
* Return an instance of this class.
*/
public static function get_instance() {
if ( is_null( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Initialize.
*/
public function initialize_data() {
$options = get_option( 'usces', array() );
$options['acting_settings']['paidy']['activate'] = ( isset( $options['acting_settings']['paidy']['activate'] ) ) ? $options['acting_settings']['paidy']['activate'] : 'off';
$options['acting_settings']['paidy']['paidy_activate'] = ( isset( $options['acting_settings']['paidy']['paidy_activate'] ) ) ? $options['acting_settings']['paidy']['paidy_activate'] : 'off';
if ( false !== strpos( $options['acting_settings']['paidy']['public_key'], '_test_' ) ) {
$options['acting_settings']['paidy']['environment'] = 'test';
$options['acting_settings']['paidy']['public_key'] = ( ! empty( $options['acting_settings']['paidy']['public_key'] ) ) ? $options['acting_settings']['paidy']['public_key'] : '';
$options['acting_settings']['paidy']['secret_key'] = ( ! empty( $options['acting_settings']['paidy']['secret_key'] ) ) ? $options['acting_settings']['paidy']['secret_key'] : '';
$options['acting_settings']['paidy']['public_key_test'] = ( ! empty( $options['acting_settings']['paidy']['public_key'] ) ) ? $options['acting_settings']['paidy']['public_key'] : '';
$options['acting_settings']['paidy']['secret_key_test'] = ( ! empty( $options['acting_settings']['paidy']['secret_key'] ) ) ? $options['acting_settings']['paidy']['secret_key'] : '';
} else {
$options['acting_settings']['paidy']['environment'] = ( isset( $options['acting_settings']['paidy']['environment'] ) ) ? $options['acting_settings']['paidy']['environment'] : 'live';
$options['acting_settings']['paidy']['public_key'] = ( isset( $options['acting_settings']['paidy']['public_key'] ) ) ? $options['acting_settings']['paidy']['public_key'] : '';
$options['acting_settings']['paidy']['secret_key'] = ( isset( $options['acting_settings']['paidy']['secret_key'] ) ) ? $options['acting_settings']['paidy']['secret_key'] : '';
$options['acting_settings']['paidy']['public_key_test'] = ( isset( $options['acting_settings']['paidy']['public_key_test'] ) ) ? $options['acting_settings']['paidy']['public_key_test'] : '';
$options['acting_settings']['paidy']['secret_key_test'] = ( isset( $options['acting_settings']['paidy']['secret_key_test'] ) ) ? $options['acting_settings']['paidy']['secret_key_test'] : '';
}
update_option( 'usces', $options );
$available_settlement = get_option( 'usces_available_settlement', array() );
if ( ! in_array( $this->paymod_id, $available_settlement, true ) ) {
$available_settlement[ $this->paymod_id ] = $this->acting_name;
update_option( 'usces_available_settlement', $available_settlement );
}
$this->unavailable_method = array( 'acting_paygent_paidy' );
}
/**
* 決済有効判定
* 支払方法で使用している場合に true
*
* @param string $type Module type.
* @return boolean
*/
public function is_validity_acting( $type = '' ) {
$options = get_option( 'usces', array() );
if ( empty( $options['acting_settings']['paidy'] ) ) {
return false;
}
$payment_method = usces_get_system_option( 'usces_payment_method', 'sort' );
$method = false;
switch ( $type ) {
case 'paidy':
foreach ( $payment_method as $payment ) {
if ( 'acting_paidy' === $payment['settlement'] && 'activate' === $payment['use'] ) {
$method = true;
break;
}
}
if ( $method && $this->is_activate_paidy() ) {
return true;
} else {
return false;
}
break;
default:
if ( isset( $options['acting_settings']['paidy']['activate'] ) && 'on' === $options['acting_settings']['paidy']['activate'] ) {
return true;
} else {
return false;
}
}
}
/**
* ペイディ決済有効判定
*
* @return boolean
*/
public function is_activate_paidy() {
$options = get_option( 'usces', array() );
if ( ( isset( $options['acting_settings']['paidy']['activate'] ) && 'on' === $options['acting_settings']['paidy']['activate'] ) &&
( isset( $options['acting_settings']['paidy']['paidy_activate'] ) && 'on' === $options['acting_settings']['paidy']['paidy_activate'] ) ) {
$res = true;
} else {
$res = false;
}
return $res;
}
/**
* 管理画面スクリプト
* admin_print_footer_scripts
*/
public function admin_scripts() {
$admin_page = filter_input( INPUT_GET, 'page' );
switch ( $admin_page ) :
/* クレジット決済設定画面 */
case 'usces_settlement':
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( $this->paymod_id, (array) $settlement_selected, true ) ) :
$options = get_option( 'usces', array() );
$paidy_activate = ( isset( $options['acting_settings']['paidy']['paidy_activate'] ) ) ? $options['acting_settings']['paidy']['paidy_activate'] : 'off';
?>
get_order_acting_flg( $order_id );
}
}
if ( in_array( $acting_flg, $this->pay_method, true ) ) :
?>
paymod_id ) {
return;
}
$this->error_mes = '';
$payment_method = usces_get_system_option( 'usces_payment_method', 'settlement' );
$options = get_option( 'usces', array() );
$post_data = wp_unslash( $_POST );
unset( $options['acting_settings']['paidy'] );
$options['acting_settings']['paidy']['paidy_activate'] = ( isset( $post_data['paidy_activate'] ) ) ? $post_data['paidy_activate'] : 'off';
$options['acting_settings']['paidy']['environment'] = ( isset( $post_data['environment'] ) ) ? $post_data['environment'] : 'live';
$options['acting_settings']['paidy']['public_key'] = ( isset( $post_data['public_key'] ) ) ? $post_data['public_key'] : '';
$options['acting_settings']['paidy']['secret_key'] = ( isset( $post_data['secret_key'] ) ) ? $post_data['secret_key'] : '';
$options['acting_settings']['paidy']['public_key_test'] = ( isset( $post_data['public_key_test'] ) ) ? $post_data['public_key_test'] : '';
$options['acting_settings']['paidy']['secret_key_test'] = ( isset( $post_data['secret_key_test'] ) ) ? $post_data['secret_key_test'] : '';
if ( 'on' === $options['acting_settings']['paidy']['paidy_activate'] ) {
if ( 'live' === $options['acting_settings']['paidy']['environment'] ) {
if ( WCUtils::is_blank( $options['acting_settings']['paidy']['public_key'] ) ) {
$this->error_mes .= '※本番用パブリックキーを入力してください
';
}
if ( WCUtils::is_blank( $options['acting_settings']['paidy']['secret_key'] ) ) {
$this->error_mes .= '※本番用シークレットキーを入力してください
';
}
} else {
if ( WCUtils::is_blank( $options['acting_settings']['paidy']['public_key_test'] ) ) {
$this->error_mes .= '※テスト用パブリックキーを入力してください
';
}
if ( WCUtils::is_blank( $options['acting_settings']['paidy']['secret_key_test'] ) ) {
$this->error_mes .= '※テスト用シークレットキーを入力してください
';
}
}
}
if ( '' === $this->error_mes ) {
$usces->action_status = 'success';
$usces->action_message = __( 'Options are updated.', 'usces' );
$toactive = array();
if ( 'on' === $options['acting_settings']['paidy']['paidy_activate'] ) {
$usces->payment_structure['acting_paidy'] = 'Paidy';
foreach ( $payment_method as $settlement => $payment ) {
if ( 'acting_paidy' === $settlement && 'activate' !== $payment['use'] ) {
$toactive[] = $payment['name'];
}
}
} else {
unset( $usces->payment_structure['acting_paidy'] );
}
if ( 'on' === $options['acting_settings']['paidy']['paidy_activate'] ) {
$options['acting_settings']['paidy']['activate'] = 'on';
usces_admin_orderlist_show_wc_trans_id();
if ( 0 < count( $toactive ) ) {
$usces->action_message .= __( 'Please update the payment method to "Activate". General Setting > Payment Methods', 'usces' );
}
} else {
$options['acting_settings']['paidy']['activate'] = 'off';
unset( $usces->payment_structure['acting_paidy'] );
}
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( ! array_key_exists( $settlement, $usces->payment_structure ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message;
}
} else {
$usces->action_status = 'error';
$usces->action_message = __( 'Data have deficiency.', 'usces' );
$options['acting_settings']['paidy']['activate'] = 'off';
unset( $usces->payment_structure['acting_paidy'] );
$deactivate = array();
foreach ( $payment_method as $settlement => $payment ) {
if ( in_array( $settlement, $this->pay_method, true ) ) {
if ( 'deactivate' !== $payment['use'] ) {
$payment['use'] = 'deactivate';
$deactivate[] = $payment['name'];
usces_update_system_option( 'usces_payment_method', $payment['id'], $payment );
}
}
}
if ( 0 < count( $deactivate ) ) {
$deactivate_message = sprintf( __( '"Deactivate" %s of payment method.', 'usces' ), implode( ',', $deactivate ) );
$usces->action_message .= $deactivate_message . __( 'Please complete the setup and update the payment method to "Activate".', 'usces' );
}
}
ksort( $usces->payment_structure );
update_option( 'usces', $options );
update_option( 'usces_payment_structure', $usces->payment_structure );
}
/**
* クレジット決済設定画面タブ
* usces_action_settlement_tab_title
*/
public function settlement_tab_title() {
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( $this->paymod_id, $settlement_selected, true ) ) {
echo '
' . esc_html( $this->acting_name ) . '';
}
}
/**
* クレジット決済設定画面フォーム
* usces_action_settlement_tab_body
*/
public function settlement_tab_body() {
$settlement_selected = get_option( 'usces_settlement_selected', array() );
if ( in_array( $this->paymod_id, $settlement_selected, true ) ) :
$options = get_option( 'usces', array() );
$activate = ( isset( $options['acting_settings']['paidy']['activate'] ) && 'on' === $options['acting_settings']['paidy']['activate'] ) ? true : false;
$paidy_activate = ( isset( $options['acting_settings']['paidy']['paidy_activate'] ) && ( 'on' === $options['acting_settings']['paidy']['paidy_activate'] ) ) ? 'on' : 'off';
$environment = ( isset( $options['acting_settings']['paidy']['environment'] ) ) ? $options['acting_settings']['paidy']['environment'] : 'live';
?>
acting_name ); ?>
paymod_id ) :
if ( '' !== $this->error_mes ) :
?>
error_mes ); ?>
十分にテストを行ってから運用してください。
ペイディとは
クレジットカードが不要なため、クレジットカードを持っていない若年層や、セキュリティが不安でクレジットカードをなるべく使いたくないユーザーも、安心してお買い物を楽しむことができる決済です。
ペイディの詳細はこちら 》
【ご利用までの流れ】
お申し込み前に「特定商取引法に基づく表示」と「プライバシーポリシー(個人情報の第三者提供含む)」ページのご準備をお願いいたします。
- 加盟店申請:ダッシュボードのペイディ決済らくらく設定、またはペイディWebサイトからお申し込みください。
- 加盟店審査:お申し込みから最大10営業日で、審査結果メールがPaidy合同会社より届きます。添付されている条件通知書で、「契約日」と「経済条件」をご確認ください。
- 利用開始 :
- ペイディ決済らくらく設定から申し込んだ場合、ダッシュボードに表示されるボタンによりご利用開始が可能です。
- ペイディWebサイトから申し込んだ場合、WelcartでAPIキーの設定が完了したら、ご利用開始となります。
APIキーの確認方法は、ペイディ導入ガイドの Paidy APIキー をご確認ください。
【資料】
操作方法などについては下記をご覧ください。
ペイディ導入ガイド
ペイディ加盟店管理画面マニュアル
加盟店FAQ
acting_formal_name ) {
$unique = false;
} elseif ( $pm['name'] === $newvalue['name'] ) {
$unique = false;
}
}
if ( $unique ) {
$newvalue['name'] = $this->acting_formal_name;
}
$newvalue['explanation'] = '
- クレジットカード、事前登録不要。
- メールアドレスと携帯番号だけで、今すぐお買い物。
- 1か月に何度お買い物しても、お支払いは翌月まとめて1回でOK。
- お支払いは翌月10日までに、コンビニ払い・銀行振込・口座振替で。
';
}
return $newvalue;
}
/**
* 支払方法変更
* usces_filter_up_payment_method
*
* @param array $value Payment method data.
* @return array
*/
public function up_payment_method( $value ) {
if ( USCES_JP && 'acting_paidy' === $value['settlement'] ) {
$value['name'] = $this->acting_formal_name;
}
return $value;
}
/**
* 結果通知処理
* usces_after_cart_instant
*/
public function acting_transaction() {
global $usces;
$post_json = file_get_contents( 'php://input' );
$post_data = json_decode( $post_json, true );
if ( isset( $post_data['payment_id'] ) && isset( $post_data['status'] ) && isset( $post_data['order_ref'] ) ) {
if ( 'authorize_success' === $post_data['status'] ) {
$order_id = usces_get_order_id_by_trans_id( $post_data['order_ref'] );
if ( empty( $order_id ) ) {
// $response_data = $this->api_close( $post_data['payment_id'] );
$response_data = $this->api_retrieve( $post_data['payment_id'] );
if ( isset( $response_data['status'] ) && 'authorized' === $response_data['status'] ) {
if ( ! isset( $response_data['acting'] ) ) {
$response_data['acting'] = 'paidy';
}
$res = $usces->order_processing( $response_data );
}
}
}
header( 'HTTP/1.0 200 OK' );
die();
}
}
/**
* ポイント即時付与
* usces_filter_is_complete_settlement
*
* @param boolean $complete Complete the payment.
* @param string $payment_name Payment name.
* @param string $status Payment status.
* @return boolean
*/
public function is_complete_settlement( $complete, $payment_name, $status ) {
$payment = usces_get_payments_by_name( $payment_name );
if ( isset( $payment['settlement'] ) && 'acting_paidy' === $payment['settlement'] ) {
$complete = true;
}
return $complete;
}
/**
* 管理画面決済処理
* usces_action_admin_ajax
*/
public function admin_ajax() {
global $usces;
$mode = filter_input( INPUT_POST, 'mode' );
$data = array();
switch ( $mode ) {
/* 参照 */
case 'retrieve_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = filter_input( INPUT_POST, 'order_id' );
$trans_id = filter_input( INPUT_POST, 'trans_id' );
if ( empty( $order_id ) || empty( $trans_id ) ) {
$data['status'] = 'retrieve_error';
wp_send_json( $data );
break;
}
$result = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trans_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$response_data = $this->api_retrieve( $payment_id, true );
if ( isset( $response_data['status'] ) ) {
$status = $response_data['status'];
$amount = ( isset( $response_data['final_amount'] ) ) ? $response_data['final_amount'] : $response_data['amount'];
if ( ! empty( $response_data['capture_id'] ) && 0 < $amount ) {
$status = 'capture';
}
$class = ' paidy-' . $status;
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
switch ( $status ) {
case 'authorized':
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case 'capture':
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case 'closed':
$result .= '';
break;
}
}
$result .= $this->settlement_history( $order_id, $trans_id );
$data['result'] = $result;
wp_send_json( $data );
break;
/* クローズ */
case 'close_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = filter_input( INPUT_POST, 'order_id' );
$trans_id = filter_input( INPUT_POST, 'trans_id' );
if ( empty( $order_id ) || empty( $trans_id ) ) {
$data['status'] = 'retrieve_error';
wp_send_json( $data );
break;
}
$result = '';
$status = 'closed';
$acting_status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trans_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$response_data = $this->api_close( $payment_id );
if ( isset( $response_data['status'] ) && ! isset( $response_data['code'] ) ) {
$this->save_acting_log( $response_data, 'paidy', $status, 'OK', $order_id, $trans_id );
$class = ' paidy-' . $status;
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$acting_status = '' . $status_name . '';
$result .= '';
} else {
$status = 'closed_error';
$this->save_acting_log( $response_data, 'paidy', $status, 'NG', $order_id, $trans_id );
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$amount = (int) $latest_log['amount'];
switch ( $latest_log['status'] ) {
case 'authorized':
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
case 'capture':
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
break;
}
}
$result .= $this->settlement_history( $order_id, $trans_id );
$data['result'] = $result;
$data['acting_status'] = $acting_status;
wp_send_json( $data );
break;
/* キャプチャー(売上確定) */
case 'capture_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = filter_input( INPUT_POST, 'order_id' );
$trans_id = filter_input( INPUT_POST, 'trans_id' );
if ( empty( $order_id ) || empty( $trans_id ) ) {
$data['status'] = 'retrieve_error';
wp_send_json( $data );
break;
}
$result = '';
$status = 'capture';
$acting_status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trans_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$response_data = $this->api_capture( $payment_id );
if ( isset( $response_data['status'] ) && ! isset( $response_data['code'] ) ) {
$this->save_acting_log( $response_data, 'paidy', $status, 'OK', $order_id, $trans_id );
$class = ' paidy-' . $status;
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$acting_status = '' . $status_name . '';
$amount = (int) $latest_log['amount'];
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
} else {
$status = 'capture_error';
$this->save_acting_log( $response_data, 'paidy', $status, 'NG', $order_id, $trans_id );
$status_name = $this->get_status_name( $status );
$amount = (int) $latest_log['amount'];
$result .= '' . $status_name . '
';
$result .= '';
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
}
$result .= $this->settlement_history( $order_id, $trans_id );
$data['result'] = $result;
$data['acting_status'] = $acting_status;
wp_send_json( $data );
break;
/* リファンド(返金) */
case 'refund_paidy':
check_admin_referer( 'order_edit', 'wc_nonce' );
$order_id = filter_input( INPUT_POST, 'order_id' );
$trans_id = filter_input( INPUT_POST, 'trans_id' );
$amount = filter_input( INPUT_POST, 'amount' );
if ( empty( $order_id ) || empty( $trans_id ) ) {
$data['status'] = 'retrieve_error';
wp_send_json( $data );
break;
}
$result = '';
$status = 'refund';
$acting_status = '';
$latest_log = $this->get_acting_latest_log( $order_id, $trans_id );
$payment_id = ( isset( $latest_log['payment_id'] ) ) ? $latest_log['payment_id'] : '';
$retrieve_data = $this->api_retrieve( $payment_id, true );
if ( isset( $retrieve_data['status'] ) && 'closed' === $retrieve_data['status'] && ! empty( $retrieve_data['capture_id'] ) && ! empty( $retrieve_data['final_amount'] ) ) {
$response_data = $this->api_refund( $payment_id, $retrieve_data['capture_id'], $amount );
if ( isset( $response_data['status'] ) && ! isset( $response_data['code'] ) ) {
$this->save_acting_log( $response_data, 'paidy', $status, 'OK', $order_id, $trans_id, $amount );
$final_amount = (int) $retrieve_data['final_amount'] - $amount;
if ( 0 === $final_amount ) {
$status = 'closed';
$this->save_acting_log( $response_data, 'paidy', $status, 'OK', $order_id, $trans_id );
} else {
$status = 'capture';
}
$class = ' paidy-' . $status;
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$acting_status = '' . $status_name . '';
} else {
$status = 'refund_error';
$this->save_acting_log( $response_data, 'paidy', $status, 'NG', $order_id, $trans_id );
$status_name = $this->get_status_name( $status );
$result .= '' . $status_name . '
';
$final_amount = (int) $latest_log['amount'];
}
switch ( $status ) {
case 'closed':
$result .= '';
break;
default:
$result .= '';
$result .= '';
$result .= '';
$result .= '
';
}
}
$result .= $this->settlement_history( $order_id, $trans_id );
$data['result'] = $result;
$data['acting_status'] = $acting_status;
wp_send_json( $data );
break;
}
}
/**
* 決済履歴
*
* @param int $order_id Order number.
* @param string $trans_id Transaction ID.
* @return string
*/
private function settlement_history( $order_id, $trans_id ) {
$history = '';
$log_data = $this->get_acting_log( $order_id, $trans_id, 'ALL' );
if ( $log_data ) {
$num = count( $log_data );
$history = '';
$history .= '';
$history .= ' | ' . __( 'Processing date', 'usces' ) . ' | 決済ID | ' . __( 'Status', 'usces' ) . ' | ' . __( 'Amount', 'usces' ) . ' | ' . __( 'Result', 'usces' ) . ' |
';
$history .= '';
$history .= '';
foreach ( (array) $log_data as $data ) {
$log = usces_unserialize( $data['log'] );
$payment_id = ( isset( $log['id'] ) ) ? $log['id'] : '';
$status_name = ( isset( $data['status'] ) ) ? $this->get_status_name( $data['status'] ) : '';
$err_code = '';
$class = '';
if ( 'OK' === $data['result'] && 0 < $data['amount'] ) {
$amount = usces_crform( $data['amount'], false, true, 'return', true );
} else {
$amount = '';
}
if ( 'OK' !== $data['result'] ) {
$err_code = ( isset( $log['code'] ) ) ? $log['code'] : '';
$class = ' error';
}
$history .= '';
$history .= '| ' . $num . ' | ';
$history .= '' . $data['datetime'] . ' | ';
$history .= '' . $payment_id . ' | ';
$history .= '' . $status_name . ' | ';
$history .= '' . $amount . ' | ';
$history .= '' . $err_code . ' | ';
$history .= '
';
$num--;
}
$history .= '';
$history .= '
';
}
return $history;
}
/**
* 決済状況
* usces_filter_orderlist_detail_value
*
* @param string $detail HTML.
* @param string $value Settlement info key.
* @param string $key Settlement info value.
* @param int $order_id Order number.
* @return array
*/
public function orderlist_settlement_status( $detail, $value, $key, $order_id ) {
if ( 'wc_trans_id' !== $key || empty( $value ) ) {
return $detail;
}
$acting_flg = $this->get_order_acting_flg( $order_id );
if ( 'acting_paidy' === $acting_flg ) {
$trans_id = $this->get_trans_id( $order_id );
$payment_status = $this->get_payment_status( $order_id, $trans_id );
if ( ! empty( $payment_status ) ) {
$class = ' paidy-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
if ( ! empty( $status_name ) ) {
$detail = '' . esc_html( $value ) . '' . esc_html( $status_name ) . ' | ';
}
}
}
return $detail;
}
/**
* 受注編集画面【ステータス】
* usces_action_order_edit_form_status_block_middle
*
* @param array $data Order data.
* @param array $cscs_meta Custom field data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_status( $data, $cscs_meta, $action_args ) {
extract( $action_args );
if ( 'new' !== $order_action && ! empty( $order_id ) ) {
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
$acting_flg = ( isset( $payment['settlement'] ) ) ? $payment['settlement'] : '';
if ( 'acting_paidy' === $acting_flg ) {
$trans_id = $this->get_trans_id( $order_id );
$payment_status = $this->get_payment_status( $order_id, $trans_id );
if ( ! empty( $payment_status ) ) {
$class = ' paidy-' . $this->get_status( $payment_status );
$status_name = $this->get_status_name( $payment_status );
if ( ! empty( $status_name ) ) {
echo '
| ' . esc_html__( 'Settlement status', 'usces' ) . ' |
' . esc_html( $status_name ) . ' |
';
}
}
}
}
}
/**
* 受注編集画面【支払情報】
* usces_action_order_edit_form_settle_info
*
* @param array $data Order data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_information( $data, $action_args ) {
global $usces;
extract( $action_args );
if ( 'new' !== $order_action && ! empty( $order_id ) ) {
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
if ( isset( $payment['settlement'] ) && 'acting_paidy' === $payment['settlement'] ) {
$trans_id = $this->get_trans_id( $order_id );
$acting_data = usces_unserialize( $usces->get_order_meta_value( $payment['settlement'], $order_id ) );
if ( ! empty( $trans_id ) && isset( $acting_data['id'] ) ) {
echo '';
}
}
}
}
/**
* 決済情報ダイアログ
* usces_action_endof_order_edit_form
*
* @param array $data Order data.
* @param array $action_args Compact array( 'order_action', 'order_id', 'cart' ).
*/
public function settlement_dialog( $data, $action_args ) {
extract( $action_args );
if ( 'new' !== $order_action && ! empty( $order_id ) ) :
$payment = usces_get_payments_by_name( $data['order_payment_name'] );
if ( isset( $payment['settlement'] ) && 'acting_paidy' === $payment['settlement'] ) :
?>
acting_name;
}
return $value;
}
/**
* 決済リンクキー
* usces_filter_get_link_key
*
* @param string $linkkey Settlement link key.
* @param array $results Response data.
* @return string
*/
public function get_link_key( $linkkey, $results ) {
if ( isset( $results['trans_id'] ) ) {
$linkkey = $results['trans_id'];
} elseif ( isset( $results['trading_id'] ) ) {
$linkkey = $results['trading_id'];
}
return $linkkey;
}
/**
* 受注データ復旧処理
* usces_action_revival_order_data
*
* @param int $order_id Order number.
* @param string $log_key Link key.
* @param string $acting_flg Payment type.
*/
public function revival_orderdata( $order_id, $log_key, $acting_flg ) {
global $usces;
if ( 'acting_paidy' === $acting_flg ) {
$usces->set_order_meta_value( 'trans_id', $log_key, $order_id );
$usces->set_order_meta_value( 'wc_trans_id', $log_key, $order_id );
$data = array(
'trans_id' => $log_key,
);
$usces->set_order_meta_value( $acting_flg, usces_serialize( $data ), $order_id );
}
}
/**
* 内容確認ページ [注文する] ボタン
* usces_filter_confirm_inform
*
* @param string $form Purchase post form.
* @param array $payments Payment data.
* @param string $acting_flg Payment type.
* @param string $rand Welcart transaction key.
* @param string $purchase_disabled Disable purchase button.
* @return string
*/
public function confirm_inform( $form, $payments, $acting_flg, $rand, $purchase_disabled ) {
global $usces;
if ( 'acting_paidy' !== $acting_flg ) {
return $form;
}
$entry = $usces->cart->get_entry();
$cart = $usces->cart->get_cart();
if ( ! $entry || ! $cart ) {
return $form;
}
if ( ! $entry['order']['total_full_price'] ) {
return $form;
}
usces_save_order_acting_data( $rand );
$form = '