public function testCreateCardAccountTest() { $userid = 'ec9bf096-c505-4bef-87f6-18822b9dbf2c'; $info = array('id' => $userid, 'active' => 'true', 'card' => array('fullname' => 'test', 'number' => '4111111111111111', "expiry_month" => '12', "expiry_year" => '2020', "cvv" => '123')); $repo = new CardAccountRepository(); $carAcc = new CardAccount($info); $this->assertEquals($carAcc->getCard()->getFullName(), $repo->createCardAccount($carAcc)->getFullName()); }
public function createCardAccount(CardAccount $card) { $payload = ''; $preparePayload = array("id" => $card->getUserId(), "full_name" => $card->getCard()->getFullName(), "number" => $card->getCard()->getNumber(), "expiry_month" => $card->getCard()->getExpMonth(), "expiry_year" => $card->getCard()->getExpYear(), "cvv" => $card->getCard()->getCVV()); foreach ($preparePayload as $key => $value) { $payload .= $key . '='; $payload .= urlencode($value); $payload .= "&"; } $response = $this->RestClient('post', 'card_accounts/', $payload); $jsonData = json_decode($response->raw_body, true); return new CardAccount($jsonData); }