本文整理汇总了PHP中Braintree_Transaction::cloneTransaction方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Transaction::cloneTransaction方法的具体用法?PHP Braintree_Transaction::cloneTransaction怎么用?PHP Braintree_Transaction::cloneTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Braintree_Transaction
的用法示例。
在下文中一共展示了Braintree_Transaction::cloneTransaction方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCloneWithValidations
function testCloneWithValidations()
{
$result = Braintree_Transaction::credit(array('amount' => '100.00', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/2011')));
$this->assertTrue($result->success);
$transaction = $result->transaction;
$cloneResult = Braintree_Transaction::cloneTransaction($transaction->id, array('amount' => '123.45'));
$this->assertFalse($cloneResult->success);
$baseErrors = $cloneResult->errors->forKey('transaction')->onAttribute('base');
$this->assertEquals(Braintree_Error_Codes::TRANSACTION_CANNOT_CLONE_CREDIT, $baseErrors[0]->code);
}
示例2: cloneTransaction
/**
* Clone a transaction
*
* @param $transactionId
* @param $amount
*
* @return bool|mixed
*/
public function cloneTransaction($transactionId, $amount, $submitForSettlement = true)
{
// Attempt to clone the transaction
try {
$result = Braintree_Transaction::cloneTransaction($transactionId, array('amount' => $amount, 'options' => array('submitForSettlement' => $submitForSettlement)));
return $result;
} catch (Exception $e) {
// Log the issue
Gene_Braintree_Model_Debug::log(array('cloneTransaction' => $e));
return false;
}
}
示例3: testCloneTransaction_RaisesErrorOnInvalidProperty
function testCloneTransaction_RaisesErrorOnInvalidProperty()
{
$this->setExpectedException('InvalidArgumentException');
Braintree_Transaction::cloneTransaction('an id', array('amount' => '123.45', 'invalidProperty' => 'foo'));
}
示例4: cloneTransaction
/**
* @param string $transactionId
* @param array $attribs
* @return \Braintree_Result_Successful|\Braintree_Result_Error
*/
public function cloneTransaction($transactionId, array $attribs)
{
return \Braintree_Transaction::cloneTransaction($transactionId, $attribs);
}
示例5: json_encode
echo "</form>";
echo "--------------------------------------------------------------------------------------------------------------------------";
} else {
if ($_REQUEST['_act'] == 'refund_process') {
$result = Braintree_Transaction::refund((string) $_POST['id'], (string) $_POST['amt']);
echo "<div style='height:300px; overflow-y:scroll; background-color:#fff;'> <h3>API response</h3>";
echo json_encode($result, JSON_PRETTY_PRINT);
echo "</div>";
exit;
} else {
if ($_POST['_act'] == 'find') {
$result = Braintree_Transaction::find($_POST['id']);
print_r($result);
} else {
if ($_POST['_act'] == 'clone') {
$result = Braintree_Transaction::cloneTransaction($_POST['id'], array('amount' => '10.00', 'options' => array('submitForSettlement' => true)));
print_r($result);
} else {
if ($_POST['_act'] == 'createCustomer') {
if (isset($_POST['data'])) {
$postData = explode("&", urldecode($_POST['data']));
//[SETTING UP POST DATA TO SUPPORT AJAX]
foreach ($postData as $key => $value) {
$postValue = explode("=", $value);
$_POST[$postValue[0]] = $postValue[1];
}
unset($_POST['data']);
}
$result = Braintree_Customer::create(array('firstName' => $_POST['firstName'], 'lastName' => $_POST['lastName'], 'company' => $_POST['company'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'fax' => $_POST['fax'], 'website' => $_POST['website'], 'customFields' => array('custom_field_one' => $_POST['custom1'], 'custom_field_two' => $_POST['custom2']), 'paymentMethodNonce' => $_POST["payment_method_nonce"]));
$result->success;
# true
示例6: _cloneTransaction
/**
* Clones existing transaction
*
* @param decimal $amount
* @param string $transactionId
*/
protected function _cloneTransaction($amount, $transactionId)
{
$this->_debug('clone-' . $transactionId . ' amount=' . $amount);
try {
$result = Braintree_Transaction::cloneTransaction($transactionId, array('amount' => $amount, 'options' => array('submitForSettlement' => true)));
} catch (Exception $e) {
Mage::logException($e);
return false;
}
$this->_debug($result);
return $result;
}
示例7: cloneTransaction
public function cloneTransaction($transaction_id, $amount)
{
$result = Braintree_Transaction::cloneTransaction($transaction_id, array('amount' => $amount, 'options' => array('submitForSettlement' => true)));
if ($result->success) {
return array('success' => 1, 'transaction_id' => $result->transaction->id, 'amount' => $result->transaction->amount, 'currency_code' => $result->transaction->currencyIsoCode, 'type' => $result->transaction->type, 'escrow_status' => $result->transaction->escrowStatus, 'service_fee' => $result->transaction->serviceFeeAmount);
} else {
if (count($result->errors->deepAll()) > 0) {
return array('success' => 0, 'transaction_clone_errors' => $result->errors->deepAll());
} else {
return array('success' => 0, 'transaction_clone_errors' => $result->message);
}
}
}