using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.Common;
using Cosmos.CommonManager;
using System.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
using System.Net.Cache;
using System.IO;
using System.Collections.Specialized;
using System.Management;
using System.Security.Cryptography;
//************************************************************************************************
// 최초 작성 : 2018.02.22, 미주 펀치 APP 와 해피포인트 기능 ; girak.kim
// Class : Model > PunchhPosClient(PunchhClientResponse) <--> PunchhServiceCaller (PunchhAPIResponse)
// 변경 이력 :
//------------------------------------------------------------------------------------------------
// - 수정 이유 :
// - 수정 내용 :
// - 수정 적용된 내용 :
// - 기 타 :
//************************************************************************************************
namespace Cosmos.Service
{
//##############################[결제, 포인트 관련 인터페이스 구현 클래스]#############################################//
class PunchhHappyPoint_US : PaymentBase, IPaymentUs
{
private IOCBDirect m_OCBDirect = null;
public PunchhHappyPoint_US()
{
m_OCBDirect = (IOCBDirect)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.OCB_DIRECT);
}
#region SearchPayment 결제 조회
///
/// 결제 조회
///
///
///
///
public string SearchPayment(string[] aParam, ref string[] aRet)
{
string sRet = UserCom.RST_ERR;
return sRet;
}
#endregion
#region GetPayment 결제 정보 획득
///
/// 결제 정보 획득
///
///
///
public object GetPayment(string[] aParam)
{
return m_cPayItem;
}
#endregion
#region SetPayment 결제 등록
///
/// 결제 등록(제휴 포인트 사용)
///
///
///
public string SetPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
return sRet;
}
#endregion
#region CancelPayment 결제 취소
///
/// 결제 취소
///
///
///
public string CancelPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
return sRet;
}
#endregion
#region RefundPayment 결제 반품
///
/// 결제 반품
///
///
///
public string RefundPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
return sRet;
}
#endregion
#region SetMenualPayment
public string SetMenualPayment(string[] aParam)
{
string sRet = UserCom.RST_ERR;
return sRet;
}
#endregion
}
//##############################[결제, 포인트 관련 인터페이스 구현 클래스 끝]#############################################//
#region Punchh 상수
public class PunchhConst
{
public const string LOCATION_KEY = "9079df560fad175e29c5dff19c5acbda";//"273b9a4039481b5063e1d1001cdaef4e";
public const string USER_LOOKUP_API_URL = "/users/search";//사용자 정보 조회
public static string POSSIBLE_REDEMPTION_API_URL = "/redemptions/possible"; //
public static string CREATE_OR_VOID_REDEMPTION_API_URL = "/redemptions";
public static string CHECKIN_API_URL = "/checkins";
}
#endregion
#region 각종 요청/응답 모델 Strat (API 연동 시에 아래 모델 Json 형식으로 파싱함
#region 공통 모델 (Balance, Reward, MenuItem) Strat
public class Balance
{
[JsonProperty(PropertyName = "banked_rewards")]
public double BankedRewards { get; set; }
[JsonProperty(PropertyName = "membership_level")]
public string MembershipLevel { get; set; }
[JsonProperty(PropertyName = "membership_level_id")]
public int? MembershipLevelId { get; set; }
[JsonProperty(PropertyName = "membership_program_id")]
public int? MembershipProgramId { get; set; }
[JsonProperty(PropertyName = "net_balance")]
public double? NetBalance { get; set; }
[JsonProperty(PropertyName = "net_debits")]
public double? NetDebits { get; set; }
[JsonProperty(PropertyName = "pending_points")]
public double? PendingPoints { get; set; }
[JsonProperty(PropertyName = "points_balance")]
public double? PointsBalance { get; set; }
[JsonProperty(PropertyName = "signup_anniversary_day")]
public string SignupAnniversaryDay { get; set; }
[JsonProperty(PropertyName = "total_credits")]
public double? TotalCredits { get; set; }
[JsonProperty(PropertyName = "total_debits")]
public double? TotalDebits { get; set; }
[JsonProperty(PropertyName = "total_point_credits")]
public double? TotalPointCredits { get; set; }
[JsonProperty(PropertyName = "total_redeemable_visits")]
public int? TotalRedeemableVisits { get; set; }
[JsonProperty(PropertyName = "expired_membership_level")]
public string ExpiredMembershipLevel { get; set; }
[JsonProperty(PropertyName = "total_visits")]
public int? TotalVisits { get; set; }
[JsonProperty(PropertyName = "initial_visits")]
public int? InitialVisits { get; set; }
[JsonProperty(PropertyName = "unredeemed_cards")]
public int? UnredeemedCards { get; set; }
}
public class Reward
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "name")]
public string Name { get; set; }
[JsonProperty(PropertyName = "description")]
public string Description { get; set; }
[JsonProperty(PropertyName = "discount_amount")]
public double DiscountAmount { get; set; }
[JsonProperty(PropertyName = "points")]
public double Points { get; set; }
[JsonProperty(PropertyName = "image")]
public string Image { get; set; }
[JsonProperty(PropertyName = "created_at")]
public DateTime? CreatedAt { get; set; }
[JsonProperty(PropertyName = "end_date_tz")]
public DateTime? EndDateTz { get; set; }
[JsonProperty(PropertyName = "start_date_tz")]
public DateTime? StartDateTz { get; set; }
[JsonProperty(PropertyName = "updated_at")]
public DateTime? UpdatedAt { get; set; }
[JsonProperty(PropertyName = "redeemable_properties")]
public string RedeemableProperties { get; set; }
[JsonProperty(PropertyName = "status")]
public string Status { get; set; }
}
public class MenuItem
{
[JsonProperty(PropertyName = "item_name")]
public string ItemName { get; set; }
[JsonProperty(PropertyName = "item_qty")]
public int? ItemQty { get; set; }
[JsonProperty(PropertyName = "item_amount")]
public double? ItemAmount { get; set; }
[JsonProperty(PropertyName = "menu_item_type")]
public string MenuItemType { get; set; }
[JsonProperty(PropertyName = "menu_item_id")]
public int? MenuItemId { get; set; }
[JsonProperty(PropertyName = "menu_family")]
public string MenuFamily { get; set; }
[JsonProperty(PropertyName = "menu_major_group")]
public string MenuMajorGroup { get; set; }
[JsonProperty(PropertyName = "serial_number")]
public int? SerialNumber { get; set; }
}
#endregion 공통 모델 (Balance, Reward, MenuItem) End
#region UserLookup Model 사용자 정보, 포인트 조회 요청 파라메타
public class UserLookupRequest
{
[JsonProperty(PropertyName = "location_key")]
public string LocationKey { get; set; }
[JsonProperty(PropertyName = "phone")]
public string Phone { get; set; }
[JsonProperty(PropertyName = "user_as_qrcode")]
public string UserAsQRcode { get; set; }
[JsonProperty(PropertyName = "redemption_code")]
public string RedemptionCode { get; set; }
[JsonProperty(PropertyName = "card_number")]
public string CardNumber { get; set; }
}
public class UserLookupResponse
{
[JsonProperty(PropertyName = "id")]
public int Id { get; set; }
[JsonProperty(PropertyName = "created_at")]
public DateTime? CreatedAt { get; set; }
[JsonProperty(PropertyName = "updated_at")]
public DateTime? UpdatedAt { get; set; }
[JsonProperty(PropertyName = "first_name")]
public string FirstName { get; set; }
[JsonProperty(PropertyName = "last_name")]
public string LastName { get; set; }
[JsonProperty(PropertyName = "phone")]
public string Phone { get; set; }
[JsonProperty(PropertyName = "fb_uid")]
public string FbUid { get; set; }
[JsonProperty(PropertyName = "birthday")]
public DateTime? Birthday { get; set; }
[JsonProperty(PropertyName = "gender")]
public string Gender { get; set; }
[JsonProperty(PropertyName = "city")]
public string City { get; set; }
[JsonProperty(PropertyName = "state")]
public string State { get; set; }
[JsonProperty(PropertyName = "selected_card_number")]
public string SelectedCardNumber { get; set; }
[JsonProperty(PropertyName = "selected_reward_id")]
public int? selected_reward_id { get; set; }
[JsonProperty(PropertyName = "balance")]
public Balance Balance { get; set; }
[JsonProperty(PropertyName = "rewards")]
public List Rewards { get; set; }
}
#endregion UserLookup Model End
#region Redemption Possible Model (결제 가능 여부 잔액 조회)
public class RedemptionRequest
{
[JsonProperty(PropertyName = "location_key")]
public string LocationKey { get; set; }
[JsonProperty(PropertyName = "discount_type")]
public string DiscountType { get; set; }
[JsonProperty(PropertyName = "reward_id")]
public int? RewardId { get; set; }
[JsonProperty(PropertyName = "redemption_code")]
public string RedemptionCode { get; set; }
[JsonProperty(PropertyName = "user_as_qrcode")]
public string UserAsQRcode { get; set; }
[JsonProperty(PropertyName = "punchh_key")]
public string PunchhKey { get; set; }
[JsonProperty(PropertyName = "transaction_no")]
public int? TransactionNo { get; set; }
[JsonProperty(PropertyName = "receipt_datetime")]
public DateTime? ReceiptDateTime { get; set; }
[JsonProperty(PropertyName = "menu_items")]
public List