Example #1
0
$firstBoughtItem = WebPayItem::orderRow();
$firstBoughtItem->setAmountExVat(10.99);
$firstBoughtItem->setVatPercent(25);
$firstBoughtItem->setQuantity(1);
$firstBoughtItem->setDescription("Billy");
$firstBoughtItem->setArticleNumber("123456789A");
// Add firstBoughtItem to order row
$myOrder->addOrderRow($firstBoughtItem);
// Add secondBoughtItem in a fluent fashion
$myOrder->addOrderRow(WebPayItem::orderRow()->setAmountIncVat(5.0)->setVatPercent(12)->setQuantity(2)->setDescription("Korv med bröd"));
// For card orders the ->addCustomerDetails() method is optional, but recommended, so we'll add what info we have
$myCustomerInformation = WebPayItem::individualCustomer();
// there's also a ::companyCustomer() method, used for non-person entities
// Set customer information, using the methods from the IndividualCustomer class
$myCustomerInformation->setName($customerFirstName, $customerLastName);
$sveaAddress = Svea\Helper::splitStreetAddress($customerAddress);
// Svea requires an address and a house number
$myCustomerInformation->setStreetAddress($sveaAddress[0], $sveaAddress[1]);
$myCustomerInformation->setZipCode($customerZipCode)->setLocality($customerCity);
$myOrder->addCustomerDetails($myCustomerInformation);
// We have now completed specifying the order, and wish to send the payment request to Svea. To do so, we first select a payment method.
// For card orders, we recommend using the ->usePaymentMethod(PaymentMethod::SVEACARDPAY).
$myCardOrderRequest = $myOrder->usePaymentMethod(PaymentMethod::SVEACARDPAY);
// Then set any additional required request attributes as detailed below. (See Svea\PaymentMethodPayment and Svea\HostedPayment classes for details.)
$myCardOrderRequest->setCardPageLanguage("SV")->setReturnUrl("http://localhost/" . getPath() . "/landingpage.php");
// The return url where we receive and process the finished request response
// Get a payment form object which you can use to send the payment request to Svea
$myCardOrderPaymentForm = $myCardOrderRequest->getPaymentForm();
// Then send the form to Svea, and receive the response on the landingpage after the customer has completed the card checkout SveaCardPay
echo "<pre>";
print_r("press submit to send the card payment request to Svea");