コード例 #1
0
 public function nonceForPayPalAccount($options)
 {
     $clientToken = json_decode(Braintree_TestHelper::decodedClientToken());
     $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
     $response = $this->post('/client_api/v1/payment_methods/paypal_accounts.json', json_encode($options));
     if ($response["status"] == 201 || $response["status"] == 202) {
         $body = json_decode($response["body"], true);
         return $body["paypalAccounts"][0]["nonce"];
     } else {
         throw new Exception(var_dump($response));
     }
 }
コード例 #2
0
 function testFromNonce_ReturnsErrorWhenNonceIsLocked()
 {
     $customer = Braintree_Customer::createNoValidate();
     $clientTokenOptions = array();
     $clientToken = json_decode(Braintree_TestHelper::decodedClientToken($clientTokenOptions));
     $sharedCustomerIdentifier = "fake_identifier_" . rand();
     $options = array("credit_card" => array("number" => "4009348888881881", "expirationMonth" => "11", "expirationYear" => "2099"), "share" => true);
     $options["authorization_fingerprint"] = $clientToken->authorizationFingerprint;
     $options["shared_customer_identifier"] = $sharedCustomerIdentifier;
     $options["shared_customer_identifier_type"] = "testing";
     $response = Braintree_HttpClientApi::post('/client_api/v1/payment_methods/credit_cards.json', json_encode($options));
     $this->assertEquals(201, $response["status"]);
     unset($options["credit_card"]);
     $response = Braintree_HttpClientApi::get_cards($options);
     $body = json_decode($response["body"]);
     $nonce = $body->paymentMethods[0]->nonce;
     $this->setExpectedException('Braintree_Exception_NotFound', "locked");
     Braintree_CreditCard::fromNonce($nonce);
 }
コード例 #3
0
 function test_ClientTokenAcceptsMerchantAccountId()
 {
     $clientToken = Braintree_TestHelper::decodedClientToken(array('merchantAccountId' => 'my_merchant_account'));
     $merchantAccountId = json_decode($clientToken)->merchantAccountId;
     $this->assertEquals('my_merchant_account', $merchantAccountId);
 }