Example #1
0
 void onPay()
 {
     PayInfo payInfo = new PayInfo();
     payInfo.PropID = "0001";
     payInfo.PriceInCurrency = 100;
     payInfo.PropName = "10个钻石(1元)";
     GSDK.Instance.StartPayAsync(payInfo, (payResult) => {
         if (payResult.Status == EPayResultStatus.Succeed)
         {
             // 支付成功后,可以向服务器验证此订单(也可以直接发货)
             // 建议此处将订单存入本地文件,若游戏闪退,可用验证接口自动补单
             GSDK.Instance.StartCheckOrderAsync(payResult.OrderIDStr, checkOrderResult =>{
                 if (checkOrderResult.Status == GSDKUnityLib.Pay.CheckOrder.ECheckOrderResultStatus.Paid)
                     Debug.Log("验证成功,发货: " + payInfo.PropID);
                 else
                     Debug.LogWarning(string.Format("验证失败 {0} {1}", checkOrderResult.Status, (int)checkOrderResult.Status));
             });
         }
         else if (payResult.Status == EPayResultStatus.Cancelled)
         {
             Debug.Log("玩家放弃支付了");
         }
         else
         {
             Debug.Log(string.Format("支付失败 {0} {1} {2}", payResult.Status, payResult.InfoStr, payResult.InternalErrorStr));
         }
     });
 }
