Exemplo n.º 1
0
 /**
  * REST API method card/processRecurring implementation
  * @param string $userId user's identifier
  * @param float $price price in real currency
  * @param string $currency currency code as ISO 4217
  * @param null|string $orderId merchant's order ID that will be returned back in a callback
  * @param null|string $description product description
  * @return Request card/processRecurring request instance
  * @throws ErrorException if there is an API error
  */
 public function cardProcessRecurring($userId, $price, $currency, $orderId = null, $description = null)
 {
     $parameters = ['user' => (string) $userId, 'price' => (double) $price, 'currency' => (string) $currency];
     if (!is_null($orderId)) {
         $parameters['order_id'] = (string) $orderId;
     }
     if (!is_null($description)) {
         $parameters['description'] = (string) $description;
     }
     return $this->getRequest('card/processRecurring', $parameters, function ($string) {
         return ProcessRecurringResponse::initializeByString($string);
     });
 }
Exemplo n.º 2
0
    public function testProcessRecurringResponse()
    {
        $Response = ProcessRecurringResponse::initializeByString('{
"id": 1326123574311498453, "success": true,
"card": {
"lastFour": "4242",
"type": "visa",
"mask": "************4242",
"expirationMonth": "4",
"expirationYear": "2020" } }');
        $this->assertEquals('1326123574311498453', $Response->getId());
        $this->assertTrue($Response->isSuccess());
        $this->assertEquals('4242', $Response->getCard()->getLastFour());
        $this->assertEquals('************4242', $Response->getCard()->getMask());
        $this->assertEquals(4, $Response->getCard()->getExpirationMonth());
        $this->assertEquals(2020, $Response->getCard()->getExpirationYear());
        $this->assertEquals('process recurring result
    id:             1326123574311498453
    success:        true
    card
        four:       4242
        mask:       ************4242
        type:       visa
        exp. month: 4
        exp. year:  2020', (string) $Response);
    }