public static function Braintree_TestHelper::submitTrRequest in Commerce Braintree 7
14 calls to Braintree_TestHelper::submitTrRequest()
- Braintree_CreditCardTest::createCreditCardViaTr in braintree_php/tests/integration/CreditCardTest.php
- Braintree_CreditCardTest::updateCreditCardViaTr in braintree_php/tests/integration/CreditCardTest.php
- Braintree_CustomerTest::createCustomerViaTr in braintree_php/tests/integration/CustomerTest.php
- Braintree_CustomerTest::updateCustomerViaTr in braintree_php/tests/integration/CustomerTest.php
- Braintree_TestHelper::createViaTr in braintree_php/tests/TestHelper.php
... See full list
File
- braintree_php/tests/TestHelper.php, line 57
Class
- Braintree_TestHelper
Code
public static function submitTrRequest($url, $regularParams, $trData) {
$curl = curl_init();
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query(array_merge($regularParams, array(
'tr_data' => $trData,
))));
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/x-www-form-urlencoded',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($curl);
curl_close($curl);
preg_match('/Location: .*\\?(.*)/', $response, $match);
return trim($match[1]);
}