Ejemplo n.º 1
0
 public function testCreatePayInit()
 {
     $saferpay = new Saferpay();
     $saferpay->setHttpClient(new BuzzClient());
     $payInitParameter = new PayInitParameter();
     $payInitParameter->setAccountid('99867-94913159');
     $payInitParameter->setAmount(1200);
     $payInitParameter->setCurrency('CHF');
     $payInitParameter->setDescription(sprintf('Ordernumber: %s', '000001'));
     $payInitParameter->setSuccesslink('http://test.lo?status=success');
     $payInitParameter->setFaillink('http://test.lo?status=fail');
     $payInitParameter->setBacklink('http://test.lo?status=back');
     $payInitParameter->setDelivery('no');
     // hide address form
     $url = $saferpay->createPayInit($payInitParameter);
     $this->assertStringStartsWith('https://www.saferpay.com/vt2/Pay.aspx', $url);
 }
Ejemplo n.º 2
0
 public function testCreatePayInit()
 {
     $saferpay = new Saferpay();
     $saferpay->setHttpClient(new BuzzClient());
     $payInitParameter = new PayInitParameter();
     $payInitParameter->setAccountid('99867-94913159');
     $payInitParameter->setAmount(1200);
     $payInitParameter->setCurrency('CHF');
     $payInitParameter->setDescription(sprintf('Ordernumber: %s', '000001'));
     $payInitParameter->setOrderid(1);
     $payInitParameter->setSuccesslink('http://test.lo?status=success');
     $payInitParameter->setFaillink('http://test.lo?status=fail');
     $payInitParameter->setBacklink('http://test.lo?status=back');
     $payInitParameter->setProviderset(array(BillpayPayInitParameterInterface::PROVIDERSET_BILLPAY_INVOICE));
     $payInitParameter->setGender(PayInitParameterInterface::GENDER_COMPANY);
     $payInitParameter->setFirstname('John');
     $payInitParameter->setLastname('Doe');
     $payInitParameter->setStreet('Samplestreet 0');
     $payInitParameter->setZip('00000');
     $payInitParameter->setCity('Samplecity');
     $payInitParameter->setCountry('US');
     $payInitParameter->setLangid('EN');
     $payInitParameter->setPhone('+10000000000');
     $payInitParameter->setEmail('*****@*****.**');
     $billpayPayInitParameter = new BillpayPayInitParameter();
     $billpayPayInitParameter->setLegalform(BillpayPayInitParameterInterface::LEGALFORM_MISC);
     $billpayPayInitParameter->setDeliveryGender(PayInitParameterInterface::GENDER_COMPANY);
     $billpayPayInitParameter->setDeliveryFirstname('John');
     $billpayPayInitParameter->setDeliveryLastname('Doe');
     $billpayPayInitParameter->setDeliveryStreet('Samplestreet 0');
     $billpayPayInitParameter->setDeliveryZip('00000');
     $billpayPayInitParameter->setDeliveryCity('Samplecity');
     $billpayPayInitParameter->setDeliveryCountry('US');
     $billpayPayInitParameter->setDeliveryPhone('+10000000000');
     $payInitParameterCollection = new Collection($payInitParameter->getRequestUrl());
     $payInitParameterCollection->addCollectionItem($payInitParameter);
     $payInitParameterCollection->addCollectionItem($billpayPayInitParameter);
     $url = $saferpay->createPayInit($payInitParameterCollection);
     $this->assertStringStartsWith('https://www.saferpay.com/vt2/Pay.aspx', $url);
 }
