post() public method

public post ( $path, $params = null )
Ejemplo n.º 1
0
 public static function createGrant($gateway, $params)
 {
     $http = new Braintree\Http($gateway->config);
     $http->useClientCredentials();
     $response = $http->post('/oauth_testing/grants', array('grant' => $params));
     return $response['grant']['code'];
 }
Ejemplo n.º 2
0
 public function testGatewayAll_returnsAllAddOns()
 {
     $newId = strval(rand());
     $addOnParams = ["amount" => "100.00", "description" => "some description", "id" => $newId, "kind" => "add_on", "name" => "php_add_on", "neverExpires" => "false", "numberOfBillingCycles" => "1"];
     $http = new Braintree\Http(Braintree\Configuration::$global);
     $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
     $http->post($path, ["modification" => $addOnParams]);
     $gateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key']);
     $addOns = $gateway->addOn()->all();
     foreach ($addOns as $addOn) {
         if ($addOn->id == $newId) {
             $actualAddOn = $addOn;
         }
     }
     $this->assertNotNull($actualAddOn);
     $this->assertEquals($addOnParams["amount"], $actualAddOn->amount);
     $this->assertEquals($addOnParams["description"], $actualAddOn->description);
     $this->assertEquals($addOnParams["id"], $actualAddOn->id);
 }
Ejemplo n.º 3
0
 public function testGatewayAll_returnsAllDiscounts()
 {
     $newId = strval(rand());
     $discountParams = array("amount" => "100.00", "description" => "some description", "id" => $newId, "kind" => "discount", "name" => "php_discount", "neverExpires" => "false", "numberOfBillingCycles" => "1");
     $http = new Braintree\Http(Braintree\Configuration::$global);
     $path = Braintree\Configuration::$global->merchantPath() . "/modifications/create_modification_for_tests";
     $http->post($path, array("modification" => $discountParams));
     $gateway = new Braintree\Gateway(array('environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key'));
     $discounts = $gateway->discount()->all();
     foreach ($discounts as $discount) {
         if ($discount->id == $newId) {
             $actualDiscount = $discount;
         }
     }
     $this->assertNotNull($actualDiscount);
     $this->assertEquals($discountParams["amount"], $actualDiscount->amount);
     $this->assertEquals($discountParams["id"], $actualDiscount->id);
     $this->assertEquals($discountParams["kind"], $actualDiscount->kind);
 }
Ejemplo n.º 4
0
 public function testGatewayAll_returnsAllPlans()
 {
     $newId = strval(rand());
     $params = array("id" => $newId, "billingDayOfMonth" => "1", "billingFrequency" => "1", "currencyIsoCode" => "USD", "description" => "some description", "name" => "php test plan", "numberOfBillingCycles" => "1", "price" => "1.00", "trialPeriod" => "false");
     $http = new Braintree\Http(Braintree\Configuration::$global);
     $path = Braintree\Configuration::$global->merchantPath() . '/plans/create_plan_for_tests';
     $http->post($path, array("plan" => $params));
     $gateway = new Braintree\Gateway(array('environment' => 'development', 'merchantId' => 'integration_merchant_id', 'publicKey' => 'integration_public_key', 'privateKey' => 'integration_private_key'));
     $plans = $gateway->plan()->all();
     foreach ($plans as $plan) {
         if ($plan->id == $newId) {
             $actualPlan = $plan;
         }
     }
     $this->assertNotNull($actualPlan);
     $this->assertEquals($params["billingDayOfMonth"], $actualPlan->billingDayOfMonth);
     $this->assertEquals($params["billingFrequency"], $actualPlan->billingFrequency);
     $this->assertEquals($params["currencyIsoCode"], $actualPlan->currencyIsoCode);
     $this->assertEquals($params["description"], $actualPlan->description);
     $this->assertEquals($params["name"], $actualPlan->name);
     $this->assertEquals($params["numberOfBillingCycles"], $actualPlan->numberOfBillingCycles);
     $this->assertEquals($params["price"], $actualPlan->price);
 }
Ejemplo n.º 5
0
 /**
  * sends the create request to the gateway
  * @ignore
  * @param string $subPath
  * @param array $params
  * @return mixed
  */
 private function _doCreate($subPath, $params)
 {
     $fullPath = $this->_config->merchantPath() . $subPath;
     $response = $this->_http->post($fullPath, $params);
     return $this->_verifyGatewayResponse($response);
 }
Ejemplo n.º 6
0
 public static function create3DSVerification($merchantAccountId, $params)
 {
     $http = new Braintree\Http(Braintree\Configuration::$global);
     $path = Braintree\Configuration::$global->merchantPath() . '/three_d_secure/create_verification/' . $merchantAccountId;
     $response = $http->post($path, array('threeDSecureVerification' => $params));
     return $response['threeDSecureVerification']['threeDSecureToken'];
 }
Ejemplo n.º 7
0
 public static function generate3DSNonce($params)
 {
     $http = new Braintree\Http(Braintree\Configuration::$global);
     $path = Braintree\Configuration::$global->merchantPath() . '/three_d_secure/create_nonce/' . self::threeDSecureMerchantAccountId();
     $response = $http->post($path, $params);
     return $response['paymentMethodNonce']['nonce'];
 }