Ejemplo n.º 1
0
 /**
  * Return an array with the information for the new test user
  * @param string $siteId
  * @return array
  */
 public function createTestUser($siteId = 'MCO')
 {
     // Obtain access token
     $result = CurlClient::post(self::API_URL . '/oauth/token', ['grant_type' => 'client_credentials', 'client_id' => $this->appId(), 'client_secret' => $this->secretKey()]);
     $accessToken = $result['response']['access_token'];
     // Obtain data
     $result = CurlClient::post(CurlClient::buildQuery(self::API_URL . '/users/test_user', ['access_token' => $accessToken]), ['site_id' => $siteId]);
     return $result['response'];
 }
Ejemplo n.º 2
0
 public function createPreference($accessToken = null)
 {
     if (sizeof($this->items()) == 0) {
         throw new Exception("There is no items for the preference");
     }
     if (is_null($accessToken)) {
         $accessToken = $this->accessToken();
     }
     $this->preferenceData['items'] = $this->items();
     if (!is_null($this->fee())) {
         $this->preferenceData['marketplace_fee'] = $this->fee();
     }
     if (!is_null($this->backUrls())) {
         $this->preferenceData['back_urls'] = $this->backUrls();
     }
     if (!is_null($this->notificationUrl())) {
         $this->preferenceData['notification_url'] = $this->notificationUrl();
     }
     $response = CurlClient::post(CurlClient::buildQuery(self::API_URL . '/checkout/preferences', ['access_token' => $accessToken]), $this->preferenceData);
     return new Preference($response['response']);
 }