0

我正在尝试将 PayFort 集成到离子应用程序中。没有可用于 ionic 的 SDK,因此我正在集成重定向模式,我们只需从供应商处打开一个网页。

在离子上使用 HttpClient

let data = JSON.stringify({
  'access_code' : 'xxxxxxxx',
  'amount' : '10000',
  'command' : 'AUTHORIZATION',
  'currency' : 'SAR',
  'customer_email' : 'test@payfort.com',
  'language' : 'en',
  'merchant_identifier' : 'xxxxxxxx',
  'merchant_reference' : 'xxxxx-xxxxx-xxxx-xxxxx',
  'payment_option' : 'MASTERCARD',
  'signature' : 'xxxxxxxxxxxxxxxxxxxxxx' });


return new Promise((resolve, reject) => {
this.http
.post(apiUrl,data,options)
.subscribe(
  data => {
    console.log("Success: ",data);
    resolve(data);
  },
  error=>{
    console.log("Error:",error);
    reject(error);
  }
);
})

执行此代码后,PayFort 返回“参数缺失”错误。

相同的参数适用于 PHP 和 HTML。

还尝试了以下格式的参数

let dataString = 'access_code=xxxxxxxxxxx&amount=10000&command=AUTHORIZATION&currency=SAR&customer_email=test@payfort.com&language=en&merchant_identifier=xxxxxxx&merchant_reference=xxxxxxxxxx&payment_option=MASTERCARD&signature=xxxxxxxx'

let dataStringInJSON = {'access_code=xxxxxxxxxxx&amount=10000&command=AUTHORIZATION&currency=SAR&customer_email=test@payfort.com&language=en&merchant_identifier=xxxxxxx&merchant_reference=xxxxxxxxxx&payment_option=MASTERCARD&signature=xxxxxxxx'}


let dataJSON = {
  'access_code' : 'xxxxxxxx',
  'amount' : '10000',
  'command' : 'AUTHORIZATION',
  'currency' : 'SAR',
  'customer_email' : 'test@payfort.com',
  'language' : 'en',
  'merchant_identifier' : 'xxxxxxxx',
  'merchant_reference' : 'xxxxx-xxxxx-xxxx-xxxxx',
  'payment_option' : 'MASTERCARD',
  'signature' : 'xxxxxxxxxxxxxxxxxxxxxx' }
4

1 回答 1

0

Please try to send JSON object instead of JSON string.

let data = Your JSON object
于 2018-04-20T13:14:07.230 回答