function testNotificationJson()
 {
     $json = \Hypercharge\JsonSchemaFixture::notification('Scheduler_expiring.json');
     $this->assertJson($json);
     $data = json_decode($json);
     $this->assertIdentical('f433a0bf7c9681f39b82ace9d2af7e96', $data->recurring_schedule_unique_id);
 }
Esempio n. 2
0
 function getRequestFixture($fileName, $asArray = true)
 {
     return json_decode(\Hypercharge\JsonSchemaFixture::request($fileName), $asArray);
 }
 function testConstructorLoadsJsonResponse()
 {
     $response = json_decode(JsonSchemaFixture::response('scheduled_transactions_one.json'));
     $this->assertIsA($response->entries[0], 'stdClass');
     $trx = new Transaction($response->entries[0]);
     $this->assertIdentical(500, $trx->amount);
     $this->assertIdentical('USD', $trx->currency);
     $this->assertEqual('3ba2d77ab04f773c0a47bd1081ac50be', $trx->unique_id);
 }
 /**
  * @param string $fileName e.g. "sale.json" for /vendor/hypercharge/hypercharge-schema/test/fixtures/sale.json
  * @return mixed array for *.json, string for other
  */
 function schemaNotification($fileName)
 {
     return self::parseIfJson(JsonSchemaFixture::notification($fileName), $fileName);
 }
Esempio n. 5
0
 function testJsonResponseWorkflowError()
 {
     $data = json_decode(\Hypercharge\JsonSchemaFixture::response('scheduler_workflow_error.json'));
     $this->assertIsA($data, 'stdClass');
     $this->assertIdentical(400, $data->error->code);
     $e = errorFromResponseHash($data->error);
     $this->assertIsa($e, 'Hypercharge\\Errors\\WorkflowError');
     $this->assertEqual('Something went wrong, please contact support!', $e->message);
     $this->assertEqual("transaction already has a schedule.", $e->technical_message);
 }
 function response($responseFixture)
 {
     return json_decode(JsonSchemaFixture::response($responseFixture));
 }
 function testEachWithEmpty()
 {
     $response = json_decode(JsonSchemaFixture::response('scheduled_transactions_empty.json'));
     $this->expect_Curl_jsonRequest()->with('GET', 'https://test.hypercharge.net/v2/scheduler/e1420438c52b4cb3a03a14a7e4fc16e1/transactions?page=3')->andReturn($response);
     $_this = $this;
     SchedulerTransactions::each('e1420438c52b4cb3a03a14a7e4fc16e1', array('page' => 3), function ($trx) use($_this) {
         $_this->fail('callback should not be called!');
     });
 }
 function testCreateThrowsIfTransactionHasScheduler()
 {
     $trxData = $this->transactionFixture('init_recurring_authorize.json');
     $this->setStartAndEndDate($trxData['recurring_schedule']);
     $trx = Transaction::init_recurring_authorize($this->channel_token, $trxData);
     $this->assertTrue($trx->isApproved());
     $this->assertIsA($trx->recurring_schedule, 'Hypercharge\\Scheduler');
     $schedulerData = json_decode(JsonSchemaFixture::request('scheduler_create.json'), true);
     $schedulerData['payment_transaction_unique_id'] = $trx->unique_id;
     $this->setStartAndEndDate($schedulerData);
     $this->expectException('Hypercharge\\Errors\\WorkflowError');
     $this->mockV2Url('scheduler');
     Scheduler::create($schedulerData);
 }