PHP code example of payarc / payarc-sdk-php
1. Go to this page and download the library: Download payarc/payarc-sdk-php 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/ */
payarc / payarc-sdk-php example snippets
use Symfony\Component\Dotenv\Dotenv;
$dotenv = new Dotenv();
$dotenv->load('.env');
/**
* Creates an instance of Payarc.
* @param {string} bearer_token - The bearer token for authentication.Mandatory parameter to construct the object
* @param {string} [base_url='sandbox'] - The url of access points possible values prod or sandbox, as sandbox is the default one. Vary for testing playground and production. can be set in environment file too.
* @param {string} [api_version='/v1/'] - The version of access points for now 1(it has default value thus could be omitted).
* @param {string} [version='1.0'] - API version.
* @param {string} bearer_token_agent - The bearer token for agent authentication. Only
try {
$charge = $payarc->charges->create(
[
'amount' => 2860,
'currency' => 'usd',
'source' => [
"card_number" => "4012******5439",
"exp_month" => "03",
"exp_year" => "2025",
]
],
);
echo "Charge created: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$charge_data = [
'amount' => 1285,
'currency' => 'usd',
'source' => [
"token_id" => "tok_mE*****LL8wYl"
]
];
try {
$charge = $payarc->charges->create($charge_data);
echo "Charge created: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$charge_data = [
'amount' => 3985,
'currency' => 'usd',
'source' => [
'card_id' => 'card_Ly9*****59M0m1',
'customer_id' => 'cus_j*******PVnDp'
]
];
try {
$charge = $payarc->charges->create($charge_data);
echo "Charge created: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$customer = $this->payarc->customers->retrieve('cus_j*******p');
$charge_data = [
'amount' => 3785,
'sec_code'=> 'WEB',
'source' => [
'bank_account_id'=> 'bnk_eJjbbbbbblL'
]
];
$charge = $customer['charges']['create'](charge_data);
echo "Charge created: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$customer = $this->payarc->customers->retrieve('cus_j*******p');
$charge_data = [
'amount' => 3785,
'sec_code'=> 'WEB',
'source' => [
'account_number' =>'123432575352',
'routing_number'=>'123345349',
'first_name'=> 'FirstName III',
'last_name'=>'LastName III',
'account_type'=> 'Personal Savings',
]
];
$charge = $customer['charges']['create'](charge_data);
echo "Charge created: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$charges = $payarc->charges->list();
echo "Charges listed: " . json_encode($charges) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$charge = $payarc->charges->retrieve('ch_1J*****3');
echo "Charge retrieved: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$charge = $payarc->charges->retrieve('ach_1J*****3');
echo "Charge retrieved: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$id = 'ach_g**********08eA';
$options = ['reason' => 'requested_by_customer',
'description'=> 'The customer returned the product, did not like it']
$charge = $payarc->charges->createRefund($id, $options);
echo "Charge refunded: " . json_encode($charge) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$customer_data = [
"email" => "[email protected] ",
"cards" => [
[
"card_source" => "INTERNET",
"card_number" => "4012000098765439",
"exp_month" => "07",
"exp_year" => "2025",
"cvv" => "997",
"card_holder_name" => "Bat Doncho",
"address_line1" => "123 Main Street",
"city" => "Greenwich",
"state" => "CT",
"zip" => "06830",
"country" => "US",
],
[
"card_source" => "INTERNET",
"card_number" => "4012000098765439",
"exp_month" => "01",
"exp_year" => "2025",
"cvv" => "998",
"card_holder_name" => "Bat Gancho",
"address_line1" => "123 Main Street Apt 44",
"city" => "Greenwich",
"state" => "CT",
"zip" => "06830",
"country" => "US",
]
]
];
try {
$customer = $payarc->customers->create($customer_data);
echo "Customer created: " . json_encode($customer) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$id = 'cus_j*******p';
$customer = $payarc->customers->update($id, [
"name" => "Bai Doncho 3",
"description" => "Example customer",
"phone" => "1234567890"
]);
echo "Customer updated: " . json_encode($customer) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$customer = $payarc->customers->retrieve('cus_j*******p');
$customer = $customer['update']([
"name" => "Bai Doncho 4",
"description" => "Senior Example customer",
"phone" => "1234567895"
]);
echo "Customer updated: " . json_encode($customer) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$customers = $payarc->customers->list(['limit' => 3]);
echo "Customers retrieved: " . json_encode($customers) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$card_data = [
"card_source" => "INTERNET",
"card_number" => "4012000098765439",
"exp_month" => "01",
"exp_year" => "2025",
"cvv" => "998",
"card_holder_name" => "Bat Gancho",
"address_line1" => "123 Main Street Apt 44",
"city" => "Greenwich",
"state" => "CT",
"zip" => "06830",
"country" => "US",
];
try {
$customer = $payarc->customers->retrieve($id);
$card = $customer['cards']['create']($card_data);
echo "Card added: " . json_encode($card) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$acc_data = [
"account_number" => "1234567890",
"routing_number" => "110000000",
'first_name' => 'Bat Petio',
'last_name' => 'The Tsar',
"account_type" => "Personal Savings",
'sec_code' => 'WEB'
];
try {
$customer = $payarc->customers->retrieve($id);
$acc = $customer['bank_accounts']['create']($acc_data);
echo "Bank account added: " . json_encode($acc) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try
{
$customer = $this->payarc->customers->delete($id);
echo "Customer deleted: " . json_encode($customer) . "\n";
}
catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$merchant_candidate = [
"Lead" => [
"Industry" => "cbd",
"MerchantName" => "Kolio i sie",
"LegalName" => "Best Co in w",
"ContactFirstName" => "Joan",
"ContactLastName" => "Dhow",
"ContactEmail" => "[email protected] ",
"DiscountRateProgram" => "interchange"
],
"Owners" => [
[
"FirstName" => "First",
"LastName" => "Last",
"Title" => "President",
"OwnershipPct" => 100,
"Address" => "Somewhere",
"City" => "City Of Test",
"SSN" => "4546-0034",
"State" => "WY",
"ZipCode" => "10102",
"BirthDate" => "1993-06-24",
"Email" => "[email protected] ",
"PhoneNo" => "2346456784"
]
]
];
try {
$merchant = $payarc->applications->create($merchant_candidate);
echo "Merchant candidate created: " . json_encode($merchant) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$merc_candidate = [
"Lead" => [
"Industry" => "cbd",
"MerchantName" => "chichovoto",
"LegalName" => "Best Co in w",
"ContactFirstName" => "Lubo",
"ContactLastName" => "Penev",
"ContactEmail" => "[email protected] ",
"DiscountRateProgram"=> "interchange"
],
"Owners" => [
[
"FirstName" => "First",
"LastName" => "Last",
"Title" => "President",
"OwnershipPct" => 100,
"Address" => "Somewhere",
"City" => "City Of Test",
"SSN" => "4546-0034",
"State" => "WY",
"ZipCode" => "10102",
"BirthDate" => "1993-06-24",
"Email" => "[email protected] ",
"PhoneNo" => "2346456784"
]
]
];
try {
$sub_agent = $payarc->applications->list_sub_agents();
$merc_candidate['agentId'] = $sub_agent['sub_agents'][0]['object_id'] ?? null;
$candidate = $this->payarc->applications->create($merc_candidate);
echo "Merchant candidate created: " . json_encode($candidate) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$applications = $payarc->applications->list();
echo "Applications retrieved: " . json_encode($applications) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$id = 'app_1J*****3';
$merchant = $payarc->applications->retrieve($id);
echo "Merchant candidate retrieved: " . json_encode($merchant) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$id = 'app_1J*****3';
$payload = [
"MerchantBankAccountNo"=> "999999999",
"MerchantBankRoutingNo"=> "1848505",
"BankInstitutionName"=> "Bank of Kolio"
];
try{
$updated_candidate = $payarc
->applications
->update($id, $payload);
echo "Candidate merchant updated: " . json_encode($updated_candidate) . "\n";
}catch (Throwable $e){
echo "Error detected: " . $e->getMessage() . "\n";
}
$doc_data = [
"DocumentType"=> "Business Bank Statement",
"DocumentName"=> "sample document 1",
"DocumentIndex"=> 12246,
"DocumentDataBase64"=> "data:image/jpeg;base64,iVBORw0KGgoAAAANSUhEUgAAAMcAAAAvCAYAAABXEt4pAAAABHNCSVQICAgIfAhkiAAAC11JREFUeF7tXV1yHDUQlsZrkjccB2K/sZwA5wSYil3FG+YEcU6AcwLMCeKcAHMCNm9U2SmcE2CfgPWbHYhZvxHsHdE9O7OZ1WpGX2tmdjA1U0VBsfppfeqv1Wq1ZL26tmVUjR81dsLNaaUHsV56Nbr4ZVhj80lTK+tf9yMz/sYoszPpS22mfZxS/6OivlfWt79EZBldHL1J+lnZXFH3l79A6qi/b85Go5MRVDYtxONQavwZUieTqaisHxN1GuveS3s+Vj7d3lBL6mOfDK7+C+uO1fXoj6PTsjY/Wd/aHBv1HcNM87fB/6Z/RleXxw98sti/sxxRpL7M6UPWHhdNdUKdUj8n4/e3b9B50nWTwxacyWJ071kdJGEQdGRe5MhQiiP1PaC+n2d9o2OlCaIuJh/VYYX3Kg+VeU71DiQTu/po+1Bp89RXh4R58+7yeNNVjkmhze2PAkxm5uPh2tYJ4eQ1GnlMMjk8dQk3vX91efQyL/fDR092jFYv6DcyDPOfqx/nuMlwRR/1viP8dovaKsTVmMMo0j/9eXF8UoZ94+SYdm7U/tXb4x98ilAIxL3e9/TbXkD9kdb6+buLo8Mgcqxv7SujuG/PZ4ZXl68/95XKfp9Y+tvfkfLamG/fvX09sMuuPtr6npbNfaQNq8wUkwbJkXSZl53w5/kjYhR/CDkerj95aoxmQ8SrTfCXGM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merchant['data']['add_document']($doc_data);
echo "Document added: " . json_encode($doc) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$response = $payarc->applications->list();
$applicant = $response['applications'][0];
$details = $applicant['retrieve']();
$document = $details['Documents']['data'][0] ?? null;
if($document){
$doc = $document['delete']();
echo "Document deleted: " . json_encode($doc) . "\n";
} else {
echo "No document to delete\n";
}
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'doc_1J*****3';
$doc = $payarc->applications->delete_document($id);
echo "Document deleted: " . json_encode($doc) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'app_1J*****3';
$applicant = $payarc->applications->submit($id);
echo "Applicant submitted for signature: " . json_encode($applicant) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$campaigns = $payarc->split_campaigns->list();
echo "Campaigns retrieved: " . json_encode($campaigns) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$merchants = $payarc->split_campaigns->list_accounts();
echo "Merchants retrieved: " . json_encode($merchants) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$campaign = $payarc->split_campaigns->create(
[
'name'=> 'Mega bonus',
'description'=> "Compliment for my favorite customers",
'notes'=> "Only for VIPs",
'base_charge'=> 63.33,
'perc_charge'=> 5.7,
'is_default'=> '0',
'accounts'=> []
]
);
echo "Campaign created: " . json_encode($campaign) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'cmp_o3**********86n5';
$campaign = $payarc->split_campaigns->retrieve($id);
echo "Campaign retrieved: " . json_encode($campaign) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$payload = [
'notes'=> "new version of notes"
];
$campaign = $payarc
->split_campaigns
->update($id, $payload);
echo "Campaign updated: " . json_encode($campaign) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$data = [
'name' => 'Monthly billing regular',
'amount' => 999,
'interval' => 'month',
'statement_descriptor' => '2024 MerchantT. srvces'
];
$plan = $payarc->billing->plan->create($data);
echo "Plan created: " . json_encode($plan) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$plans = $payarc->billing->plan->list();
$plan = $plans['plans'][0];
if($plan){
$plan = $plan['update'](['name'=> 'New plan name']);
echo "Plan updated: " . json_encode($plan) . "\n";
}
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'plan_3aln*******8y8';
$plan = $payarc->billing->plan->update($id, ['name'=> 'New plan name']);
echo "Plan updated: " . json_encode($plan) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$plans = $payarc->billing->plan->list(['search'=> 'iron']);
$subscriber = [
'customer_id'=> 'cus_*******AMNNVnjA',
];
$plans = $plans['plans'];
if($plans){
$plan = $plans[0];
if($plan){
$subscription = $plan['create_subscription']($subscriber);
echo "Subscription created: " . json_encode($subscription) . "\n";
}
}
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$subscriber = [
'customer_id'=> 'cus_DPNMVjx4AMNNVnjA',
];
$subscription = $payarc->billing->plan->create_subscription($id, $subscriber);
echo "Subscription created: " . json_encode($subscription) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$subscriptions = $payarc->billing->plan_subscription->list(['limit'=> 3, 'plan'=>'plan_7****f']);
echo "Subscriptions: " . json_encode($subscriptions) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'sub_7****f';
$subscription = $payarc->billing->plan_subscription->update($id, ['description'=> 'Monthly for VIP']);
echo "Subscription updated: " . json_encode($subscription) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'sub_7****f';
$subscription = $payarc->billing->plan_subscription->cancel($id);
echo "Subscription canceled: " . json_encode($subscription) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$cases = $payarc->disputes->list();
echo "Cases: " . json_encode($cases) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try{
$id = 'dis_7****f';
$cases = $payarc->disputes->retrieve($id);
echo "Case: " . json_encode($cases) . "\n";
}catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
$document_base64 = "iVBORw0KGgoAAAANSUhEUgAAAIUAAABsCAYAAABEkXF2AAAABHNCSVQICAgIfAhkiAAAAupJREFUeJzt3cFuEkEcx/E/001qUQ+E4NF48GB4BRM9+i59AE16ANlE4wv4Mp5MjI8gZ+ONEMJBAzaWwZsVf2VnstPZpfb7STh06ewu5JuFnSzQ8d5vDfiLa3sHcHiIAoIoIIgCgiggitwbWM/f2vniTe7NoIZ7Dz9Y0X0qy7NHYfbLtn6dfzOoYXPlUl4+IIgCooGXj10ngzM77p81vVmY2Y9vL+xi9Tn4f41HYVZYx3Wb3yws9oWBlw8IooAgCgiigCAKCKKAIAoIooAgCoikGU3nqpvy3qesPvv6+/2+LZfLpHUcsrrPD0cKCKKAIAoIooAgCgiigCAKCOecs7q3iJXbZDLZWVaWZfR4733lLbfZbBbchzZvvV4vy+PmSAFBFBBEAUEUEEQBQRQQRAFR5DzfD81FxMxVpMg9l3HT938fjhQQRAFBFBBEAUEUEEQBQRQQRe5z7SptnYejGkcKCKKAIAoIooAgCgiigCAKiKQoYj6bMB6Pd8aMRqPoz22kfCalzfmXm45nDoIoIIgCgiggiAKCKCCIAiJrFKnfTxHS9vdX5P7+ibZwpIAgCgiigCAKCKKAIAoIooDomNl2352hc+WY3+NYzyf2c345V3EyGNmdwevo8anbr3Lbfu/j+9fndrH69Ofv+48+WtF9JuM4UkAQBQRRQBAFBFFAEAUEUUBUfo9m6jUPzjl7eWr26vRyWVmW9u59GT2+Suo1B4vFImn8/4ojBQRRQBAFBFFAEAUEUUAQBUTHe7/3eorUeYrQ9RSprmP/UtZ/6OP/xfUUqI0oIIgCgiggiqY36Ddz25x/uZZ1PXmcNj60H6H1H/p4sV1F/VvjZx84HJx9IFrl733wexy3U/b3FO7ogR0dD7OsezqdVt4/HFZvNzQ+t9T9C40P6ty9erElfEKsbblnDHNrekYzFu8pIIgCgiggiAKCKCAqzz5Ccr+7T3133fb1DG0//ro4UkAQBQRRQBAFBFFAEAXEb3wL3JblytFeAAAAAElFTkSuQmCC";
try {
$case = $payarc->disputes->add_document('dis_MV***********AW0', [
'DocumentDataBase64' => $document_base64,
'text' => 'test doc evidence 3'
]);
echo "Document added: " . json_encode($case) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$login = $payarc->payarcConnect->login();
echo "Result: " . print_r($result, true) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->sale(
tenderType: "CREDIT",
ecrRefNum: "REF123",
amount: "100",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->void(
payarcTransactionId: "12345",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->refund(
amount: "100",
payarcTransactionId: "12345",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->blindCredit(
ecrRefNum: "REF123",
amount: "100",
token: "ABC123",
expDate: "0000",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->auth(
ecrRefNum: "REF123",
amount: "100",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->postAuth(
ecrRefNum: "REF123",
origRefNum: "123",
amount: "100",
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->lastTransaction(
deviceSerialNo: "12345"
);
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->serverInfo();
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
try {
$result = $payarc->payarcConnect->terminals();
echo "Result: " . json_encode($result) . "\n";
} catch (Throwable $e) {
echo "Error detected: " . $e->getMessage() . "\n";
}
bash
composer config minimum-stability dev && composer
ini
PAYARC_BASE_URL=''
PAYARC_KEY=''
AGENT_KEY=''
PAYARC_VERSION=1