예제 #1
0
 /**
  * @vcr Actions/can_validate_beneficiaries.yaml
  * @test
  */
 public function canValidateBeneficiaries()
 {
     $beneficiary = Beneficiary::createForValidate('GB', 'GBP', 'GB')->setAccountNumber('12345678')->setRoutingCodeType1('sort_code')->setRoutingCodeValue1('123456')->setPaymentTypes(['regular']);
     $beneficiary = $this->getAuthenticatedClient()->beneficiaries()->validate($beneficiary);
     $dummy = json_decode('{"payment_types":["regular"],"bank_country":"GB","bank_name":"HSBC BANK PLC","bank_account_type":null,"currency":"GBP","account_number":"12345678","routing_code_type_1":"sort_code","beneficiary_address":[],"beneficiary_country":"GB","beneficiary_entity_type":null,"beneficiary_company_name":null,"beneficiary_first_name":null,"beneficiary_last_name":null,"beneficiary_city":null,"beneficiary_postcode":null,"beneficiary_state_or_province":null,"beneficiary_date_of_birth":null,"beneficiary_identification_type":null,"beneficiary_identification_value":null,"routing_code_value_1":"123456","routing_code_type_2":null,"routing_code_value_2":null,"bic_swift":null,"iban":null,"bank_address":["5 Wimbledon Hill Rd","Wimbledon","London"]}', true);
     $this->validateObjectStrictName($beneficiary, $dummy);
 }
예제 #2
0
#!/usr/bin/env php
<?php 
use CurrencyCloud\CurrencyCloud;
use CurrencyCloud\Model\Beneficiary;
use CurrencyCloud\Model\Conversion;
use CurrencyCloud\Model\Payment;
use CurrencyCloud\Session;
require_once __DIR__ . '/../vendor/autoload.php';
$session = new Session(Session::ENVIRONMENT_DEMONSTRATION, '<user-id>', '<api-key>');
$currencyCloud = CurrencyCloud::createDefault($session);
//Note that there is no direct call to authenticate api
$detailedRate = $currencyCloud->rates()->detailed('EUR', 'GBP', 'buy', '10000.00');
var_dump($detailedRate);
$conversion = Conversion::create('EUR', 'GBP', 'buy');
$conversion = $currencyCloud->conversions()->create($conversion, '10000.00', 'Invoice Payment', true);
var_dump($conversion);
$beneficiaryRequiredDetails = $currencyCloud->reference()->beneficiaryRequiredDetails('EUR', 'DE');
var_dump($beneficiaryRequiredDetails);
$beneficiary = Beneficiary::create('Acme GmbH', 'DE', 'EUR', 'John Doe')->setBeneficiaryCountry('DE')->setBicSwift('COBADEFF')->setIban('DE89370400440532013000');
$beneficiary = $currencyCloud->beneficiaries()->create($beneficiary);
var_dump($beneficiary);
$payment = Payment::create('EUR', $beneficiary->getId(), '10000', 'Invoice Payment', 'Invoice 1234')->setPaymentType('regular')->setConversionId($conversion->getId());
$payment = $currencyCloud->payments()->create($payment);
var_dump($payment);
 /**
  * @param stdClass $response
  * @param bool $fromValidate
  *
  * @return Beneficiary
  */
 private function createBeneficiaryFromResponse(stdClass $response, $fromValidate = false)
 {
     $beneficiary = new Beneficiary();
     $beneficiary->setBankCountry($response->bank_country)->setCurrency($response->currency)->setBeneficiaryCountry($response->beneficiary_country)->setPaymentTypes($response->payment_types)->setBankName($response->bank_name)->setBankAddress($response->bank_address)->setAccountNumber($response->account_number)->setIban($response->iban)->setBicSwift($response->bic_swift)->setBankAccountType($response->bank_account_type)->setBeneficiaryAddress($response->beneficiary_address)->setBeneficiaryEntityType($response->beneficiary_entity_type)->setBeneficiaryCompanyName($response->beneficiary_company_name)->setBeneficiaryFirstName($response->beneficiary_first_name)->setBeneficiaryLastName($response->beneficiary_last_name)->setBeneficiaryCity($response->beneficiary_city)->setBeneficiaryPostcode($response->beneficiary_postcode)->setBeneficiaryStateOrProvince($response->beneficiary_state_or_province)->setBeneficiaryDateOfBirth(null !== $response->beneficiary_date_of_birth ? new DateTime($response->beneficiary_date_of_birth) : null)->setBeneficiaryIdentificationType($response->beneficiary_identification_type)->setBeneficiaryIdentificationValue($response->beneficiary_identification_value)->setRoutingCodeType1($response->routing_code_type_1)->setRoutingCodeValue1($response->routing_code_value_1)->setRoutingCodeType2($response->routing_code_type_2)->setRoutingCodeValue2($response->routing_code_value_2);
     if (!$fromValidate) {
         $beneficiary->setName($response->name)->setCreatorContactId($response->creator_contact_id)->setEmail($response->email)->setIsDefaultBeneficiary('true' === $response->default_beneficiary)->setBankAccountHolderName($response->bank_account_holder_name)->setCreatedAt(new DateTime($response->created_at))->setUpdatedAt(new DateTime($response->updated_at));
         $this->setIdProperty($beneficiary, $response->id);
     }
     return $beneficiary;
 }