/** * @param int $transactionId * @param \SubscribePro\Service\Transaction\TransactionInterface|null $transaction * @return \SubscribePro\Service\Transaction\TransactionInterface * @throws \SubscribePro\Exception\EntityInvalidDataException * @throws \SubscribePro\Exception\HttpException */ public function credit($transactionId, TransactionInterface $transaction = null) { if ($transaction && !$transaction->isServiceDataValid()) { throw new EntityInvalidDataException('Currency code not specified for given amount.'); } $postData = $transaction ? [self::API_NAME_TRANSACTION => $transaction->getServiceFormData()] : []; $response = $this->httpClient->post("/services/v1/vault/transactions/{$transactionId}/credit.json", $postData); return $this->retrieveItem($response, self::API_NAME_TRANSACTION, $transaction); }
/** * @param \SubscribePro\Service\Address\AddressInterface|null $address * @param array $expectedData * @dataProvider getTokenFormDataTest */ public function testGetTokenFormData($address, $expectedData) { $data = [TransactionInterface::TOKEN => 'token', TransactionInterface::GATEWAY_SPECIFIC_RESPONSE => 'response', TransactionInterface::GATEWAY_TYPE => 'type', TransactionInterface::AUTHORIZE_NET_RESPONSE_REASON_CODE => 'code', TransactionInterface::SUBSCRIBE_PRO_ERROR_DESCRIPTION => 'description', TransactionInterface::CREDITCARD_TYPE => 'type', TransactionInterface::CREDITCARD_LAST_DIGITS => '1111', TransactionInterface::CREDITCARD_FIRST_DIGITS => '411111', TransactionInterface::CREDITCARD_MONTH => '04', TransactionInterface::CREDITCARD_YEAR => '2019', TransactionInterface::BILLING_ADDRESS => '123', TransactionInterface::UNIQUE_ID => '129834765', TransactionInterface::REF_PAYMENT_PROFILE_ID => '414', TransactionInterface::REF_TRANSACTION_ID => '2323', TransactionInterface::REF_GATEWAY_ID => '525', TransactionInterface::REF_TOKEN => 'token', TransactionInterface::TYPE => 'type', TransactionInterface::AMOUNT => 'amount', TransactionInterface::CURRENCY_CODE => 'currency code', TransactionInterface::STATE => 'state', TransactionInterface::GATEWAY_TRANSACTION_ID => '124', TransactionInterface::EMAIL => '*****@*****.**', TransactionInterface::ORDER_ID => '123', TransactionInterface::IP => '0.0.0.0', TransactionInterface::RESPONSE_MESSAGE => 'message', TransactionInterface::ERROR_CODE => 'error_code', TransactionInterface::ERROR_DETAIL => 'detail', TransactionInterface::CVV_CODE => 'cvv_code', TransactionInterface::CVV_MESSAGE => 'cvv_message', TransactionInterface::AVS_CODE => 'avs_code', TransactionInterface::AVS_MESSAGE => 'avs_message', TransactionInterface::SUBSCRIBE_PRO_ERROR_CLASS => 'class', TransactionInterface::SUBSCRIBE_PRO_ERROR_TYPE => 'type', TransactionInterface::CREATED => '2016-12-12']; $this->transaction->importData($data); $this->assertEquals($expectedData, $this->transaction->getTokenFormData($address)); }