【发布时间】:2019-05-07 07:14:36
【问题描述】:
我在我们的网站上使用 Authorize.net PHP SDK 进行信用卡支付。目前我正在向客户的名字、姓氏、地址、邮编、城市、州、国家和电子邮件等信息发送客户账单。 我还需要发送客户 IP 地址。请提出解决方案。 当前代码的一部分如下所示:
public function authorize_card($data) {
// Create the payment data for a credit card
$creditCard = new AnetAPI\CreditCardType();
$creditCard->setCardNumber($data['card_no']);
$creditCard->setExpirationDate($data['card_exp']);
$creditCard->setCardCode($data['card_cvc']);
$paymentCreditCard = new AnetAPI\PaymentType();
$paymentCreditCard->setCreditCard($creditCard);
//create a transaction
$transactionRequestType = new AnetAPI\TransactionRequestType();
$transactionRequestType->setTransactionType("authCaptureTransaction");
$transactionRequestType->setAmount($data['amount']);
$transactionRequestType->setPayment($paymentCreditCard);
$billto = new AnetAPI\CustomerAddressType();
$billto->setFirstName($data['bill_fname']);
$billto->setLastName($data['bill_lname']);
$billto->setAddress($data['bill_address']);
$billto->setCity($data['bill_city']);
$billto->setState($data['bill_state']);
$billto->setZip($data['bill_zip']);
$billto->setCountry($data['bill_country']);
$bill_response = $transactionRequestType->setBillTo($billto);
$request = new AnetAPI\CreateTransactionRequest();
$request->setMerchantAuthentication($this->auth);
$request->setRefId($this->refId);
$request->setTransactionRequest($transactionRequestType);
$controller = new AnetController\CreateTransactionController($request);
$response = $controller->executeWithApiResponse($this->api_mode);
if ($response != null) {
$tresponse = $response->getTransactionResponse();
if ($tresponse != null && ($tresponse->getResponseCode() == 1 || $tresponse->getResponseCode() == 253)) {
$response_array = array();
$response_array['auth_code'] = $tresponse->getAuthCode();
$response_array['auth_transaction_id'] = $tresponse->getTransId();
return $response_array;
} else {
$errors = $tresponse->geterrors();
if (is_array($errors) && !empty($errors)) {
return $errors[0]->geterrorText();
} else {
$message = $response->getMessages()->getMessage();
return $message[0]->getText();
}
}
} else {
return "Charge Credit card Null response returned";
}
}
【问题讨论】:
-
祝你好运获得一个合理的 IP 地址,甚至在某些地区被允许这样做。这可能是重复的:stackoverflow.com/q/3003145/1531971
-
您发布的链接是用于在 php 中获取客户 ip 地址。我的问题是关于在 authorizeNet php sdk 中设置客户 IP 地址以将其作为客户信息发送。
-
community.developer.authorize.net/t5/Integration-and-Testing/…(看来你应该向你的网络应用询问这个。)
-
其实他们并不那么支持。
标签: php authorize.net