Example #2
0
        private string DoReplaceCode(string code, Person p, PayInfo pi = null, EmailQueueTo emailqueueto = null)
        {
            if (code.StartsWith("<style"))
                return code;
            switch (code.ToLower())
            {
                case "{address}":
                    return p.PrimaryAddress;

                case "{address2}":
                    if (p.PrimaryAddress2.HasValue())
                        return "<br>" + p.PrimaryAddress2;
                    return "";

                case "{amtdue}":
                    if (pi != null)
                        return pi.AmountDue.ToString2("c");
                    break;

                case "{amtpaid}":
                    if (pi != null)
                        return pi.AmountPaid.ToString2("c");
                    break;

                case "{amount}":
                    if (pi != null)
                        return pi.Amount.ToString2("c");
                    break;

                case "{barcode}":
                    return $"<img src='{db.ServerLink("/Track/Barcode/" + p.PeopleId)}' />";

                case "{campus}":
                    return p.CampusId != null ? p.Campu.Description : "No Campus Specified";

                case "{cellphone}":
                    return p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record";

                case "{city}":
                    return p.PrimaryCity;

                case "{csz}":
                    return Util.FormatCSZ(p.PrimaryCity, p.PrimaryState, p.PrimaryZip);

                case "{country}":
                    return p.PrimaryCountry;

                case "{createaccount}":
                    if (emailqueueto != null)
                        return CreateUserTag(emailqueueto);
                    break;

                case "{church}":
                    return db.Setting("NameOfChurch", "Set this in NameOfChurch setting");

                case "{cmshost}":
                    return db.ServerLink();

                case "{dob}":
                    return p.DOB;

                case "{emailhref}":
                    if (emailqueueto != null)
                        return db.ServerLink("/EmailView/" + emailqueueto.Id);
                    break;

                case "{first}":
                    return p.PreferredName.Contains("?") || p.PreferredName.Contains("unknown", true) ? "" : p.PreferredName;

                case "{fromemail}":
                    return from.Address;

                case "{homephone}":
                    return p.HomePhone.HasValue() ? p.HomePhone.FmtFone() : "no homephone on record";

                case "{last}":
                    return p.LastName;

                case "{name}":
                    return p.Name.Contains("?") || p.Name.Contains("unknown", true) ? "" : p.Name;

                case "{nextmeetingtime}":
                    if (emailqueueto != null)
                        return NextMeetingDate(code, emailqueueto);
                    break;
                case "{nextmeetingtime0}":
                    if (emailqueueto != null)
                        return NextMeetingDate0(code, emailqueueto);
                    break;

                case "{occupation}":
                    return p.OccupationOther;

                case "{orgname}":
                case "{org}":
                    return GetOrgInfo(emailqueueto).Name;

                case "{orgmembercount}":
                    return GetOrgInfo(emailqueueto).Count;

                case "{paylink}":
                    if (pi != null && pi.PayLink.HasValue())
                        return $"<a href=\"{pi.PayLink}\">Click this link to make a payment and view your balance.</a>";
                    break;

                case "{peopleid}":
                    return p.PeopleId.ToString();

                case "{salutation}":
                    if (emailqueueto != null)
                        return db.GoerSupporters.Where(ee => ee.Id == emailqueueto.GoerSupportId).Select(ee => ee.Salutation).SingleOrDefault();
                    break;

                case "{state}":
                    return p.PrimaryState;

                case "{email}":
                case "{toemail}":
                    if (ListAddresses.Count > 0)
                        return ListAddresses[0].Address;
                    break;

                case "{today}":
                    return DateTime.Today.ToShortDateString();

                case "{title}":
                    if (p.TitleCode.HasValue())
                        return p.TitleCode;
                    return p.ComputeTitle();

                case "{track}":
                    if (emailqueueto != null)
                        return emailqueueto.Guid.HasValue ?
                            $"<img src=\"{db.ServerLink("/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring())}\" />"
                            : "";
                    break;

                case "{unsubscribe}":
                    if (emailqueueto != null)
                        return UnSubscribeLink(emailqueueto);
                    break;

                default:
                    if (emailqueueto == null)
                        emailqueueto = new EmailQueueTo()
                        {
                            PeopleId = p.PeopleId,
                            OrgId = db.CurrentOrgId0
                        };

                    if (code.StartsWith("{addsmallgroup:", StringComparison.OrdinalIgnoreCase))
                        return AddSmallGroup(code, emailqueueto);

                    if (code.StartsWith("{extra", StringComparison.OrdinalIgnoreCase))
                        return ExtraValue(code, emailqueueto);

                    if (registerLinkRe.IsMatch(code))
                        return RegisterLink(code, emailqueueto);

                    if (registerHrefRe.IsMatch(code))
                        return RegisterLinkHref(code, emailqueueto);

                    if (registerTagRe.IsMatch(code))
                        return RegisterTag(code, emailqueueto);

                    if (rsvpLinkRe.IsMatch(code))
                        return RsvpLink(code, emailqueueto);

                    if (sendLinkRe.IsMatch(code))
                        return SendLink(code, emailqueueto);

                    if (code.StartsWith("{orgextra:", StringComparison.OrdinalIgnoreCase))
                        return OrgExtra(code, emailqueueto);

                    if (code.StartsWith("{orgmember:", StringComparison.OrdinalIgnoreCase))
                        return OrgMember(code, emailqueueto);

                    if (code.StartsWith("{orgbarcode"))
                        return OrgBarcode(code, emailqueueto);

                    if (code.StartsWith("{smallgroup:", StringComparison.OrdinalIgnoreCase))
                        return SmallGroup(code, emailqueueto);

                    if (regTextRe.IsMatch(code))
                        return RegText(code, emailqueueto);

                    if (code.StartsWith("{smallgroups", StringComparison.OrdinalIgnoreCase))
                        return SmallGroups(code, emailqueueto);

                    if (supportLinkRe.IsMatch(code))
                        return SupportLink(code, emailqueueto);

                    if (masterLinkRe.IsMatch(code))
                        return MasterLink(code, emailqueueto);

                    if (volReqLinkRe.IsMatch(code))
                        return VolReqLink(code, emailqueueto);

                    if (volSubLinkRe.IsMatch(code))
                        return VolSubLink(code, emailqueueto);

                    if (voteLinkRe.IsMatch(code))
                        return VoteLink(code, emailqueueto);

                    break;
            }

            return code;
        }