Ejemplo n.º 3
0
 public function testSetterGetterWithValidData()
 {
     $payInitParameter = new PayInitParameter();
     $payInitParameter->setAccountid(self::ACCOUNTID)->setAmount(self::AMOUNT)->setCssurl(self::CSSURL)->setCurrency(self::CURRENCY)->setDescription(self::DESCRIPTION)->setOrderid(self::ORDERID)->setVtconfig(self::VTCONFIG)->setSuccesslink(self::SUCCESSLINK)->setFaillink(self::FAILLINK)->setBacklink(self::BACKLINK)->setNotifyurl(self::NOTIFYURL)->setAutoclose(self::AUTOCLOSE)->setCcname(self::CCNAME)->setNotifyaddress(self::NOTIFYADDRESS)->setUsernotify(self::USERNOTIFY)->setLangid(self::LANGID)->setShowlanguages(self::SHOWLANGUAGES)->setPaymentmethods(unserialize(self::PAYMENTMETHODS))->setProviderset(unserialize(self::PROVIDERSET))->setDuration(self::DURATION)->setCardrefid(self::CARDREFID)->setDelivery(self::DELIVERY)->setAppearance(self::APPEARANCE)->setAddress(self::ADDRESS)->setCompany(self::COMPANY)->setGender(self::GENDER)->setFirstname(self::FIRSTNAME)->setLastname(self::LASTNAME)->setStreet(self::STREET)->setZip(self::ZIP)->setCity(self::CITY)->setCountry(self::COUNTRY)->setEmail(self::EMAIL)->setPhone(self::PHONE);
     $this->assertEquals(self::ACCOUNTID, $payInitParameter->getAccountid());
     $this->assertEquals(self::AMOUNT, $payInitParameter->getAmount());
     $this->assertEquals(self::CSSURL, $payInitParameter->getCssurl());
     $this->assertEquals(self::CURRENCY, $payInitParameter->getCurrency());
     $this->assertEquals(self::DESCRIPTION, $payInitParameter->getDescription());
     $this->assertEquals(self::ORDERID, $payInitParameter->getOrderid());
     $this->assertEquals(self::VTCONFIG, $payInitParameter->getVtconfig());
     $this->assertEquals(self::SUCCESSLINK, $payInitParameter->getSuccesslink());
     $this->assertEquals(self::FAILLINK, $payInitParameter->getFaillink());
     $this->assertEquals(self::BACKLINK, $payInitParameter->getBacklink());
     $this->assertEquals(self::NOTIFYURL, $payInitParameter->getNotifyurl());
     $this->assertEquals(self::AUTOCLOSE, $payInitParameter->getAutoclose());
     $this->assertEquals(self::CCNAME, $payInitParameter->getCcname());
     $this->assertEquals(self::NOTIFYADDRESS, $payInitParameter->getNotifyaddress());
     $this->assertEquals(self::USERNOTIFY, $payInitParameter->getUsernotify());
     $this->assertEquals(self::LANGID, $payInitParameter->getLangid());
     $this->assertEquals(self::SHOWLANGUAGES, $payInitParameter->getShowlanguages());
     $this->assertEquals(unserialize(self::PAYMENTMETHODS), $payInitParameter->getPaymentmethods());
     $this->assertEquals(unserialize(self::PROVIDERSET), $payInitParameter->getProviderset());
     $this->assertEquals(self::DURATION, $payInitParameter->getDuration());
     $this->assertEquals(self::CARDREFID, $payInitParameter->getCardrefid());
     $this->assertEquals(self::DELIVERY, $payInitParameter->getDelivery());
     $this->assertEquals(self::APPEARANCE, $payInitParameter->getAppearance());
     $this->assertEquals(self::ADDRESS, $payInitParameter->getAddress());
     $this->assertEquals(self::COMPANY, $payInitParameter->getCompany());
     $this->assertEquals(self::GENDER, $payInitParameter->getGender());
     $this->assertEquals(self::FIRSTNAME, $payInitParameter->getFirstname());
     $this->assertEquals(self::LASTNAME, $payInitParameter->getLastname());
     $this->assertEquals(self::STREET, $payInitParameter->getStreet());
     $this->assertEquals(self::ZIP, $payInitParameter->getZip());
     $this->assertEquals(self::CITY, $payInitParameter->getCity());
     $this->assertEquals(self::COUNTRY, $payInitParameter->getCountry());
     $this->assertEquals(self::EMAIL, $payInitParameter->getEmail());
     $this->assertEquals(self::PHONE, $payInitParameter->getPhone());
     $this->assertCount(0, $payInitParameter->getInvalidData());
 }
Ejemplo n.º 4
0
$saferpay = new Saferpay();
$saferpay->setHttpClient(new BuzzClient());
$amount = 1200;
$currency = 'CHF';
if (getParam('status') == 'success') {
    $payConfirmParameter = $saferpay->verifyPayConfirm(getParam('DATA'), getParam('SIGNATURE'));
    if ($payConfirmParameter->get('AMOUNT') == $amount && $payConfirmParameter->get('CURRENCY') == $currency) {
        $saferpay->payCompleteV2($payConfirmParameter, 'Settlement');
        echo 'payment success!';
    } else {
        $saferpay->payCompleteV2($payConfirmParameter, 'Cancel');
        echo 'payment failed!';
    }
} else {
    $payInitParameter = new PayInitParameter();
    $payInitParameter->setAccountid(PayInitParameter::SAFERPAYTESTACCOUNT_ACCOUNTID);
    $payInitParameter->setAmount($amount);
    $payInitParameter->setCurrency($currency);
    $payInitParameter->setDescription(sprintf('Ordernumber: %s', '000001'));
    $payInitParameter->setSuccesslink(requestUrl() . '?status=success');
    $payInitParameter->setFaillink(requestUrl() . '?status=fail');
    $payInitParameter->setBacklink(requestUrl() . '?status=back');
    $payInitParameter->setDelivery('no');
    // hide address form
    header('Location: ' . $saferpay->createPayInit($payInitParameter), 302);
}
function requestUrl()
{
    $protocol = strtolower(substr($_SERVER['SERVER_PROTOCOL'], 0, strpos($_SERVER['SERVER_PROTOCOL'], '/')));
    return $protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
}