这是我用来在我的 Braintree 帐户中创建子商户帐户的代码,用于在我的本地机器上使用邮递员进行测试。sub_merchant 创建调用将来自使用自定义表单的 Android 或 iOS 设备。在本地,此代码与邮递员一起工作正常,如果有任何与我们从返回的$result对象传递给 Braintree 的任何字段相关联并以简洁的方式显示回客户端屏幕的任何字段,任何人都可以建议我如何捕获错误消息?
<?php
include("../connection.php");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'braintree_environment_settings.php';
$dataReceived = json_decode(file_get_contents('php://input'), true);
//var_dump($dataReceived);
if((json_last_error() == JSON_ERROR_NONE))
{
// code to handle iOS call
$firstName = $dataReceived['firstName'];
$lastName = $dataReceived['lastName'];
$email = $dataReceived['email'];
$dateOfBirth = $dataReceived['dateOfBirth'];
$streetAddress = $dataReceived['streetAddress'];
$locality = $dataReceived['locality'];
$region = $dataReceived['region'];
$postalCode = $dataReceived['postalCode'];
$accountNumber = $dataReceived['accountNumber'];
$routingNumber = $dataReceived['routingNumber'];
}
else {
// code to handle Android call
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
$dateOfBirth = $_POST['dateOfBirth'];
$streetAddress = $_POST['streetAddress'];
$locality = $_POST['locality'];
$region = $_POST['region'];
$postalCode = $_POST['postalCode'];
$accountNumber = $_POST['accountNumber'];
$routingNumber = $_POST['routingNumber'];
}
$merchantAccountParams = [
'individual' => [
'firstName' => $firstName,
'lastName' => $lastName,
'email' => $email,
'dateOfBirth' => $dateOfBirth,
'address' => [
'streetAddress' => $streetAddress,
'locality' => $locality,
'region' => $region,
'postalCode' => $postalCode
]
],
'funding' => [
'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK,
'accountNumber' => $accountNumber,
'routingNumber' => $routingNumber
],
'tosAccepted' => true,
'masterMerchantAccountId' => 'zeefasys'
// 'id' => "Praveens_caffe_store"
];
$result = Braintree_MerchantAccount::create($merchantAccountParams);
$responseData = array('Merchant_ID' => $result->merchantAccount->id, "message" => "Success");
header('Content-type: application/json');
echo json_encode($responseData);
?>