Example #3
0
        private string DoReplaceCode(string code, Person p, PayInfo pi, EmailQueueTo emailqueueto)
        {
            switch (code.ToLower())
            {
                case "{address}":
                    return p.PrimaryAddress;

                case "{address2}":
                    if (p.PrimaryAddress2.HasValue())
                        return "<br>" + p.PrimaryAddress2;
                    return "";

                case "{amtdue}":
                    if (pi != null)
                        return (pi.Amount - pi.AmountPaid).ToString2("c");
                    break;

                case "{barcode}":
                    return string.Format("<img src='{0}' />", Util.URLCombine(db.CmsHost, "/Track/Barcode/" + emailqueueto.PeopleId));

                case "{campus}":
                    return p.CampusId != null ? p.Campu.Description : "No Campus Specified";

                case "{cellphone}":
                    return p.CellPhone.HasValue() ? p.CellPhone.FmtFone() : "no cellphone on record";

                case "{city}":
                    return p.PrimaryCity;

                case "{csz}":
                    return Util.FormatCSZ(p.PrimaryCity, p.PrimaryState, p.PrimaryZip);

                case "{country}":
                    return p.PrimaryCountry;

                case "{createaccount}":
                    return CreateUserTag(emailqueueto);

                case "{cmshost}":
                    return db.CmsHost.TrimEnd('/');

                case "{emailhref}":
                    return Util.URLCombine(db.CmsHost, "/EmailView/" + emailqueueto.Id);

                case "{first}":
                    return p.PreferredName.Contains("?") || p.PreferredName.Contains("unknown", true) ? "" : p.PreferredName;

                case "{fromemail}":
                    return from.Address;

                case "{last}":
                    return p.LastName;

                case "{name}":
                    return p.Name.Contains("?") || p.Name.Contains("unknown", true) ? "" : p.Name;

                case "{nextmeetingtime}":
                    return NextMeetingDate(code, emailqueueto);

                case "{occupation}":
                    return p.OccupationOther;

                case "{orgname}":
                    return
                        db.Organizations.Where(oo => oo.OrganizationId == db.CurrentOrgId)
                            .Select(oo => oo.OrganizationName).SingleOrDefault();

                case "{paylink}":
                    if (pi != null && pi.PayLink.HasValue())
                        return "<a href=\"{0}\">payment link</a>".Fmt(pi.PayLink);
                    break;

                case "{peopleid}":
                    return p.PeopleId.ToString();

                case "{saluation}":
                    return db.GoerSupporters.Where(ee => ee.Id == emailqueueto.GoerSupportId).Select(ee => ee.Salutation).SingleOrDefault();

                case "{state}":
                    return p.PrimaryState;

                case "{toemail}":
                    if (ListAddresses.Count > 0)
                        return ListAddresses[0].Address;
                    break;

                case "{today}":
                    return DateTime.Today.ToShortDateString();

                case "{track}":
                    return emailqueueto.Guid.HasValue ? "<img src=\"{0}\" />".Fmt(Util.URLCombine(db.CmsHost, "/Track/Key/" + emailqueueto.Guid.Value.GuidToQuerystring())) : "";

                case "{unsubscribe}":
                    return UnSubscribeLink(emailqueueto);

                default:
                    if (code.StartsWith("{addsmallgroup:", StringComparison.OrdinalIgnoreCase))
                        return AddSmallGroup(code, emailqueueto);

                    if (code.StartsWith("{extra", StringComparison.OrdinalIgnoreCase))
                        return ExtraValue(code, emailqueueto);

                    if (registerLinkRe.IsMatch(code))
                        return RegisterLink(code, emailqueueto);

                    if (registerTagRe.IsMatch(code))
                        return RegisterTag(code, emailqueueto);

                    if (rsvpLinkRe.IsMatch(code))
                        return RsvpLink(code, emailqueueto);

                    if (sendLinkRe.IsMatch(code))
                        return SendLink(code, emailqueueto);

                    if(code.StartsWith("{orgextra:", StringComparison.OrdinalIgnoreCase))
                        return OrgExtra(code, emailqueueto);

                    if (code.StartsWith("{smallgroup:", StringComparison.OrdinalIgnoreCase))
                        return SmallGroup(code, emailqueueto);

                    if (code.StartsWith("{smallgroups", StringComparison.OrdinalIgnoreCase))
                        return SmallGroups(code, emailqueueto); ;

                    if (supportLinkRe.IsMatch(code))
                        return SupportLink(code, emailqueueto);

                    if (volReqLinkRe.IsMatch(code))
                        return VolReqLink(code, emailqueueto);

                    if (volSubLinkRe.IsMatch(code))
                        return VolSubLink(code, emailqueueto);

                    if (voteLinkRe.IsMatch(code))
                        return VoteLink(code, emailqueueto);

                    break;
            }

            return code;
        }