如何从AngularJS调用PHP文件

时间:2019-01-22 11:42:09

标签: javascript php angularjs symfony

我正在尝试将支付网关集成到Web应用程序中。我正在尝试调用重定向到另一个页面的php文件。我需要向它传递一些值,然后它应该重定向到支付网关页面。

这就是我在做什么:

<form name="payBillForm" id="payBillFormId" ng-submit="paymentGateway()">
 <div class="input-group"  ng-class="{'has-error': amountEnteredInvalid}" >
          <span class="input-group-addon"> <i class="fa fa-rupee"></i>
          </span>
          <input type="text" class="form-control" 
          ng-change="testAmountValidity()"
          ng-disabled="isPaymentComplete" ng-model="amountPayingNow" >
         <button class="btn btn-info" type="submit">Pay</button>
        </div>
</form>

控制器:

let formName = document.getElementById('payBillFormId');

let paymentFormData = new FormData(formName);
paymentFormData.append("amount", $scope.amountPayingNow);
paymentFormData.append("email", $scope.payEmailId);
paymentFormData.append("mobile_no", $scope.payContactNo);
paymentFormData.append("invoice", 234);
paymentFormData.append("invoice_amount", $scope.amountPayingNow);


$http({
    method: "POST",
        url: '../PaymentGateway/index.php',
        data: paymentFormData,
        ContentType: false

}).then(function successCallback(response) {
  console.log(response, "Payrespo");
});

在控制台的响应中,我得到:

"<br />↵<b>Notice</b>:  Undefined index: invoice_amt in <b>C:\xampp\htdocs\myworkspace\AMS\apartment-management-system\PaymentGateway\index.php</b> on line <b>15</b><br />

PHP:

    <?php
require_once('fonepaisa.php'); 
 $invoice_amt = $_REQUEST['invoice_amt'];
 $amount = $_REQUEST['amount'];
 $email = $_REQUEST['email'];
 $mobile_no = $_REQUEST['mobile_no'];
 //$invoice = $_REQUEST['invoice'];

fonepaisa_forward(array(

            'id'=>'FPTEST',
            'merchant_id'=>'FPTEST',
            'merchant_display'=>'fonePaisa Test Merchant',
            'invoice_amt' => "$invoice_amt",
            'amount' => "$amount",
            'email'=> "$email",
            'mobile_no'=> "$mobile_no",
            'callback_url'=>'http://localhost/myworkspace/AMS/apartment-management-system/PaymentGateway/confirm.php',
            'callback_failure_url'=>'http://localhost/myworkspace/AMS/apartment-management-system/PaymentGateway/cancel.php',
            'invoice'=>'FPORDER'.rand(1,100000000),
            'api_key'=>'08Z1782051U62BY9OUGW4XM67GF2004',
            'private_key'=>'file://C:\xampp\htdocs\myworkspace\AMS\apartment-management-system\PaymentGateway\priv.pem',
            'public_key'=>'',
            'is_live_env'=>'N' //The value should be changed to 'Y' when one wants to move to production
        ));
exit
?>

1 个答案:

答案 0 :(得分:1)

您的HTML和JS代码不包含POST请求的任何'invoice_amt'值! 我认为您 invoice_amout 而不是 invoice_amt

尝试将您的.theme-1 { .primary { background: lightblue; } .secondary { background: green; } .accent { background: pink; } .warn { background: red; } } .theme-2 { .primary { background: brown; } .secondary { background: grey; } .accent { background: yellow; } .warn { background: darkred; } } .theme-3 { .primary { background: steelblue; } .secondary { background: lightgreen; } .accent { background: salmon; } .warn { background: plum; } } 替换为Dim Result As Long Dim rng As range Dim rnng As range Set rng = ThisWorkbook.Worksheets("Sheet1").range("N2:N296") Set rnng= ThisWorkbook.Worksheets("Sheet1").range("D2:D296") Result = Application.Index(rnng, Application.Match(Application.Max(rng), rng, 0)) [B3] = Result