Example #1
0
 public function refund($orderId, $amount)
 {
     $token = $this->getToken();
     $response = $this->request('order/refund', array('orderId' => $orderId, 'amount' => $amount), $token->getAccessToken());
     $order = new Order();
     $order->fromArray($response['order']);
     $order->validate();
     return $order;
 }
Example #2
0
require __DIR__ . '/../../vendor/autoload.php';
$dotenv = new Dotenv(__DIR__ . '/../../');
$dotenv->load();
if ($_ENV['COINFIDE_USER'] == 'yourapiusername') {
    die('Please copy .env.example file to .env and fill in your Coinfide credentials');
}
\Symfony\Component\Debug\Debug::enable();
/*
 * Configure this values in your Dashboard,
 * Profile - Business details - API username and API secret key
 */
$client = new Client(array('trace' => true));
$client->setMode($_ENV['COINFIDE_MODE']);
$client->setCredentials($_ENV['COINFIDE_USER'], $_ENV['COINFIDE_PASSWORD']);
/* test full phone */
$order = new Order();
$phone = new Phone();
$phone->setFullNumber('37121234567');
$seller = new Account();
//important!! change this to your actual e-mail, or the example will not work
$seller->setEmail('*****@*****.**');
$order->setSeller($seller);
$buyer = new Account();
$buyer->setEmail('*****@*****.**');
$buyer->setPhone($phone);
$order->setBuyer($buyer);
$order->setCurrencyCode('EUR');
$orderItem = new OrderItem();
$orderItem->setType('I');
$orderItem->setName('Some random goods');
$orderItem->setPriceUnit(12.34);
Example #3
0
 /**
  * both checks serialization and validation
  */
 public function testOrderSerialize()
 {
     $json = json_decode(file_get_contents(__DIR__ . '/fixtures/example_order.json'), true);
     $seller = new Account();
     $seller->setEmail('*****@*****.**');
     $sellerPhone = new Phone();
     $sellerPhone->setCountryCode('371');
     $sellerPhone->setNumber('20000000');
     $sellerAddress = new Address();
     $sellerAddress->setCountryCode('LV');
     $sellerAddress->setCity('Riga');
     $sellerAddress->setFirstAddressLine('Duntes 4');
     $sellerAddress->setSecondAddressLine('Office 403');
     $sellerAddress->setState('Rigas');
     $sellerAddress->setPostalCode('LV-2020');
     $seller->setAddress($sellerAddress);
     $seller->setPhone($sellerPhone);
     $seller->setBirthDate('19951015000000');
     $seller->setWebsite('http://www.example.com');
     $seller->setTaxpayerIdentificationNumber('TAX83642');
     $seller->setAdditionalInfo('Additional information for buyer');
     $buyer = new Account();
     $buyer->setEmail('*****@*****.**');
     $buyerPhone = new Phone();
     $buyerPhone->setCountryCode('371');
     $buyerPhone->setNumber('21111111');
     $buyer->setName('Anna');
     $buyer->setSurname('Borg');
     $buyer->setLanguage('en');
     $buyerAddress = new Address();
     $buyerAddress->setCountryCode('LV');
     $buyerAddress->setCity('Riga');
     $buyerAddress->setFirstAddressLine('Brivibas 1/2');
     $buyerAddress->setSecondAddressLine('Office 404');
     $buyerAddress->setState('Rigas');
     $buyerAddress->setPostalCode('LV-1010');
     $buyer->setAddress($buyerAddress);
     $buyer->setPhone($buyerPhone);
     $order = new Order();
     $buyer->setEmail('*****@*****.**');
     $order->setSeller($seller);
     $order->setBuyer($buyer);
     $order->setCurrencyCode('EUR');
     $order->setDiscountAmount(0.0);
     $order->setDiscountPercent(0.0);
     $order->setIssueDate('20151001184000');
     $order->setDueDate('20171201184000');
     $order->setExternalOrderId('TSPV000001');
     $order->setReference('REF582764');
     $order->setNote('Some note here');
     $order->setTerms('Terms and conditions');
     $order->setAmountTotal(110);
     $affiliateInfo = new AffiliateInfo();
     $affiliateInfo->setAffiliateId('AF4');
     $affiliateInfo->setCampaignId('C539');
     $affiliateInfo->setBannerId('BRT13');
     $affiliateInfo->setCustomParameters('tr=24&hd=3');
     $order->setAffiliateInfo($affiliateInfo);
     $order->setAcceptPaymentsIfOrderExpired(true);
     $order->setTaxBeforeDiscount(true);
     $order->setTaxInclusive(true);
     $order->setSuccessUrl('http://seller.success.url');
     $order->setPaymentPageUrl('http://seller.payment.page.url');
     $order->setFailUrl('http://seller.fail.url');
     $order->setProvisionChannel('123456');
     $orderItem = new OrderItem();
     $orderItem->setType('I');
     $orderItem->setName('Item1');
     $orderItem->setDescription('First item description');
     $orderItem->setPriceUnit(10.0);
     $orderItem->setQuantity(10);
     $orderItem->setDiscountAmount(0);
     $orderItem->setDiscountPercent(10);
     $tax = new Tax();
     $tax->setRate(20);
     $tax->setName('Tax 20%');
     $orderItem->setTax($tax);
     $order->addOrderItem($orderItem);
     $orderItem = new OrderItem();
     $orderItem->setType('S');
     $orderItem->setName('Shipping with FedEx');
     $orderItem->setPriceUnit(20.0);
     $orderItem->setQuantity(1);
     $tax = new Tax();
     $tax->setRate(10);
     $tax->setName('Tax 10%');
     $orderItem->setTax($tax);
     $order->addOrderItem($orderItem);
     $shippingAddress = new Address();
     $shippingAddress->setCountryCode('MT');
     $shippingAddress->setCity('M\'scala');
     $shippingAddress->setFirstAddressLine('Triq Il-Buhagiar');
     $shippingAddress->setSecondAddressLine('Fl.2, Hortana Court');
     $shippingAddress->setState('South');
     $shippingAddress->setPostalCode('MSK2100');
     $order->setShippingAddress($shippingAddress);
     $this->assertEquals($json, array('order' => $order->toArray()));
 }
Example #4
0
if ($_ENV['COINFIDE_USER'] == 'yourapiusername') {
    die('Please copy .env.example file to .env and fill in your Coinfide credentials');
}
\Symfony\Component\Debug\Debug::enable();
/*
 * Configure this values in your Dashboard,
 * Profile - Business details - API username and API secret key
 */
$client = new Client();
$client->setMode($_ENV['COINFIDE_MODE']);
$client->setCredentials($_ENV['COINFIDE_USER'], $_ENV['COINFIDE_PASSWORD']);
/*
 * Create order; this is a minimal amount of values needed to submit an order. For full example, consult order methods
 * or test/SerializationTest
 */
$order = new Order();
$seller = new Account();
//important!! change this to your actual e-mail, or the example will not work
$seller->setEmail('*****@*****.**');
$order->setSeller($seller);
$buyer = new Account();
$buyer->setEmail('*****@*****.**');
$order->setBuyer($buyer);
$order->setCurrencyCode('EUR');
$order->setExternalOrderId('external_order_id');
$orderItem = new OrderItem();
$orderItem->setType('I');
$orderItem->setName('Some random goods');
$orderItem->setPriceUnit(12.34);
$orderItem->setQuantity(1.23);
$order->addOrderItem($orderItem);