PHP code example of peach / oppwa

1. Go to this page and download the library: Download peach/oppwa 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/ */

    

peach / oppwa example snippets


$config = new \Peach\Oppwa\Configuration(
    'set_your_user_id',
    'set_your_password',
    'set_your_entity_id'
);

$client = new \Peach\Oppwa\Client($config);


$client = new \Peach\Oppwa\Client([
    'set_your_user_id',
    'set_your_password',
    'set_your_entity_id']
);

$client = new \Peach\Oppwa\Client(
    'set_your_user_id',
    'set_your_password',
    'set_your_entity_id'
);

    $client->setTestMode(true);

if ($response->isSuccess()) {
 // was successful
}

$paymentStatus = new \Peach\Oppwa\Payments\Status($client);
$paymentStatusResult = $paymentStatus
    ->setTransactionId('8a82944a55c5c6620155ca4667222d20')
    ->process();

var_dump(json_decode((string)$paymentStatusResult, JSON_PRETTY_PRINT));

$storeCard = new \Peach\Oppwa\Cards\Store($testClient);
$storeCardResult = $storeCard->setCardBrand(\Peach\Oppwa\Cards\Brands::MASTERCARD)
    ->setCardNumber('5454545454545454')
    ->setCardHolder('Jane Jones')
    ->setCardExpiryMonth('05')
    ->setCardExpiryYear('2018')
    ->setCardCvv('123')
    ->process();

$cardDelete = new \Peach\Oppwa\Cards\Delete($testClient);
$cardDelete->setTransactionId($storeCardResult->getId());
$cardDeleteResult = $cardDelete->process();

$debit = new \Peach\Oppwa\Payments\Debit($testClient);
$debitResult = $debit
    ->setCardBrand(\Peach\Oppwa\Cards\Brands::MASTERCARD)
    ->setCardNumber('5454545454545454')
    ->setCardHolder('Jane Jones')
    ->setCardExpiryMonth('05')
    ->setCardExpiryYear('2018')
    ->setCardCvv('123')
    ->setAmount(95.99)
    ->setCurrency('EUR')
    ->setAuthOnly(false)
    ->process();

$preAuthorization = new \Peach\Oppwa\Payments\Debit($testClient);
$preAuthorizationResult = $preAuthorization
    ->setCardBrand(\Peach\Oppwa\Cards\Brands::MASTERCARD)
    ->setCardNumber('5454545454545454')
    ->setCardHolder('Jane Jones')
    ->setCardExpiryMonth('05')
    ->setCardExpiryYear('2018')
    ->setCardCvv('123')
    ->setAmount(95.99)
    ->setCurrency('EUR')
    ->setAuthOnly(true)
    ->process();

$capture = new \Peach\Oppwa\Payments\Capture($testClient, $preAuthorizationResult->getId(), '95.99', 'EUR');
$captureResult = $capture->process();

$reverse = new \Peach\Oppwa\Payments\Reverse($testClient, $captureResult->getId());
$reverseResult = $reverse->process();

$reverse = new \Peach\Oppwa\Payments\Reverse($testClient, $captureResult->getId(), '50', 'EUR');
$reverseResult = $reverse->process();