本文整理汇总了PHP中Merchant::curl_helper方法的典型用法代码示例。如果您正苦于以下问题:PHP Merchant::curl_helper方法的具体用法?PHP Merchant::curl_helper怎么用?PHP Merchant::curl_helper使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Merchant
的用法示例。
在下文中一共展示了Merchant::curl_helper方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _process_return
public function _process_return()
{
$action = $this->CI->input->get('action', TRUE);
if ($action === FALSE) {
return new Merchant_response('failed', 'invalid_response');
}
if ($action === 'success') {
return new Merchant_response('return', '', $_POST['txn_id']);
}
if ($action === 'cancel') {
return new Merchant_response('failed', 'payment_cancelled');
}
if ($action === 'ipn') {
// generate the post string from _POST
$post_string = 'cmd=_notify-validate&' . http_build_query($_POST);
$response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $post_string);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$memo = $this->CI->input->post('memo');
if (strpos("VERIFIED", $response['data']) !== FALSE) {
// Valid IPN transaction.
return new Merchant_response('authorized', $memo, $_POST['txn_id'], (string) $_POST['mc_gross']);
} else {
// Invalid IPN transaction
return new Merchant_response('declined', $memo);
}
}
}
示例2: _process
public function _process($params)
{
$data = array('VPSProtocol' => '2.23', 'TxType' => 'PAYMENT', 'Vendor' => $this->settings['vendor'], 'VendorTxCode' => $params['transaction_id'], 'Description' => $params['reference'], 'Amount' => sprintf('%01.2f', $params['amount']), 'Currency' => $params['currency_code'], 'CardHolder' => $params['card_name'], 'CardNumber' => $params['card_no'], 'CV2' => $params['csc'], 'CardType' => strtoupper($params['card_type']), 'ExpiryDate' => $params['exp_month'] . $params['exp_year'] % 100, 'AccountType' => 'E', 'ApplyAVSCV2' => 2);
if ($data['CardType'] == 'MASTERCARD') {
$data['CardType'] = 'MC';
}
if (!empty($params['card_issue'])) {
$data['IssueNumber'] = $params['card_issue'];
}
if (!empty($params['start_month']) and !empty($params['start_year'])) {
$data['StartDate'] = $params['start_month'] . $params['start_year'] % 100;
}
$response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $data);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
// convert weird ini-type format to a useful array
$response_array = explode("\n", $response['data']);
foreach ($response_array as $key => $value) {
unset($response_array[$key]);
$line = explode('=', $value, 2);
$response_array[trim($line[0])] = isset($line[1]) ? trim($line[1]) : '';
}
if (empty($response_array['Status'])) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($response_array['Status'] == 'OK') {
return new Merchant_response('authorized', $response_array['StatusDetail'], $response_array['VPSTxId'], (double) $params['amount']);
} else {
return new Merchant_response('declined', $response_array['StatusDetail']);
}
}
示例3: _process
public function _process($params)
{
$request = array('amount' => (int) ($params['amount'] * 100), 'card' => $params['token'], 'currency' => strtolower($params['currency_code']), 'description' => $params['reference']);
$response = Merchant::curl_helper(self::API_ENDPOINT . '/v1/charges', $request, $this->settings['api_key']);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$data = json_decode($response['data']);
if (isset($data->error)) {
return new Merchant_response('declined', $data->error->message);
} else {
return new Merchant_response('authorized', '', $data->id, $data->amount / 100);
}
}
示例4: _process
public function _process($params)
{
$card_name = explode(' ', $params['card_name'], 2);
$data = array('USER' => $this->settings['username'], 'PWD' => $this->settings['password'], 'SIGNATURE' => $this->settings['signature'], 'VERSION' => '65.1', 'METHOD' => 'doDirectPayment', 'PAYMENTACTION' => 'Sale', 'AMT' => sprintf('%01.2f', $params['amount']), 'CURRENCYCODE' => $params['currency_code'], 'ACCT' => $params['card_no'], 'EXPDATE' => $params['exp_month'] . $params['exp_year'], 'CVV2' => $params['csc'], 'IPADDRESS' => $this->CI->input->ip_address(), 'FIRSTNAME' => $card_name[0], 'LASTNAME' => isset($card_name[1]) ? $card_name[1] : '');
if (isset($params['card_type'])) {
$data['CREDITCARDTYPE'] = ucfirst($params['card_type']);
if ($data['CREDITCARDTYPE'] == 'Mastercard') {
$data['CREDITCARDTYPE'] = 'MasterCard';
}
}
if (isset($params['card_issue'])) {
$data['ISSUENUMBER'] = $params['card_issue'];
}
if (isset($params['start_month']) and isset($params['start_year'])) {
$data['STARTDATE'] = $params['start_month'] . $params['start_year'];
}
if (isset($params['address'])) {
$data['STREET'] = $params['address'];
}
if (isset($params['city'])) {
$data['CITY'] = $params['city'];
}
if (isset($params['region'])) {
$data['STATE'] = $params['region'];
}
if (isset($params['postcode'])) {
$data['ZIP'] = $params['postcode'];
}
if (isset($params['country'])) {
$data['COUNTRYCODE'] = strtoupper($params['country']);
}
// send request to paypal
$response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $data);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$response_array = array();
parse_str($response['data'], $response_array);
if (empty($response_array['ACK'])) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($response_array['ACK'] == 'Success' or $response_array['ACK'] == 'SuccessWithWarning') {
return new Merchant_response('authorized', '', $response_array['TRANSACTIONID'], (double) $response_array['AMT']);
} elseif ($response_array['ACK'] == 'Failure' or $response_array['ACK'] == 'FailureWithWarning') {
return new Merchant_response('declined', $response_array['L_ERRORCODE0'] . ': ' . $response_array['L_LONGMESSAGE0']);
} else {
return new Merchant_response('failed', 'invalid_response');
}
}
示例5: _process
public function _process($params)
{
$date_expiry = $params['exp_month'];
$date_expiry .= $params['exp_year'] % 100;
$request = '<Txn>' . '<PostUsername>' . $this->settings['username'] . '</PostUsername>' . '<PostPassword>' . $this->settings['password'] . '</PostPassword>' . '<CardHolderName>' . htmlspecialchars($params['card_name']) . '</CardHolderName>' . '<CardNumber>' . $params['card_no'] . '</CardNumber>' . '<Amount>' . sprintf('%01.2f', $params['amount']) . '</Amount>' . '<DateExpiry>' . $date_expiry . '</DateExpiry>' . '<Cvc2>' . $params['csc'] . '</Cvc2>' . '<InputCurrency>' . $params['currency_code'] . '</InputCurrency>' . '<TxnType>Purchase</TxnType>' . '<TxnId>' . $params['transaction_id'] . '</TxnId>' . '<MerchantReference>' . $params['reference'] . '</MerchantReference>' . '<EnableAddBillCard>' . (int) $this->settings['enable_token_billing'] . '</EnableAddBillCard>' . '</Txn>';
$response = Merchant::curl_helper(self::PROCESS_URL, $request);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$xml = simplexml_load_string($response['data']);
if (!isset($xml->Success)) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($xml->Success == '1') {
return new Merchant_response('authorized', (string) $xml->HelpText, (string) $xml->DpsTxnRef, (string) $xml->Transaction->Amount);
} else {
return new Merchant_response('declined', (string) $xml->HelpText, (string) $xml->DpsTxnRef);
}
}
示例6: _process_return
public function _process_return()
{
if (($payment_code = $this->CI->input->get_post('AccessPaymentCode')) === FALSE) {
return new Merchant_response('failed', 'invalid_response');
}
$data = array('CustomerID' => $this->settings['customer_id'], 'UserName' => $this->settings['username'], 'AccessPaymentCode' => $_REQUEST['AccessPaymentCode']);
$response = Merchant::curl_helper(self::PROCESS_RETURN_URL . '?' . http_build_query($data));
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$xml = simplexml_load_string($response['data']);
if (!isset($xml->TrxnStatus)) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($xml->TrxnStatus == 'True') {
return new Merchant_response('authorized', '', (string) $xml->TrxnNumber, (double) $xml->ReturnAmount);
} else {
return new Merchant_response('declined', (string) $xml->TrxnResponseMessage, (string) $xml->TrxnNumber);
}
}
示例7: _process
public function _process($params)
{
// eway thows HTML formatted error if customerid is missing
if (empty($this->settings['customer_id'])) {
return new Merchant_response('failed', 'Missing Customer ID!');
}
$request = '<ewaygateway>' . '<ewayCustomerID>' . $this->settings['customer_id'] . '</ewayCustomerID>' . '<ewayTotalAmount>' . sprintf('%01d', $params['amount'] * 100) . '</ewayTotalAmount>' . '<ewayCustomerInvoiceDescription>' . $params['reference'] . '</ewayCustomerInvoiceDescription>' . '<ewayCustomerInvoiceRef>' . $params['transaction_id'] . '</ewayCustomerInvoiceRef>' . '<ewayCardHoldersName>' . $params['card_name'] . '</ewayCardHoldersName>' . '<ewayCardNumber>' . $params['card_no'] . '</ewayCardNumber>' . '<ewayCardExpiryMonth>' . $params['exp_month'] . '</ewayCardExpiryMonth>' . '<ewayCardExpiryYear>' . $params['exp_year'] % 100 . '</ewayCardExpiryYear>' . '<ewayTrxnNumber>' . $params['transaction_id'] . '</ewayTrxnNumber>' . '<ewayCVN>' . $params['csc'] . '</ewayCVN>' . '<ewayCustomerFirstName></ewayCustomerFirstName>' . '<ewayCustomerLastName></ewayCustomerLastName>' . '<ewayCustomerEmail></ewayCustomerEmail>' . '<ewayCustomerAddress></ewayCustomerAddress>' . '<ewayCustomerPostcode></ewayCustomerPostcode>' . '<ewayOption1></ewayOption1>' . '<ewayOption2></ewayOption2>' . '<ewayOption3></ewayOption3>' . '</ewaygateway>';
$response = Merchant::curl_helper($this->settings['test_mode'] ? self::PROCESS_URL_TEST : self::PROCESS_URL, $request);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$xml = simplexml_load_string($response['data']);
if (!isset($xml->ewayTrxnStatus)) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($xml->ewayTrxnStatus == 'True') {
return new Merchant_response('authorized', (string) $xml->ewayTrxnError, (string) $xml->ewayTrxnNumber, (double) $xml->ewayReturnAmount / 100);
} else {
return new Merchant_response('declined', (string) $xml->ewayTrxnError);
}
}
示例8: _process_return
public function _process_return()
{
if ($this->CI->input->get('result', TRUE) === FALSE) {
return new Merchant_response('failed', 'invalid_response');
}
// validate dps response
$request = '<ProcessResponse>' . '<PxPayUserId>' . $this->settings['user_id'] . '</PxPayUserId>' . '<PxPayKey>' . $this->settings['key'] . '</PxPayKey>' . '<Response>' . $this->CI->input->get('result', TRUE) . '</Response>' . '</ProcessResponse>';
$response = Merchant::curl_helper(self::PROCESS_URL, $request);
if (!empty($response['error'])) {
return new Merchant_response('failed', $response['error']);
}
$xml = simplexml_load_string($response['data']);
if (!isset($xml->Success)) {
return new Merchant_response('failed', 'invalid_response');
} elseif ($xml->Success == '1') {
return new Merchant_response('authorized', (string) $xml->ResponseText, (string) $xml->DpsTxnRef, (double) $xml->AmountSettlement);
} else {
return new Merchant_response('declined', (string) $xml->ResponseText, (string) $xml->DpsTxnRef);
}
}