• Add an account

To add a user account, use the following syntax, and follow the prompts to give the account a password and identifiable characteristics such as a full name, phone number, etc.

1
sudo adduser username
  • To delete a user account and its primary group, use the following syntax:

Deleting an account does not remove their respective home folder. It is up to you whether or not you wish to delete the folder manually or keep it according to your desired retention policies. Remember, any user added later on with the same UID/GID as the previous owner will now have access to this folder if you have not taken the necessary precautions. You may want to change these UID/GID values to something more appropriate, such as the root account, and perhaps even relocate the folder to avoid future conflicts:

1
sudo deluser username
  • To temporarily lock or unlock a user account, use the following syntax, respectively:
1
sudo passwd -l username
1
sudo passwd -u username

Introduction

Since I add a localizable file to my project, I found this problem: the first time I load my app, I see the localised string of my key in a label, the second time I load the app, the key string in a label, the next time I load the app, everything is fine again.

Solution

the issue is that some vender plugins include a localizable.file again, and that my project include the same name file, so when I launch the app either of these two localizable string files were picked up.

So, u can rename your localizable file name, like MyString.string, and make it localization. use NSLocalizedStringFromTable to localize it.

1
NSLocalizedStringFromTable(@"Key", @"MyString", nil)

IE Array no indexOf function

今天在开发写Js时候才发现,使用了indexOf地方,在IE浏览器下面都挂了,查了下,才发现,原来是IE下面Array没有indexOf这个方法。

Solve way:

1
2
3
4
5
6
7
function(obj, start){
  for (var i = (start || 0), j = this.length; i < j; i++) {
    if (this[i] === obj)
      return i;
  }
  return -1;
}

Requirement

在现有Rails项目中,扩展第三方支付功能;

Preparation

  • 认知第三支付接口的业务流程

    估计很大部分童鞋在接到该功能任务情况下,都会选择去查找实现第三方支付功能的gem,然后直接一个劲地开始 coding coding and coding !!! 导致在开发过程遇到bug或者问题都无从下手,加上支付gem的文档普遍写得不够详细,那更加雪上加霜。所以建议弄清楚第三方支付接口业务流程后,再去选择合适的gem(关于支付gem在下面会有简要介绍)。

    Tenpay(财付通)为例子:

    wap支付流程

    wap支付流程中,用户在财付通WAP APP中购买业务,通过财付通WAP支付平台进行支付。典型业务流程如下:

    Wap

    通知查询/订单查询流程(按需要把,其实这个功能大部分情况都不怎么用到)

    通知查询/订单查询是指财付通APP向财付通系统发送查询请求,并同步等待财付通系统处理完毕后返回的响应数据。数据交互是财付通APP与财付通服务器直接通信。

    Tenpay

    后台通知流程 (这个比较重点,简单说就是有sync与async两种requests)

    后台通知是指财付通系统主动向财付通APP发送通知数据,并同步等待财付通APP处理完毕后返回的响应数据。数据交互是财付通服务器与财付通APP直接通信,一般请求采用http的get或post,应答用字符串格式。

    Tenpay

    更多文档可以直接去官网查看:

    Tenpay Doc

    Alipay Doc

  • 申请需求的Key(申请key各位童鞋们自己去搞定,这里就不多介绍)

    Tenpay 需要 SPID KEY Tenpay

    Alipay 需要 Account Key Email Alipay

Coding

Read pay_fu Readme

Testing

  • Tenpay

    http://open.tenpay.com/wiki/index.php/%E6%B5%8B%E8%AF%95

  • Alipay

    说到Alipay的测试,我就忍不住吐槽一番了,居然连测试帐号与沙箱环境都没提供,那好把! 乖乖的一分钱一分钱的去测试,然后通过错误日记提示错误,通过模拟request测试直到成功

Payment gems

  • activemerchant_patch_for_china

    简介: A rails plugin to add an active_merchant patch for china online payment platform including alipay (支付宝), 99bill (快钱) and tenpay (财付通)

    github: https://github.com/flyerhzm/activemerchant_patch_for_china

    优点: 支持支付方式多

    缺点:目前已停止更新, 多样性的支付方式必定伴随着定制性与轻巧性的不足

  • pay_fu

    简介:a rails payment engine that supports both alipay and paypal

    github: https://github.com/transist/pay_fu

    优点: 轻巧,目前仍处于更新ing

    缺点: 支持支付方式少,某些参数配置依赖于activemerchant_patch_for_china,无sync request handler function,async request handler function定制性难

    PS: (目前正对pay_fu补充Tenpay feature,并增加sync request与async request handler function 的定制)