-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathcharge.php
54 lines (49 loc) · 1.7 KB
/
charge.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
/*
* This file is part of the WayForPay project.
*
* @link https://github.com/wayforpay/php-sdk
*
* @author Vladislav Lyshenko <vladdnepr1989@gmail.com>
* @copyright Copyright 2019 WayForPay
* @license https://opensource.org/licenses/MIT
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../vendor/autoload.php';
use WayForPay\SDK\Collection\ProductCollection;
use WayForPay\SDK\Credential\AccountSecretTestCredential;
use WayForPay\SDK\Domain\Card;
use WayForPay\SDK\Domain\Client;
use WayForPay\SDK\Domain\Product;
use WayForPay\SDK\Exception\ApiException;
use WayForPay\SDK\Wizard\ChargeWizard;
// Use test credential or yours
$credential = new AccountSecretTestCredential();
//$credential = new AccountSecretCredential('account', 'secret');
try {
$response = ChargeWizard::get($credential)
->setOrderReference(sha1(microtime(true)))
->setAmount(0.01)
->setCurrency('USD')
->setOrderDate(new \DateTime())
->setMerchantDomainName('https://google.com')
->setClient(new Client(
'John',
'Dou',
'john.dou@gmail.com',
'+12025550152',
'USA'
))
->setProducts(new ProductCollection(array(
new Product('test', 0.01, 1)
)))
->setCard(new Card('5276999765600381', '05', '2021', '237', 'JOHN DOU'))
//->setCardToken(new CardToken('1aa11aaa-1111-11aa-a1a1-0000a00a00aa'))
->getRequest()
->send();
echo 'Status: ' . $response->getTransaction()->getStatus() . PHP_EOL;
} catch (ApiException $e) {
echo "Exception: {$e->getMessage()}\n";
}