public function test_builds()
 {
     $m = Mockery::mock('Mcprohosting\\Ccbill\\Forms\\Builders\\Builder');
     $m->shouldReceive('build')->with($this->client, $this->form)->andReturn('foo');
     $this->assertEquals('foo', $this->form->build($m));
 }
Пример #2
0
 public function test_input_builder()
 {
     $this->assertEquals('<input type="hidden" name="formName" value="75cc">' . '<input type="hidden" name="formPrice" value="18.00">' . '<input type="hidden" name="formPeriod" value="10">' . '<input type="hidden" name="currencyCode" value="840">' . '<input type="hidden" name="clientSubacc" value="456">' . '<input type="hidden" name="clientAccnum" value="123">' . '<input type="hidden" name="formDigest" value="d9d6e044d6663cd05d07e15735205a7f">', $this->form->build(new InputBuilder()));
 }
Пример #3
0
<?php

use Mcprohosting\Ccbill\Client\CcbillClient as Client;
use Mcprohosting\Ccbill\Forms\DynamicPricingForm;
use Mcprohosting\Ccbill\CurrencyCode;
use Mcprohosting\Ccbill\Forms\Builders\UrlBuilder;
// First, make the ccbill client
$client = new Client(['accnum' => '123', 'subacc' => '456', 'salt' => '789']);
// Then create the form for a dynamic pricing request.
$form = new DynamicPricingForm($client, ['formName' => '75cc', 'formPrice' => '18.00', 'formPeriod' => 10, 'currencyCode' => CurrencyCode::from('USD')]);
// If we're returning from ccbill, try to verify the form.
if (count($_POST)) {
    if ($form->capture()->isSuccessful()) {
        echo 'Your payment has been processed!';
    } else {
        echo 'Oh no, something went wrong!';
    }
} else {
    echo 'Go to this address to purchase: ' . $form->build(new UrlBuilder());
}