本文整理汇总了PHP中Braintree_Transaction类的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Transaction类的具体用法?PHP Braintree_Transaction怎么用?PHP Braintree_Transaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Braintree_Transaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doDirectPayment
/**
* Submit a payment using Advanced Integration Method
*
* @param array $params assoc array of input parameters for this transaction
*
* @return array the result in a nice formatted array (or an error object)
* @public
*/
function doDirectPayment(&$params)
{
$requestArray = $this->formRequestArray($params);
$result = Braintree_Transaction::sale($requestArray);
if ($result->success) {
$params['trxn_id'] = $result->transaction->id;
$params['gross_amount'] = $result->transaction->amount;
} else {
if ($result->transaction) {
$errormsg = 'Transactions is not approved';
return self::error($result->transaction->processorResponseCode, $result->message);
} else {
$error = "Validation errors:<br/>";
foreach ($result->errors->deepAll() as $e) {
$error .= $e->message;
}
return self::error(9001, $error);
}
}
return $params;
}
示例2: _doTestRequest
private function _doTestRequest($testPath, $transactionId)
{
self::_checkEnvironment();
$path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath;
$response = $this->_http->put($path);
return Braintree_Transaction::factory($response['transaction']);
}
示例3: _initialize
/**
* @ignore
*/
protected function _initialize($attributes)
{
$this->_attributes = $attributes;
$addOnArray = array();
if (isset($attributes['addOns'])) {
foreach ($attributes['addOns'] as $addOn) {
$addOnArray[] = Braintree_AddOn::factory($addOn);
}
}
$this->_attributes['addOns'] = $addOnArray;
$discountArray = array();
if (isset($attributes['discounts'])) {
foreach ($attributes['discounts'] as $discount) {
$discountArray[] = Braintree_Discount::factory($discount);
}
}
$this->_attributes['discounts'] = $discountArray;
if (isset($attributes['descriptor'])) {
$this->_set('descriptor', new Braintree_Descriptor($attributes['descriptor']));
}
$statusHistory = array();
if (isset($attributes['statusHistory'])) {
foreach ($attributes['statusHistory'] as $history) {
$statusHistory[] = new Braintree_Subscription_StatusDetails($history);
}
}
$this->_attributes['statusHistory'] = $statusHistory;
$transactionArray = array();
if (isset($attributes['transactions'])) {
foreach ($attributes['transactions'] as $transaction) {
$transactionArray[] = Braintree_Transaction::factory($transaction);
}
}
$this->_attributes['transactions'] = $transactionArray;
}
示例4: send
public function send()
{
$this->load->model('checkout/order');
$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
$amount = $this->currency->format($order_info['total'], $order_info['currency_code'], 1.0, false);
//Load Braintree Library
require_once './vendor/braintree/braintree_php/lib/Braintree.php';
Braintree_Configuration::environment($this->config->get('simple_braintree_payments_mode'));
Braintree_Configuration::merchantId($this->config->get('simple_braintree_payments_merchant'));
Braintree_Configuration::publicKey($this->config->get('simple_braintree_payments_public_key'));
Braintree_Configuration::privateKey($this->config->get('simple_braintree_payments_private_key'));
// Payment nonce received from the client js side
$nonce = $_POST["payment_method_nonce"];
//create object to use as json
$json = array();
$result = null;
try {
// Perform the transaction
$result = Braintree_Transaction::sale(array('amount' => $amount, 'paymentMethodNonce' => $nonce, 'orderId' => $this->session->data['order_id']));
} catch (Exception $e) {
$json['phperror'] = $e->getMessage();
}
$json['details'] = $result;
if ($result->success) {
$this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('simple_braintree_payments_order_status_id'));
$json['success'] = $this->url->link('checkout/success', '', 'SSL');
} else {
$json['error'] = $result->_attributes['message'];
}
$this->response->setOutput(json_encode($json));
}
示例5: braintree
function braintree($data)
{
foreach ($data as $k => $v) {
${$k} = $v;
}
try {
include_once 'config.braintree.php';
$customer = Braintree_Customer::create(['firstName' => $first_name, 'lastName' => $last_name]);
if (!isset($nonce) || empty($nonce)) {
throw new Exception("An unknown error has occurred");
}
if ($customer->success) {
$transaction = Braintree_Transaction::sale(['amount' => $price, 'customerId' => $customer->customer->id, 'paymentMethodNonce' => $nonce]);
if ($transaction->success) {
$this->save($data, __FUNCTION__, $transaction->transaction, 1);
return json_encode(["status" => true, "msg" => sprintf("Your payment has been %s", $transaction->transaction->status)]);
} else {
throw new Exception($transaction->message);
}
}
} catch (Exception $e) {
$this->save($data, __FUNCTION__, (string) $e, 0);
return json_encode(["status" => false, "msg" => $e->getMessage()]);
}
}
示例6: directpay
public function directpay($var = array())
{
$payment = array("amount" => $var['postVal']['amount'], "creditCard" => array("number" => $var['postVal']['ccNum'], "cvv" => $var['postVal']['ccCCV'], "cardholderName" => $var['postVal']['ccHolder'], "expirationMonth" => $var['postVal']['ccExpMM'], "expirationYear" => $var['postVal']['ccExpYY']), "merchantAccountId" => $var['postVal']['cur'], "options" => array("submitForSettlement" => true));
$sale = Braintree_Transaction::sale($payment);
$result = array();
if ($sale->success) {
$result['status'] = "200";
$result['detail']['id'] = $sale->transaction->id;
$result['detail']['sales_id'] = $sale->transaction->id;
$result['detail']['state'] = $sale->transaction->status;
$result['detail']['create_time'] = $sale->transaction->createdAt->format("Y-m-d H:i:s");
$result['detail']['update_time'] = $sale->transaction->updatedAt->format("Y-m-d H:i:s");
$result['detail']['currency'] = $sale->transaction->currencyIsoCode;
$result['detail']['amount'] = $sale->transaction->amount;
$result['detail']['gateway'] = "Braintree";
} else {
if ($sale->transaction) {
$result['status'] = $sale->transaction->processorResponseCode;
$result['errMsg'] = $sale->message;
} else {
$result['status'] = "400";
$errMsg = "";
foreach ($sale->errors->deepAll() as $error) {
$errMsg .= "- " . $error->message . "<br/>";
}
$result['errMsg'] = $errMsg;
}
}
return $result;
}
示例7: _initialize
protected function _initialize($attributes)
{
$this->_attributes = $attributes;
if (isset($attributes['subject']['apiErrorResponse'])) {
$wrapperNode = $attributes['subject']['apiErrorResponse'];
} else {
$wrapperNode = $attributes['subject'];
}
if (isset($wrapperNode['subscription'])) {
$this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
}
if (isset($wrapperNode['merchantAccount'])) {
$this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
}
if (isset($wrapperNode['transaction'])) {
$this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
}
if (isset($wrapperNode['disbursement'])) {
$this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
}
if (isset($wrapperNode['partnerMerchant'])) {
$this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
}
if (isset($wrapperNode['errors'])) {
$this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
$this->_set('message', $wrapperNode['message']);
}
}
示例8: __construct
/**
* overrides default constructor
* @ignore
* @param array $response gateway response array
*/
public function __construct($response)
{
$this->_attributes = $response;
$this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
if (isset($response['verification'])) {
$this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
} else {
$this->_set('creditCardVerification', null);
}
if (isset($response['transaction'])) {
$this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
} else {
$this->_set('transaction', null);
}
if (isset($response['subscription'])) {
$this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
} else {
$this->_set('subscription', null);
}
if (isset($response['merchantAccount'])) {
$this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
} else {
$this->_set('merchantAccount', null);
}
}
示例9: init
/**
* create signatures for different call types
* @ignore
*/
public static function init()
{
self::$_createCustomerSignature = array(self::$_transparentRedirectKeys, array('customer' => Braintree_Customer::createSignature()));
self::$_updateCustomerSignature = array(self::$_transparentRedirectKeys, 'customerId', array('customer' => Braintree_Customer::updateSignature()));
self::$_transactionSignature = array(self::$_transparentRedirectKeys, array('transaction' => Braintree_Transaction::createSignature()));
self::$_createCreditCardSignature = array(self::$_transparentRedirectKeys, array('creditCard' => Braintree_CreditCard::createSignature()));
self::$_updateCreditCardSignature = array(self::$_transparentRedirectKeys, 'paymentMethodToken', array('creditCard' => Braintree_CreditCard::updateSignature()));
}
示例10: donate
function donate($nonce, $info)
{
$result = Braintree_Transaction::sale(['amount' => $info['amount'], 'paymentMethodNonce' => $nonce, 'options' => ['submitForSettlement' => True]]);
if (!isset($result->transaction) || !$result->transaction) {
return $this->processErrors('donation', $result->errors->deepAll());
}
return $this->retrieveTransactioResults($result->success, $result->transaction, $info);
}
示例11: braintreepay
function braintreepay(){
$nonce = $_POST["payment_method_nonce"];
$amount = $_POST["amount"];
$result = Braintree_Transaction::sale([
'amount'=>''.$amount,
'paymentMethodNonce' => 'fake-valid-nonce'
]);
echo $result->success;
}
示例12: searchTransactions
public function searchTransactions()
{
$transactions = Braintree_Transaction::search($data);
if ($transactions) {
return $transactions;
} else {
return false;
}
}
示例13: _sale
private function _sale($postFormData, $nonce)
{
$amount = $postFormData['Order']['amount'];
$currencyModelObj = ClassRegistry::init('Currency');
$currency = $currencyModelObj->getCurrencyByAbbreviation($postFormData['Order']['currency_abbr']);
$convertedAmount = (double) round($amount / $currency['Currency']['rate'], 2);
$sale = Braintree_Transaction::sale(['amount' => $convertedAmount, 'paymentMethodNonce' => $nonce]);
return $sale;
}
示例14: pay
public function pay($data)
{
global $_SESSION;
$this->debug($_SESSION);
$billingAddress = $this->getAddress($data['billingAddress'], true)[0];
$shippingAddress = $this->getAddress($data['shippingAddress'], true)[0];
$sale = Braintree_Transaction::sale(['amount' => '10.00', 'paymentMethodNonce' => $data['payment_method_nonce'], 'shipping' => ['firstName' => $shippingAddress['address_first_name'], 'lastName' => $shippingAddress['address_last_name'], 'company' => $shippingAddress['address_company_name'], 'streetAddress' => $shippingAddress['address_street'], 'extendedAddress' => $shippingAddress['address_apartment'], 'locality' => $shippingAddress['address_city'], 'region' => $shippingAddress['address_county'], 'postalCode' => $shippingAddress['address_postcode'], 'countryCodeAlpha2' => $shippingAddress['address_country']], 'billing' => ['firstName' => $billingAddress['address_first_name'], 'lastName' => $billingAddress['address_last_name'], 'company' => $billingAddress['address_company_name'], 'streetAddress' => $billingAddress['address_street'], 'extendedAddress' => $billingAddress['address_apartment'], 'locality' => $billingAddress['address_city'], 'region' => $billingAddress['address_county'], 'postalCode' => $billingAddress['address_postcode'], 'countryCodeAlpha2' => $billingAddress['address_country']], 'options' => ['submitForSettlement' => true]]);
return $sale;
}
示例15: testGenerate_canBeGroupedByACustomField
function testGenerate_canBeGroupedByACustomField()
{
$transaction = Braintree_Transaction::saleNoValidate(array('amount' => '100.00', 'creditCard' => array('number' => '5105105105105100', 'expirationDate' => '05/12'), 'customFields' => array('store_me' => 'custom value'), 'options' => array('submitForSettlement' => true)));
Braintree_TestHelper::settle($transaction->id);
$today = new Datetime();
$result = Braintree_SettlementBatchSummary::generate(Braintree_TestHelper::nowInEastern(), 'store_me');
$this->assertTrue($result->success);
$this->assertTrue(count($result->settlementBatchSummary->records) > 0);
$this->assertArrayHasKey('store_me', $result->settlementBatchSummary->records[0]);
}