2017-08-24 64 views

回答

3

有些頭痛後,並試圖我發現了一個很簡單的方法來解決,通過沙沙支付雲功能:

使用request-js,而不是建在圖書館,我只需要編譯選項對象在request.post()方法使用如下:

const swishOptions = { 
url: 'LINK TO SWISH SERVER', 
json: true, 
pfx: fs.readFileSync('cert.p12'), 
passphrase: 'swish', 
body: swishRequestBody 
} 

的cert.p12文件應該放在山姆e文件夾作爲index.js並將與函數一起上傳。

rq.post(swishOptions, (err, res) => { 
      if (err){ 
        console.log('payment creation error: ' + JSON.stringify(err)) 
        reject(err) 
       } 
      if (res){ 
        console.log('Payment-token: ' + res.headers.paymentrequesttoken) 
       } 
     }); 

的被檢體內對象應包含在Swish API指定的所有字段,使用的console.log()讀取來自沙沙服務器錯誤的消息。