Overview
  • Namespace
  • Class

Namespaces

  • Omnipay
    • Pagarme
      • Message

Classes

  • Omnipay\Pagarme\CreditCard
  • Omnipay\Pagarme\Gateway
  • Omnipay\Pagarme\Message\AbstractRequest
  • Omnipay\Pagarme\Message\AuthorizeRequest
  • Omnipay\Pagarme\Message\CaptureRequest
  • Omnipay\Pagarme\Message\CreateCardRequest
  • Omnipay\Pagarme\Message\CreateCustomerRequest
  • Omnipay\Pagarme\Message\InstallmentsRequest
  • Omnipay\Pagarme\Message\PurchaseRequest
  • Omnipay\Pagarme\Message\RefundRequest
  • Omnipay\Pagarme\Message\Response
  • Omnipay\Pagarme\Message\VoidRequest
  1 <?php
  2 /**
  3  * Pagarme Calculate Installments Request
  4  */
  5 
  6 namespace Omnipay\Pagarme\Message;
  7 
  8 /**
  9  * Pagarme Calculate Installments Request
 10  *
 11  * You can use Pagar.me API to calculate installments
 12  * for a purchase.
 13  *
 14  * <code>
 15  *   // Do a GET request on the gateway
 16  *   $transaction = $gateway->calculateInstallments(array(
 17  *       'max_installments'   => 12,
 18  *       'free_installments'  => 3,
 19  *       'interest_rate'      => 1.12,
 20  *       'amount'             => '1200.00',
 21  *   ));
 22  * 
 23  *   $response = $transaction->send();
 24  * 
 25  *   if ($response->isSuccessful()) {
 26  *       echo "Calculate Installments request was successful!\n";
 27  *       $installments = $response->getCalculatedInstallments();
 28  *       echo "Calculated Installments = " . $installments . "\n";
 29  *   }
 30  * </code>
 31  *
 32  * @see Omnipay\Pagarme\Gateway
 33  * @link https://docs.pagar.me/api/?shell#estados-das-transaes
 34  */
 35 class InstallmentsRequest extends AbstractRequest
 36 {
 37     /**
 38      * Get Interest Rate.
 39      * 
 40      * @return float
 41      */
 42     public function getInterestRate()
 43     {
 44         return $this->getParameter('interest_rate');
 45     }
 46     
 47     /**
 48      * Set Interest Rate.
 49      * 
 50      * @param float $value
 51      * @return InstallmentsRequest provides a fluent interface.
 52      */
 53     public function setInterestRate($value)
 54     {
 55         return $this->setParameter('interest_rate', $value);
 56     }
 57     
 58     /**
 59      * Get Max Installments.
 60      * 
 61      * @return integer
 62      */
 63     public function getMaxInstallments()
 64     {
 65         return $this->getParameter('max_installments');
 66     }
 67     
 68     /**
 69      * Set Max Installments.
 70      * 
 71      * @param integer $value
 72      * @return InstallmentsRequest provides a fluent interface.
 73      */
 74     public function setMaxInstallments($value)
 75     {
 76         return $this->setParameter('max_installments', $value);
 77     }
 78     
 79     /**
 80      * Get Free Installments.
 81      * 
 82      * @return integer
 83      */
 84     public function getFreeInstallments()
 85     {
 86         return $this->getParameter('free_installments');
 87     }
 88     
 89     /**
 90      * Set Free Installments.
 91      * 
 92      * @param integer $value
 93      * @return InstallmentsRequest provides a fluent interface.
 94      */
 95     public function setFreeInstallments($value)
 96     {
 97         return $this->setParameter('free_installments', $value);
 98     }
 99     
100     /**
101      * Get HTTP method used by InstallmentsRequest.
102      * 
103      * @return string
104      */
105     public function getHttpMethod()
106     {
107         return 'GET';
108     }
109     
110     public function getData()
111     {
112         $this->validate('amount', 'interest_rate', 'max_installments');
113         
114         $data = array();
115         
116         $data['amount'] = $this->getAmountInteger();
117         $data['max_installments'] = $this->getMaxInstallments();
118         $data['free_installments'] = $this->getFreeInstallments();
119         $data['interest_rate'] = $this->getInterestRate();
120         
121         return $data;
122     }
123     
124     public function getEndpoint()
125     {
126         return $this->endpoint.'transactions/calculate_installments_amount';
127     }
128 }
API documentation generated by ApiGen