PHP code example of rasclatt / coinzoom

1. Go to this page and download the library: Download rasclatt/coinzoom library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rasclatt / coinzoom example snippets


use \CoinZoom\PartnerApi\Locale;

$arr = [];
array_map(function($v) use (&$arr) {
    $arr[$v['isoCode3']] = $v['name'];
}, (new Locale())->getCountries());
print_r($arr);


use \CoinZoom\PartnerApi\Locale;

$regions = (new Locale())->getRegions('USA'); 
$arr = [];
array_map(function($v) use (&$arr) {
    $arr[$v['code']] = $v['name'];
}, $regions);
print_r($arr);

class OnboardCreateRequest extends \SmartDto\Dto
{
    public $email = '[email protected]';
    public $mobileNumber = 1322131231231;
    public $firstName = 'Jane';
    public $middleName = '';
    public $lastName = 'Doe';
    public $dateOfBirth = '1982-04-17';
    public $addressLine1 = '101 Some Address';
    public $addressLine2 = '';
    public $city = 'Reno';
    public $stateCode = 'NV';
    public $zipCode = 89523;
    public $countryCode = 'USA';
    public $employmentStatus = 'FULL_TIME';
    public $preTaxAnnualIncome = '50k-100k';
    public $gender = 'FEMALE';
    public $distid = '112932';
}

$coinzoomData = new OnboardCreateRequest();
$Onboarding = new \CoinZoom\PartnerApi\Onboard();

try {
    # Create a new user
    $data = $Onboarding->create(...[
        new OnboardCreateRequest($coinzoomData)
    ]);
}
catch (\Exception $e) {
    print_r([
        'success' => false,
        'message' => 'Missing 

use \CoinZoom\Dto\ {
    Order\Create as OrderCreate,
    Order\CreateWithUuidRequest as OrderCreateUuid
};
use \CoinZoom\ {
    Order,
    Currency,
    Market
};

# Create an order dto to send to wallet
$data = [
    'distid' => $request->distid,
    'invoice' => $request->invoice,
    'price' => $request->total
];
# Create new user order
if(!empty($request->referralToken)) {
    $data['referralToken'] = $request->referralToken;
    $CreateDto = new OrderCreateUuid($data);
}
# Create current user order
else
    $CreateDto = new OrderCreate($data);
# Start transaction
$CZ = new Order($CreateDto);
# Set reply url (spinner)
$CZ->setWebhook('https://www.example.com/webhook/')
# Set the default currency
    ->setPaymentOption('USD');
# Try and create the CZ transaction
try {
    # Create the CZ transaction
    $createTransaction = $CZ->create(new Currency(new Market()));
}
catch (\Exception $e) {
    die('Wallet failed with error: '.$e->getMessage().':'.$e->getCode());
}
print_r($createTransaction);