/** * Generates nonce for saved payment method * * @param string $ccToken * @return string */ public function getNonceForVaultedToken($ccToken) { try { $result = Braintree_PaymentMethodNonce::create($ccToken); } catch (Exception $e) { Mage::logException($e); Mage::throwException(Mage::helper('braintree_payments')->__('Please try again later')); } return $this->jsQuoteEscape($result->paymentMethodNonce->nonce); }
/** * If we're trying to charge a 3D secure card in the vault we need to build a special nonce * * @param $paymentMethodToken * * @return mixed */ public function getThreeDSecureVaultNonce($paymentMethodToken) { $this->init(); $result = Braintree_PaymentMethodNonce::create($paymentMethodToken); return $result->paymentMethodNonce->nonce; }
function testCreate_fromNonExistentPaymentMethodToken() { $this->setExpectedException('Braintree_Exception_NotFound'); Braintree_PaymentMethodNonce::create('not_a_token'); }
/** * @param string $token * @return \Braintree_Result_Successful|\Braintree_Result_Error */ public function createNonce($token) { return \Braintree_PaymentMethodNonce::create($token); }
private function _getPaymentMethodNonce($paymentToken) { $nonce = Braintree_PaymentMethodNonce::create($paymentToken); return $nonce->paymentMethodNonce->nonce; }
function testFind_nonExistantNonce() { $this->setExpectedException('Braintree_Exception_NotFound'); Braintree_PaymentMethodNonce::create('not_a_nonce'); }
public function settlePayment() { if (Efiwebsetting::getData('checkOAuth') == 'yes') { IMBAuth::checkOAuth(); } $id_order = $_GET["id_order"]; $id_user = $_GET["id_user"]; $user = new UserModel(); $user->getByID($id_user); $order = new MasterOrderModel(); $order->getByID($id_order); $objResto = new MasterRestaurantModel(); $objResto->getByID($order->id_restaurant); if ($user->payment_id == null || $user->payment_id == "0") { Generic::errorMsg("No Payment Method"); } try { $result = Braintree_PaymentMethodNonce::create($user->braintree_id); $nonce = $result->paymentMethodNonce->nonce; $resultSale = Braintree_Transaction::sale(['amount' => $order->grand_total, 'paymentMethodNonce' => $nonce, 'options' => ['submitForSettlement' => True]]); } catch (Exception $e) { Generic::errorMsg($e->getMessage()); } // $transaction = $resultSale->transaction; // $order->transaction_id = $transaction->id; // $order->load = 1; // $order->status_payment = '1'; // $orderObj->nonce_cc = $nonce; // $order->isPaid = '1'; // $order->save(); pr($resultSale); // $json['results'] = "Your Payment was successful with ID Order " . $id_order; // echo json_encode($json); //, // 'descriptor' => [ // 'name' => $objResto->name . " - " . $objResto->order_number // ] // die(); }