如何在WooCommerce中保存从自定义网关返回的自定义值



我开发了自定义支付网关,它将使用从支付服务器(如自定义ID(获得的响应来保存信用卡信息。第二次登录时必须显示同一客户的已保存信息。

1(我第一次将客户ID发送到支付网关时,它将发送网关客户ID并将其存储在数据库中2(同一用户将第二次登录需要显示保存的抄送信息。我已经尝试过,但不确定这在WooCommerce中是如何工作的。

//Custom plugin gateway
    function handler_response(){
      //store the gateway custom id in database
    add_post_meta($order->id,'_customer_id',$_POST['gateway_custom_id']);   //this is wrong way to store. once i stored in database can't get back to check in show_form function
    }
    function show form(){
    //get_post_meta('_customer_id')
   // check condition if gateway customer id available or not and if it is avaiable show the saved cc info or if it is first time send the customer id to gateway
    <form>
<input type="text" name="">//Show saved cc info here
</form>
    }
 function handler_response(){
//store the gateway_customer_id
global $current_user;
//order_id already taken
$current_customer_id = get_user_meta( $current_user->ID, '_gateway_customer_id', true );
if(empty($current_customer_id)){                                            
    update_user_meta( $order->get_user_id(), '_gateway_customer_id', $_POST['EpicCustomerId'] );
                    }
}
function show form(){
$gatewayid = get_user_meta( $current_user->ID, '_gateway_customer_id', true );
if($gatewayid){
  //show cc info form with saved details
}else{
 // show cc normal form without save checkbox info
}
}

最新更新