ios第三方支付 微信篇(含本地簽名)

2021-08-15 11:00:34 字數 1515 閱讀 3120

//統一下單介面

@」1)專案配置

設定專案屬性中的url schemes

return yes;
}

`

}

//新增key欄位

nslog(@"%@",contentstring);

//得到md5 sign簽名

nsstring *md5sign =[self md5:contentstring];

//輸出debug info

return md5sign;

`-(nsstring ) md5:(nsstring )str

];[session post:@"" parameters:send constructingbodywithblock:^(id_nonnull formdata) progress:^(nsprogress * _nonnull uploadprogress) success:^(nsurlsessiondatatask * _nonnull task, id _nullable responseobject)

} }

} failure:^(nsurlsessiondatatask * _nullable task, nserror * _nonnull error) ];我們拿到了prepayid後進行二次簽名

nsstring *package, *time_stamp, *nonce_str;

//設定支付引數

time_t now;

time(&now);

time_stamp = [nsstring stringwithformat:@」%ld」, now];//時間戳

nonce_str = [self md5:time_stamp];//隨機字串(直接用時間戳來生成就可以了)

package         = @"sign=wxpay";

nsmutabledictionary *signparams = [nsmutabledictionary dictionary];//用於二次簽名的引數

[signparams setobject: mch_id forkey:@"partnerid"];

[signparams setobject: nonce_str forkey:@"noncestr"];

[signparams setobject: package forkey:@"package"];

[signparams setobject: time_stamp forkey:@"timestamp"];

[signparams setobject: prepayid forkey:@"prepayid"];

req.sign                = [self createmd5sign:signparams];//二次簽名

[wxapi sendreq:req];`

demo—-

第三方支付 之微信支付

需要注意的一點是,在開發的過程中,由於使用的是mvc的架構,位址以 xx xx 結束。導致一直無法 成功。後來把 頁面改為 xx.aspx 就可以了。步驟是 public partial class weixinback system.web.ui.page 支付結果通知 處理類 public cl...

ios 第三方支付

1.封裝訂單模型 alixpayorder order alixpayorder alloc init 生成訂單描述 nsstring orderspec order description 2.簽名 idsigner creatersadatasigner 私鑰key 傳入訂單描述 進行 簽名 n...

iOS微信第三方登入

2.匯入對應的庫 置應用間的跳轉 4.就說明沒有針對ios9 增加白名單。2 單例介面 import wxapi.h inte ce uiresponder wxapidelegate property strong nonatomic nsstring access token property ...