@@ -30,10 +30,10 @@ discard block |
||
30 | 30 | { |
31 | 31 | $xml = mb_convert_encoding($xml, "UTF-8", "UTF-8,ISO-8859-1"); |
32 | 32 | $parser = xml_parser_create(); |
33 | - if (!xml_parse($parser, $xml)) { |
|
33 | + if ( ! xml_parse($parser, $xml)) { |
|
34 | 34 | throw new Exception( |
35 | - "PagSeguroLibrary XML parsing error: (" . xml_get_error_code($parser) . |
|
36 | - ") " . xml_error_string(xml_get_error_code($parser)) |
|
35 | + "PagSeguroLibrary XML parsing error: (".xml_get_error_code($parser). |
|
36 | + ") ".xml_error_string(xml_get_error_code($parser)) |
|
37 | 37 | ); |
38 | 38 | } else { |
39 | 39 | $this->dom = new DOMDocument(); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | /*** @var $node DOMNode */ |
63 | 63 | if ($node->hasChildNodes()) { |
64 | 64 | foreach ($node->childNodes as $child) { |
65 | - if (!isset($occurrence[$child->nodeName])) { |
|
65 | + if ( ! isset($occurrence[$child->nodeName])) { |
|
66 | 66 | $occurrence[$child->nodeName] = null; |
67 | 67 | } |
68 | 68 | $occurrence[$child->nodeName]++; |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | } |
99 | 99 | if ($node->hasAttributes()) { |
100 | 100 | $attributes = $node->attributes; |
101 | - if (!is_null($attributes)) { |
|
101 | + if ( ! is_null($attributes)) { |
|
102 | 102 | foreach ($attributes as $key => $attr) { |
103 | - $result["@" . $attr->name] = $attr->value; |
|
103 | + $result["@".$attr->name] = $attr->value; |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | } |
@@ -24,90 +24,90 @@ |
||
24 | 24 | class PagSeguroXmlParser |
25 | 25 | { |
26 | 26 | |
27 | - private $dom; |
|
27 | + private $dom; |
|
28 | 28 | |
29 | - public function __construct($xml) |
|
30 | - { |
|
29 | + public function __construct($xml) |
|
30 | + { |
|
31 | 31 | $xml = mb_convert_encoding($xml, "UTF-8", "UTF-8,ISO-8859-1"); |
32 | - $parser = xml_parser_create(); |
|
33 | - if (!xml_parse($parser, $xml)) { |
|
34 | - throw new Exception( |
|
35 | - "PagSeguroLibrary XML parsing error: (" . xml_get_error_code($parser) . |
|
36 | - ") " . xml_error_string(xml_get_error_code($parser)) |
|
37 | - ); |
|
38 | - } else { |
|
39 | - $this->dom = new DOMDocument(); |
|
40 | - $this->dom->loadXml($xml); |
|
41 | - } |
|
42 | - } |
|
32 | + $parser = xml_parser_create(); |
|
33 | + if (!xml_parse($parser, $xml)) { |
|
34 | + throw new Exception( |
|
35 | + "PagSeguroLibrary XML parsing error: (" . xml_get_error_code($parser) . |
|
36 | + ") " . xml_error_string(xml_get_error_code($parser)) |
|
37 | + ); |
|
38 | + } else { |
|
39 | + $this->dom = new DOMDocument(); |
|
40 | + $this->dom->loadXml($xml); |
|
41 | + } |
|
42 | + } |
|
43 | 43 | |
44 | - public function getResult($node = null) |
|
45 | - { |
|
46 | - $result = $this->toArray($this->dom); |
|
47 | - if ($node) { |
|
48 | - if (isset($result[$node])) { |
|
49 | - return $result[$node]; |
|
50 | - } else { |
|
51 | - throw new Exception("PagSeguroLibrary XML parsing error: undefined index [$node]"); |
|
52 | - } |
|
53 | - } else { |
|
54 | - return $result; |
|
55 | - } |
|
56 | - } |
|
44 | + public function getResult($node = null) |
|
45 | + { |
|
46 | + $result = $this->toArray($this->dom); |
|
47 | + if ($node) { |
|
48 | + if (isset($result[$node])) { |
|
49 | + return $result[$node]; |
|
50 | + } else { |
|
51 | + throw new Exception("PagSeguroLibrary XML parsing error: undefined index [$node]"); |
|
52 | + } |
|
53 | + } else { |
|
54 | + return $result; |
|
55 | + } |
|
56 | + } |
|
57 | 57 | |
58 | - private function toArray($node) |
|
59 | - { |
|
60 | - $occurrence = array(); |
|
61 | - $result = null; |
|
62 | - /*** @var $node DOMNode */ |
|
63 | - if ($node->hasChildNodes()) { |
|
64 | - foreach ($node->childNodes as $child) { |
|
65 | - if (!isset($occurrence[$child->nodeName])) { |
|
66 | - $occurrence[$child->nodeName] = null; |
|
67 | - } |
|
68 | - $occurrence[$child->nodeName]++; |
|
69 | - } |
|
70 | - } |
|
71 | - if (isset($child)) { |
|
72 | - if ($child->nodeName == '#text') { |
|
73 | - $result = html_entity_decode( |
|
74 | - htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), |
|
75 | - ENT_COMPAT, |
|
76 | - 'ISO-8859-15' |
|
77 | - ); |
|
78 | - } else { |
|
79 | - if ($node->hasChildNodes()) { |
|
80 | - $children = $node->childNodes; |
|
81 | - for ($i = 0; $i < $children->length; $i++) { |
|
82 | - $child = $children->item($i); |
|
83 | - if ($child->nodeName != '#text') { |
|
84 | - if ($occurrence[$child->nodeName] > 1) { |
|
85 | - $result[$child->nodeName][] = $this->toArray($child); |
|
86 | - } else { |
|
87 | - $result[$child->nodeName] = $this->toArray($child); |
|
88 | - } |
|
89 | - } else { |
|
90 | - if ($child->nodeName == '0') { |
|
91 | - $text = $this->toArray($child); |
|
92 | - if (trim($text) != '') { |
|
93 | - $result[$child->nodeName] = $this->toArray($child); |
|
94 | - } |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
98 | - } |
|
99 | - if ($node->hasAttributes()) { |
|
100 | - $attributes = $node->attributes; |
|
101 | - if (!is_null($attributes)) { |
|
102 | - foreach ($attributes as $key => $attr) { |
|
103 | - $result["@" . $attr->name] = $attr->value; |
|
104 | - } |
|
105 | - } |
|
106 | - } |
|
107 | - } |
|
108 | - return $result; |
|
109 | - } else { |
|
110 | - return null; |
|
111 | - } |
|
112 | - } |
|
58 | + private function toArray($node) |
|
59 | + { |
|
60 | + $occurrence = array(); |
|
61 | + $result = null; |
|
62 | + /*** @var $node DOMNode */ |
|
63 | + if ($node->hasChildNodes()) { |
|
64 | + foreach ($node->childNodes as $child) { |
|
65 | + if (!isset($occurrence[$child->nodeName])) { |
|
66 | + $occurrence[$child->nodeName] = null; |
|
67 | + } |
|
68 | + $occurrence[$child->nodeName]++; |
|
69 | + } |
|
70 | + } |
|
71 | + if (isset($child)) { |
|
72 | + if ($child->nodeName == '#text') { |
|
73 | + $result = html_entity_decode( |
|
74 | + htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), |
|
75 | + ENT_COMPAT, |
|
76 | + 'ISO-8859-15' |
|
77 | + ); |
|
78 | + } else { |
|
79 | + if ($node->hasChildNodes()) { |
|
80 | + $children = $node->childNodes; |
|
81 | + for ($i = 0; $i < $children->length; $i++) { |
|
82 | + $child = $children->item($i); |
|
83 | + if ($child->nodeName != '#text') { |
|
84 | + if ($occurrence[$child->nodeName] > 1) { |
|
85 | + $result[$child->nodeName][] = $this->toArray($child); |
|
86 | + } else { |
|
87 | + $result[$child->nodeName] = $this->toArray($child); |
|
88 | + } |
|
89 | + } else { |
|
90 | + if ($child->nodeName == '0') { |
|
91 | + $text = $this->toArray($child); |
|
92 | + if (trim($text) != '') { |
|
93 | + $result[$child->nodeName] = $this->toArray($child); |
|
94 | + } |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | + } |
|
99 | + if ($node->hasAttributes()) { |
|
100 | + $attributes = $node->attributes; |
|
101 | + if (!is_null($attributes)) { |
|
102 | + foreach ($attributes as $key => $attr) { |
|
103 | + $result["@" . $attr->name] = $attr->value; |
|
104 | + } |
|
105 | + } |
|
106 | + } |
|
107 | + } |
|
108 | + return $result; |
|
109 | + } else { |
|
110 | + return null; |
|
111 | + } |
|
112 | + } |
|
113 | 113 | } |
@@ -26,80 +26,79 @@ |
||
26 | 26 | class CreateAuthorization |
27 | 27 | { |
28 | 28 | |
29 | - /** |
|
30 | - * |
|
31 | - */ |
|
32 | - public static function main() |
|
33 | - { |
|
34 | - // Instantiate a new authorization request |
|
35 | - $authorizationRequest = new PagSeguroAuthorizationRequest(); |
|
36 | - |
|
37 | - $authorizationRequest->setReference('REF123'); |
|
38 | - |
|
39 | - $authorizationRequest->setRedirectURL( |
|
40 | - 'http://www.lojamodelo.com.br'); |
|
41 | - |
|
42 | - $authorizationRequest->setNotificationURL( |
|
43 | - 'http://www.lojamodelo.com.br'); |
|
44 | - |
|
45 | - /** |
|
46 | - * @enum "CREATE_CHECKOUTS", |
|
47 | - * @enum "RECEIVE_TRANSACTION_NOTIFICATIONS", |
|
48 | - * @enum "SEARCH_TRANSACTIONS", |
|
49 | - * @enum "MANAGE_PAYMENT_PRE_APPROVALS", |
|
50 | - * @enum "DIRECT_PAYMENT", |
|
51 | - * @enum "REFUND_TRANSACTIONS", |
|
52 | - * @enum "CANCEL_TRANSACTIONS" |
|
53 | - |
|
54 | - */ |
|
55 | - $authorizationRequest->setPermissions( |
|
56 | - array( |
|
57 | - "CREATE_CHECKOUTS", |
|
58 | - "RECEIVE_TRANSACTION_NOTIFICATIONS", |
|
59 | - "SEARCH_TRANSACTIONS", |
|
60 | - "MANAGE_PAYMENT_PRE_APPROVALS", |
|
61 | - "DIRECT_PAYMENT", |
|
62 | - "REFUND_TRANSACTIONS", |
|
63 | - "CANCEL_TRANSACTIONS" |
|
64 | - ) |
|
65 | - ); |
|
66 | - |
|
67 | - try { |
|
68 | - /** |
|
69 | - * #### Credentials ##### |
|
70 | - * Replace the parameters below with your credentials |
|
71 | - * You can also get your credentials from a config file. See an example: |
|
72 | - * $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
73 | - */ |
|
74 | - $credentials = new PagSeguroApplicationCredentials("appId", |
|
75 | - "appKey"); |
|
76 | - |
|
77 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
78 | - $return = $authorizationRequest->register($credentials); |
|
79 | - |
|
80 | - self::printAuthorizationReturn($return); |
|
81 | - |
|
82 | - } catch (PagSeguroServiceException $e) { |
|
83 | - die($e->getMessage()); |
|
84 | - } |
|
85 | - } |
|
86 | - |
|
87 | - public static function printAuthorizationReturn($authorization) |
|
88 | - { |
|
89 | - |
|
90 | - if ($authorization) { |
|
91 | - echo "<h2>Retorno da requisição de Autorização</h2>"; |
|
92 | - |
|
93 | - if(filter_var($authorization, FILTER_VALIDATE_URL)) { |
|
94 | - |
|
95 | - echo "<p><strong>URL: </strong>" . $authorization . "</p> "; |
|
96 | - echo "<p><a title=\"URL do pagamento\" href=\"$authorization\">" . "Ir para URL de autorização" . "</a></p>"; |
|
97 | - } else { |
|
98 | - |
|
99 | - echo "<p><strong>Code: </strong>" . $authorization . "</p> "; |
|
100 | - } |
|
101 | - } |
|
102 | - } |
|
29 | + /** |
|
30 | + * |
|
31 | + */ |
|
32 | + public static function main() |
|
33 | + { |
|
34 | + // Instantiate a new authorization request |
|
35 | + $authorizationRequest = new PagSeguroAuthorizationRequest(); |
|
36 | + |
|
37 | + $authorizationRequest->setReference('REF123'); |
|
38 | + |
|
39 | + $authorizationRequest->setRedirectURL( |
|
40 | + 'http://www.lojamodelo.com.br'); |
|
41 | + |
|
42 | + $authorizationRequest->setNotificationURL( |
|
43 | + 'http://www.lojamodelo.com.br'); |
|
44 | + |
|
45 | + /** |
|
46 | + * @enum "CREATE_CHECKOUTS", |
|
47 | + * @enum "RECEIVE_TRANSACTION_NOTIFICATIONS", |
|
48 | + * @enum "SEARCH_TRANSACTIONS", |
|
49 | + * @enum "MANAGE_PAYMENT_PRE_APPROVALS", |
|
50 | + * @enum "DIRECT_PAYMENT", |
|
51 | + * @enum "REFUND_TRANSACTIONS", |
|
52 | + * @enum "CANCEL_TRANSACTIONS" |
|
53 | + */ |
|
54 | + $authorizationRequest->setPermissions( |
|
55 | + array( |
|
56 | + "CREATE_CHECKOUTS", |
|
57 | + "RECEIVE_TRANSACTION_NOTIFICATIONS", |
|
58 | + "SEARCH_TRANSACTIONS", |
|
59 | + "MANAGE_PAYMENT_PRE_APPROVALS", |
|
60 | + "DIRECT_PAYMENT", |
|
61 | + "REFUND_TRANSACTIONS", |
|
62 | + "CANCEL_TRANSACTIONS" |
|
63 | + ) |
|
64 | + ); |
|
65 | + |
|
66 | + try { |
|
67 | + /** |
|
68 | + * #### Credentials ##### |
|
69 | + * Replace the parameters below with your credentials |
|
70 | + * You can also get your credentials from a config file. See an example: |
|
71 | + * $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
72 | + */ |
|
73 | + $credentials = new PagSeguroApplicationCredentials("appId", |
|
74 | + "appKey"); |
|
75 | + |
|
76 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
77 | + $return = $authorizationRequest->register($credentials); |
|
78 | + |
|
79 | + self::printAuthorizationReturn($return); |
|
80 | + |
|
81 | + } catch (PagSeguroServiceException $e) { |
|
82 | + die($e->getMessage()); |
|
83 | + } |
|
84 | + } |
|
85 | + |
|
86 | + public static function printAuthorizationReturn($authorization) |
|
87 | + { |
|
88 | + |
|
89 | + if ($authorization) { |
|
90 | + echo "<h2>Retorno da requisição de Autorização</h2>"; |
|
91 | + |
|
92 | + if(filter_var($authorization, FILTER_VALIDATE_URL)) { |
|
93 | + |
|
94 | + echo "<p><strong>URL: </strong>" . $authorization . "</p> "; |
|
95 | + echo "<p><a title=\"URL do pagamento\" href=\"$authorization\">" . "Ir para URL de autorização" . "</a></p>"; |
|
96 | + } else { |
|
97 | + |
|
98 | + echo "<p><strong>Code: </strong>" . $authorization . "</p> "; |
|
99 | + } |
|
100 | + } |
|
101 | + } |
|
103 | 102 | } |
104 | 103 | |
105 | 104 | CreateAuthorization::main(); |
106 | 105 | \ No newline at end of file |
@@ -90,13 +90,13 @@ |
||
90 | 90 | if ($authorization) { |
91 | 91 | echo "<h2>Retorno da requisição de Autorização</h2>"; |
92 | 92 | |
93 | - if(filter_var($authorization, FILTER_VALIDATE_URL)) { |
|
93 | + if (filter_var($authorization, FILTER_VALIDATE_URL)) { |
|
94 | 94 | |
95 | - echo "<p><strong>URL: </strong>" . $authorization . "</p> "; |
|
96 | - echo "<p><a title=\"URL do pagamento\" href=\"$authorization\">" . "Ir para URL de autorização" . "</a></p>"; |
|
95 | + echo "<p><strong>URL: </strong>".$authorization."</p> "; |
|
96 | + echo "<p><a title=\"URL do pagamento\" href=\"$authorization\">"."Ir para URL de autorização"."</a></p>"; |
|
97 | 97 | } else { |
98 | 98 | |
99 | - echo "<p><strong>Code: </strong>" . $authorization . "</p> "; |
|
99 | + echo "<p><strong>Code: </strong>".$authorization."</p> "; |
|
100 | 100 | } |
101 | 101 | } |
102 | 102 | } |
@@ -26,46 +26,46 @@ |
||
26 | 26 | class CreateSession |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - try { |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + try { |
|
32 | 32 | |
33 | - /** |
|
34 | - * @todo |
|
35 | - * #### Credentials ##### |
|
36 | - * Replace the parameters below with your credentials |
|
37 | - * You can also get your credentials from a config file. See an example: |
|
38 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
39 | - */ |
|
33 | + /** |
|
34 | + * @todo |
|
35 | + * #### Credentials ##### |
|
36 | + * Replace the parameters below with your credentials |
|
37 | + * You can also get your credentials from a config file. See an example: |
|
38 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
39 | + */ |
|
40 | 40 | |
41 | - // seller authentication |
|
42 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
43 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
41 | + // seller authentication |
|
42 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
43 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
44 | 44 | |
45 | - // application authentication |
|
46 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
45 | + // application authentication |
|
46 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
47 | 47 | |
48 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
48 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
49 | 49 | |
50 | - $session = PagSeguroSessionService::getSession($credentials); |
|
50 | + $session = PagSeguroSessionService::getSession($credentials); |
|
51 | 51 | |
52 | - self::printSession($session); |
|
52 | + self::printSession($session); |
|
53 | 53 | |
54 | - } catch (PagSeguroServiceException $e) { |
|
55 | - die($e->getMessage()); |
|
56 | - } |
|
57 | - } |
|
54 | + } catch (PagSeguroServiceException $e) { |
|
55 | + die($e->getMessage()); |
|
56 | + } |
|
57 | + } |
|
58 | 58 | |
59 | - public static function printSession($sessionID) |
|
60 | - { |
|
59 | + public static function printSession($sessionID) |
|
60 | + { |
|
61 | 61 | |
62 | - if ($sessionID) { |
|
63 | - echo "<h2>Session</h2>"; |
|
64 | - echo "<p><strong>ID: </strong> ".$sessionID ."</p> "; |
|
65 | - } |
|
62 | + if ($sessionID) { |
|
63 | + echo "<h2>Session</h2>"; |
|
64 | + echo "<p><strong>ID: </strong> ".$sessionID ."</p> "; |
|
65 | + } |
|
66 | 66 | |
67 | - echo "<pre>"; |
|
68 | - } |
|
67 | + echo "<pre>"; |
|
68 | + } |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | CreateSession::main(); |
@@ -61,7 +61,7 @@ |
||
61 | 61 | |
62 | 62 | if ($sessionID) { |
63 | 63 | echo "<h2>Session</h2>"; |
64 | - echo "<p><strong>ID: </strong> ".$sessionID ."</p> "; |
|
64 | + echo "<p><strong>ID: </strong> ".$sessionID."</p> "; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | echo "<pre>"; |
@@ -26,151 +26,151 @@ |
||
26 | 26 | class CreateTransactionUsingBoleto |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - // Instantiate a new payment request |
|
32 | - $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
33 | - |
|
34 | - // Set the Payment Mode for this payment request |
|
35 | - $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
36 | - |
|
37 | - // Set the Payment Method for this payment request |
|
38 | - $directPaymentRequest->setPaymentMethod('BOLETO'); |
|
39 | - |
|
40 | - /** |
|
41 | - * @todo Change the receiver Email |
|
42 | - */ |
|
43 | - $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
44 | - |
|
45 | - // Set the currency |
|
46 | - $directPaymentRequest->setCurrency("BRL"); |
|
47 | - |
|
48 | - // Add an item for this payment request |
|
49 | - $directPaymentRequest->addItem( |
|
50 | - '0001', |
|
51 | - 'Descricao do item a ser vendido', |
|
52 | - 2, |
|
53 | - 10.00 |
|
54 | - ); |
|
55 | - |
|
56 | - // Add an item for this payment request |
|
57 | - $directPaymentRequest->addItem( |
|
58 | - '0002', |
|
59 | - 'Descricao do item a ser vendido', |
|
60 | - 2, |
|
61 | - 5.00 |
|
62 | - ); |
|
63 | - |
|
64 | - // Set a reference code for this payment request. It is useful to identify this payment |
|
65 | - // in future notifications. |
|
66 | - $directPaymentRequest->setReference("REF123"); |
|
67 | - |
|
68 | - // Set your customer information. |
|
69 | - // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
70 | - $directPaymentRequest->setSender( |
|
71 | - 'João Comprador', |
|
72 | - '[email protected]', |
|
73 | - '11', |
|
74 | - '56273440', |
|
75 | - 'CPF', |
|
76 | - '156.009.442-76', |
|
77 | - true |
|
78 | - ); |
|
79 | - |
|
80 | - $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
81 | - |
|
82 | - // Set shipping information for this payment request |
|
83 | - $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
84 | - $directPaymentRequest->setShippingType($sedexCode); |
|
85 | - $directPaymentRequest->setShippingAddress( |
|
86 | - '01452002', |
|
87 | - 'Av. Brig. Faria Lima', |
|
88 | - '1384', |
|
89 | - 'apto. 114', |
|
90 | - 'Jardim Paulistano', |
|
91 | - 'São Paulo', |
|
92 | - 'SP', |
|
93 | - 'BRA' |
|
94 | - ); |
|
95 | - |
|
96 | - try { |
|
97 | - /** |
|
98 | - * #### Credentials ##### |
|
99 | - * Replace the parameters below with your credentials |
|
100 | - * You can also get your credentials from a config file. See an example: |
|
101 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
102 | - */ |
|
103 | - |
|
104 | - // seller authentication |
|
105 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
106 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
107 | - |
|
108 | - // application authentication |
|
109 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
110 | - |
|
111 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
112 | - |
|
113 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
114 | - $return = $directPaymentRequest->register($credentials); |
|
115 | - |
|
116 | - self::printTransactionReturn($return); |
|
117 | - |
|
118 | - } catch (PagSeguroServiceException $e) { |
|
119 | - die($e->getMessage()); |
|
120 | - } |
|
121 | - } |
|
122 | - |
|
123 | - public static function printTransactionReturn($transaction) |
|
124 | - { |
|
125 | - |
|
126 | - if ($transaction) { |
|
127 | - echo "<h2>Retorno da transação com Boleto</h2>"; |
|
128 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
129 | - echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
130 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
131 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
132 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
133 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
134 | - |
|
135 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
136 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
137 | - echo "<p><strong>paymentLink: </strong> ".$transaction->getPaymentLink() ."</p> "; |
|
138 | - |
|
139 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
140 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
141 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
142 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
143 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
144 | - |
|
145 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
146 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
147 | - |
|
148 | - echo "<p><strong>Items: </strong></p>"; |
|
149 | - foreach ($transaction->getItems() as $item) |
|
150 | - { |
|
151 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
152 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
153 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
154 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
155 | - } |
|
156 | - |
|
157 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
158 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
159 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
160 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
161 | - echo "<p><strong>Shipping: </strong></p>"; |
|
162 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
163 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
164 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
165 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
166 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
167 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
168 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
169 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
170 | - } |
|
171 | - |
|
172 | - echo "<pre>"; |
|
173 | - } |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + // Instantiate a new payment request |
|
32 | + $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
33 | + |
|
34 | + // Set the Payment Mode for this payment request |
|
35 | + $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
36 | + |
|
37 | + // Set the Payment Method for this payment request |
|
38 | + $directPaymentRequest->setPaymentMethod('BOLETO'); |
|
39 | + |
|
40 | + /** |
|
41 | + * @todo Change the receiver Email |
|
42 | + */ |
|
43 | + $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
44 | + |
|
45 | + // Set the currency |
|
46 | + $directPaymentRequest->setCurrency("BRL"); |
|
47 | + |
|
48 | + // Add an item for this payment request |
|
49 | + $directPaymentRequest->addItem( |
|
50 | + '0001', |
|
51 | + 'Descricao do item a ser vendido', |
|
52 | + 2, |
|
53 | + 10.00 |
|
54 | + ); |
|
55 | + |
|
56 | + // Add an item for this payment request |
|
57 | + $directPaymentRequest->addItem( |
|
58 | + '0002', |
|
59 | + 'Descricao do item a ser vendido', |
|
60 | + 2, |
|
61 | + 5.00 |
|
62 | + ); |
|
63 | + |
|
64 | + // Set a reference code for this payment request. It is useful to identify this payment |
|
65 | + // in future notifications. |
|
66 | + $directPaymentRequest->setReference("REF123"); |
|
67 | + |
|
68 | + // Set your customer information. |
|
69 | + // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
70 | + $directPaymentRequest->setSender( |
|
71 | + 'João Comprador', |
|
72 | + '[email protected]', |
|
73 | + '11', |
|
74 | + '56273440', |
|
75 | + 'CPF', |
|
76 | + '156.009.442-76', |
|
77 | + true |
|
78 | + ); |
|
79 | + |
|
80 | + $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
81 | + |
|
82 | + // Set shipping information for this payment request |
|
83 | + $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
84 | + $directPaymentRequest->setShippingType($sedexCode); |
|
85 | + $directPaymentRequest->setShippingAddress( |
|
86 | + '01452002', |
|
87 | + 'Av. Brig. Faria Lima', |
|
88 | + '1384', |
|
89 | + 'apto. 114', |
|
90 | + 'Jardim Paulistano', |
|
91 | + 'São Paulo', |
|
92 | + 'SP', |
|
93 | + 'BRA' |
|
94 | + ); |
|
95 | + |
|
96 | + try { |
|
97 | + /** |
|
98 | + * #### Credentials ##### |
|
99 | + * Replace the parameters below with your credentials |
|
100 | + * You can also get your credentials from a config file. See an example: |
|
101 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
102 | + */ |
|
103 | + |
|
104 | + // seller authentication |
|
105 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
106 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
107 | + |
|
108 | + // application authentication |
|
109 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
110 | + |
|
111 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
112 | + |
|
113 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
114 | + $return = $directPaymentRequest->register($credentials); |
|
115 | + |
|
116 | + self::printTransactionReturn($return); |
|
117 | + |
|
118 | + } catch (PagSeguroServiceException $e) { |
|
119 | + die($e->getMessage()); |
|
120 | + } |
|
121 | + } |
|
122 | + |
|
123 | + public static function printTransactionReturn($transaction) |
|
124 | + { |
|
125 | + |
|
126 | + if ($transaction) { |
|
127 | + echo "<h2>Retorno da transação com Boleto</h2>"; |
|
128 | + echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
129 | + echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
130 | + echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
131 | + echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
132 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
133 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
134 | + |
|
135 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
136 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
137 | + echo "<p><strong>paymentLink: </strong> ".$transaction->getPaymentLink() ."</p> "; |
|
138 | + |
|
139 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
140 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
141 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
142 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
143 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
144 | + |
|
145 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
146 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
147 | + |
|
148 | + echo "<p><strong>Items: </strong></p>"; |
|
149 | + foreach ($transaction->getItems() as $item) |
|
150 | + { |
|
151 | + echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
152 | + echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
153 | + echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
154 | + echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
155 | + } |
|
156 | + |
|
157 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
158 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
159 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
160 | + $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
161 | + echo "<p><strong>Shipping: </strong></p>"; |
|
162 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
163 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
164 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
165 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
166 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
167 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
168 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
169 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
170 | + } |
|
171 | + |
|
172 | + echo "<pre>"; |
|
173 | + } |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | CreateTransactionUsingBoleto::main(); |
@@ -125,48 +125,48 @@ |
||
125 | 125 | |
126 | 126 | if ($transaction) { |
127 | 127 | echo "<h2>Retorno da transação com Boleto</h2>"; |
128 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
128 | + echo "<p><strong>Date: </strong> ".$transaction->getDate()."</p> "; |
|
129 | 129 | echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
130 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
131 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
132 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
133 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
130 | + echo "<p><strong>code: </strong> ".$transaction->getCode()."</p> "; |
|
131 | + echo "<p><strong>reference: </strong> ".$transaction->getReference()."</p> "; |
|
132 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue()."</p> "; |
|
133 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue()."</p> "; |
|
134 | 134 | |
135 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
136 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
137 | - echo "<p><strong>paymentLink: </strong> ".$transaction->getPaymentLink() ."</p> "; |
|
135 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue()."</p> "; |
|
136 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue()."</p> "; |
|
137 | + echo "<p><strong>paymentLink: </strong> ".$transaction->getPaymentLink()."</p> "; |
|
138 | 138 | |
139 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
140 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
141 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
142 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
143 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
139 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount()."</p> "; |
|
140 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount()."</p> "; |
|
141 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount()."</p> "; |
|
142 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount()."</p> "; |
|
143 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount()."</p> "; |
|
144 | 144 | |
145 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
146 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
145 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount()."</p> "; |
|
146 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount()."</p> "; |
|
147 | 147 | |
148 | 148 | echo "<p><strong>Items: </strong></p>"; |
149 | 149 | foreach ($transaction->getItems() as $item) |
150 | 150 | { |
151 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
152 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
153 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
154 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
151 | + echo "<p><strong>id: </strong> ".$item->getId()."</br> "; |
|
152 | + echo "<strong>description: </strong> ".$item->getDescription()."</br> "; |
|
153 | + echo "<strong>quantity: </strong> ".$item->getQuantity()."</br> "; |
|
154 | + echo "<strong>amount: </strong> ".$item->getAmount()."</p> "; |
|
155 | 155 | } |
156 | 156 | |
157 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
158 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
159 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
160 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
157 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName()."</p> "; |
|
158 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail()."</p> "; |
|
159 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode()." - ". |
|
160 | + $transaction->getSender()->getPhone()->getNumber()."</p> "; |
|
161 | 161 | echo "<p><strong>Shipping: </strong></p>"; |
162 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
163 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
164 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
165 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
166 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
167 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
168 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
169 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
162 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet()."</p> "; |
|
163 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber()."</p> "; |
|
164 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement()."</p> "; |
|
165 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict()."</p> "; |
|
166 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode()."</p> "; |
|
167 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity()."</p> "; |
|
168 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState()."</p> "; |
|
169 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry()."</p> "; |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | echo "<pre>"; |
@@ -26,196 +26,196 @@ |
||
26 | 26 | class CreateTransactionUsingCreditCard |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - |
|
32 | - // Instantiate a new payment request |
|
33 | - $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
34 | - |
|
35 | - // Set the Payment Mode for this payment request |
|
36 | - $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
37 | - |
|
38 | - // Set the Payment Method for this payment request |
|
39 | - $directPaymentRequest->setPaymentMethod('CREDIT_CARD'); |
|
40 | - |
|
41 | - /** |
|
42 | - * @todo Change the receiver Email |
|
43 | - */ |
|
44 | - $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
45 | - |
|
46 | - // Set the currency |
|
47 | - $directPaymentRequest->setCurrency("BRL"); |
|
48 | - |
|
49 | - // Add an item for this payment request |
|
50 | - // Add an item for this payment request |
|
51 | - $directPaymentRequest->addItem( |
|
52 | - '0001', |
|
53 | - 'Descricao do item a ser vendido', |
|
54 | - 2, |
|
55 | - 10.00 |
|
56 | - ); |
|
57 | - |
|
58 | - // Add an item for this payment request |
|
59 | - $directPaymentRequest->addItem( |
|
60 | - '0002', |
|
61 | - 'Descricao do item a ser vendido', |
|
62 | - 2, |
|
63 | - 5.00 |
|
64 | - ); |
|
65 | - |
|
66 | - // Set a reference code for this payment request. It is useful to identify this payment |
|
67 | - // in future notifications. |
|
68 | - $directPaymentRequest->setReference("REF123"); |
|
69 | - |
|
70 | - // Set your customer information. |
|
71 | - // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
72 | - $directPaymentRequest->setSender( |
|
73 | - 'João Comprador', |
|
74 | - '[email protected]', |
|
75 | - '11', |
|
76 | - '56273440', |
|
77 | - 'CPF', |
|
78 | - '156.009.442-76', |
|
79 | - true |
|
80 | - ); |
|
81 | - |
|
82 | - $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
83 | - |
|
84 | - // Set shipping information for this payment request |
|
85 | - $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
86 | - $directPaymentRequest->setShippingType($sedexCode); |
|
87 | - $directPaymentRequest->setShippingAddress( |
|
88 | - '01452002', |
|
89 | - 'Av. Brig. Faria Lima', |
|
90 | - '1384', |
|
91 | - 'apto. 114', |
|
92 | - 'Jardim Paulistano', |
|
93 | - 'São Paulo', |
|
94 | - 'SP', |
|
95 | - 'BRA' |
|
96 | - ); |
|
97 | - |
|
98 | - //Set billing information for credit card |
|
99 | - $billing = new PagSeguroBilling |
|
100 | - ( |
|
101 | - array( |
|
102 | - 'postalCode' => '01452002', |
|
103 | - 'street' => 'Av. Brig. Faria Lima', |
|
104 | - 'number' => '1384', |
|
105 | - 'complement' => 'apto. 114', |
|
106 | - 'district' => 'Jardim Paulistano', |
|
107 | - 'city' => 'São Paulo', |
|
108 | - 'state' => 'SP', |
|
109 | - 'country' => 'BRA' |
|
110 | - ) |
|
111 | - ); |
|
112 | - |
|
113 | - $token = "5b97542cd1524b67a9e89b3d90c1f262"; |
|
114 | - |
|
115 | - $installment = new PagSeguroInstallment( |
|
116 | - array("quantity" => 1, |
|
117 | - "value" => "30.00") |
|
118 | - ); |
|
119 | - |
|
120 | - $cardCheckout = new PagSeguroCreditCardCheckout( |
|
121 | - array( |
|
122 | - 'token' => $token, |
|
123 | - 'installment' => $installment, |
|
124 | - 'holder' => new PagSeguroCreditCardHolder( |
|
125 | - array( |
|
126 | - 'name' => 'João Comprador', //Equals in Credit Card |
|
127 | - 'documents' => array( |
|
128 | - 'type' => 'CPF', |
|
129 | - 'value' => '156.009.442-76' |
|
130 | - ), |
|
131 | - 'birthDate' => date('01/10/1979'), |
|
132 | - 'areaCode' => 11, |
|
133 | - 'number' => 56273440 |
|
134 | - ) |
|
135 | - ), |
|
136 | - 'billing' => $billing |
|
137 | - ) |
|
138 | - ); |
|
139 | - |
|
140 | - //Set credit card for payment |
|
141 | - $directPaymentRequest->setCreditCard($cardCheckout); |
|
142 | - |
|
143 | - try { |
|
144 | - /** |
|
145 | - * #### Credentials ##### |
|
146 | - * Replace the parameters below with your credentials |
|
147 | - * You can also get your credentials from a config file. See an example: |
|
148 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
149 | - */ |
|
150 | - |
|
151 | - // seller authentication |
|
152 | - //$credentials = new PagSeguroAccountCredentials("[email protected]", |
|
153 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
154 | - |
|
155 | - // application authentication |
|
156 | - $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
157 | - $credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
158 | - |
|
159 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
160 | - $return = $directPaymentRequest->register($credentials); |
|
161 | - |
|
162 | - self::printTransactionReturn($return); |
|
163 | - |
|
164 | - } catch (PagSeguroServiceException $e) { |
|
165 | - die($e->getMessage()); |
|
166 | - } |
|
167 | - } |
|
168 | - |
|
169 | - public static function printTransactionReturn($transaction) |
|
170 | - { |
|
171 | - |
|
172 | - if ($transaction) { |
|
173 | - echo "<h2>Retorno da transação com Cartão de Crédito.</h2>"; |
|
174 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
175 | - echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
176 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
177 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
178 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
179 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
180 | - |
|
181 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
182 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
183 | - |
|
184 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
185 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
186 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
187 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
188 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
189 | - |
|
190 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
191 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
192 | - |
|
193 | - echo "<p><strong>Items: </strong></p>"; |
|
194 | - foreach ($transaction->getItems() as $item) |
|
195 | - { |
|
196 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
197 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
198 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
199 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
200 | - } |
|
201 | - |
|
202 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
203 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
204 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
205 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
206 | - echo "<p><strong>Shipping: </strong></p>"; |
|
207 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
208 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
209 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
210 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
211 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
212 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
213 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
214 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
215 | - } |
|
216 | - |
|
217 | - echo "<pre>"; |
|
218 | - } |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + |
|
32 | + // Instantiate a new payment request |
|
33 | + $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
34 | + |
|
35 | + // Set the Payment Mode for this payment request |
|
36 | + $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
37 | + |
|
38 | + // Set the Payment Method for this payment request |
|
39 | + $directPaymentRequest->setPaymentMethod('CREDIT_CARD'); |
|
40 | + |
|
41 | + /** |
|
42 | + * @todo Change the receiver Email |
|
43 | + */ |
|
44 | + $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
45 | + |
|
46 | + // Set the currency |
|
47 | + $directPaymentRequest->setCurrency("BRL"); |
|
48 | + |
|
49 | + // Add an item for this payment request |
|
50 | + // Add an item for this payment request |
|
51 | + $directPaymentRequest->addItem( |
|
52 | + '0001', |
|
53 | + 'Descricao do item a ser vendido', |
|
54 | + 2, |
|
55 | + 10.00 |
|
56 | + ); |
|
57 | + |
|
58 | + // Add an item for this payment request |
|
59 | + $directPaymentRequest->addItem( |
|
60 | + '0002', |
|
61 | + 'Descricao do item a ser vendido', |
|
62 | + 2, |
|
63 | + 5.00 |
|
64 | + ); |
|
65 | + |
|
66 | + // Set a reference code for this payment request. It is useful to identify this payment |
|
67 | + // in future notifications. |
|
68 | + $directPaymentRequest->setReference("REF123"); |
|
69 | + |
|
70 | + // Set your customer information. |
|
71 | + // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
72 | + $directPaymentRequest->setSender( |
|
73 | + 'João Comprador', |
|
74 | + '[email protected]', |
|
75 | + '11', |
|
76 | + '56273440', |
|
77 | + 'CPF', |
|
78 | + '156.009.442-76', |
|
79 | + true |
|
80 | + ); |
|
81 | + |
|
82 | + $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
83 | + |
|
84 | + // Set shipping information for this payment request |
|
85 | + $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
86 | + $directPaymentRequest->setShippingType($sedexCode); |
|
87 | + $directPaymentRequest->setShippingAddress( |
|
88 | + '01452002', |
|
89 | + 'Av. Brig. Faria Lima', |
|
90 | + '1384', |
|
91 | + 'apto. 114', |
|
92 | + 'Jardim Paulistano', |
|
93 | + 'São Paulo', |
|
94 | + 'SP', |
|
95 | + 'BRA' |
|
96 | + ); |
|
97 | + |
|
98 | + //Set billing information for credit card |
|
99 | + $billing = new PagSeguroBilling |
|
100 | + ( |
|
101 | + array( |
|
102 | + 'postalCode' => '01452002', |
|
103 | + 'street' => 'Av. Brig. Faria Lima', |
|
104 | + 'number' => '1384', |
|
105 | + 'complement' => 'apto. 114', |
|
106 | + 'district' => 'Jardim Paulistano', |
|
107 | + 'city' => 'São Paulo', |
|
108 | + 'state' => 'SP', |
|
109 | + 'country' => 'BRA' |
|
110 | + ) |
|
111 | + ); |
|
112 | + |
|
113 | + $token = "5b97542cd1524b67a9e89b3d90c1f262"; |
|
114 | + |
|
115 | + $installment = new PagSeguroInstallment( |
|
116 | + array("quantity" => 1, |
|
117 | + "value" => "30.00") |
|
118 | + ); |
|
119 | + |
|
120 | + $cardCheckout = new PagSeguroCreditCardCheckout( |
|
121 | + array( |
|
122 | + 'token' => $token, |
|
123 | + 'installment' => $installment, |
|
124 | + 'holder' => new PagSeguroCreditCardHolder( |
|
125 | + array( |
|
126 | + 'name' => 'João Comprador', //Equals in Credit Card |
|
127 | + 'documents' => array( |
|
128 | + 'type' => 'CPF', |
|
129 | + 'value' => '156.009.442-76' |
|
130 | + ), |
|
131 | + 'birthDate' => date('01/10/1979'), |
|
132 | + 'areaCode' => 11, |
|
133 | + 'number' => 56273440 |
|
134 | + ) |
|
135 | + ), |
|
136 | + 'billing' => $billing |
|
137 | + ) |
|
138 | + ); |
|
139 | + |
|
140 | + //Set credit card for payment |
|
141 | + $directPaymentRequest->setCreditCard($cardCheckout); |
|
142 | + |
|
143 | + try { |
|
144 | + /** |
|
145 | + * #### Credentials ##### |
|
146 | + * Replace the parameters below with your credentials |
|
147 | + * You can also get your credentials from a config file. See an example: |
|
148 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
149 | + */ |
|
150 | + |
|
151 | + // seller authentication |
|
152 | + //$credentials = new PagSeguroAccountCredentials("[email protected]", |
|
153 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
154 | + |
|
155 | + // application authentication |
|
156 | + $credentials = PagSeguroConfig::getApplicationCredentials(); |
|
157 | + $credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
158 | + |
|
159 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
160 | + $return = $directPaymentRequest->register($credentials); |
|
161 | + |
|
162 | + self::printTransactionReturn($return); |
|
163 | + |
|
164 | + } catch (PagSeguroServiceException $e) { |
|
165 | + die($e->getMessage()); |
|
166 | + } |
|
167 | + } |
|
168 | + |
|
169 | + public static function printTransactionReturn($transaction) |
|
170 | + { |
|
171 | + |
|
172 | + if ($transaction) { |
|
173 | + echo "<h2>Retorno da transação com Cartão de Crédito.</h2>"; |
|
174 | + echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
175 | + echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
176 | + echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
177 | + echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
178 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
179 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
180 | + |
|
181 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
182 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
183 | + |
|
184 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
185 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
186 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
187 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
188 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
189 | + |
|
190 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
191 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
192 | + |
|
193 | + echo "<p><strong>Items: </strong></p>"; |
|
194 | + foreach ($transaction->getItems() as $item) |
|
195 | + { |
|
196 | + echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
197 | + echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
198 | + echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
199 | + echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
200 | + } |
|
201 | + |
|
202 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
203 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
204 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
205 | + $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
206 | + echo "<p><strong>Shipping: </strong></p>"; |
|
207 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
208 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
209 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
210 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
211 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
212 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
213 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
214 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
215 | + } |
|
216 | + |
|
217 | + echo "<pre>"; |
|
218 | + } |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | CreateTransactionUsingCreditCard::main(); |
@@ -96,8 +96,7 @@ discard block |
||
96 | 96 | ); |
97 | 97 | |
98 | 98 | //Set billing information for credit card |
99 | - $billing = new PagSeguroBilling |
|
100 | - ( |
|
99 | + $billing = new PagSeguroBilling( |
|
101 | 100 | array( |
102 | 101 | 'postalCode' => '01452002', |
103 | 102 | 'street' => 'Av. Brig. Faria Lima', |
@@ -171,47 +170,47 @@ discard block |
||
171 | 170 | |
172 | 171 | if ($transaction) { |
173 | 172 | echo "<h2>Retorno da transação com Cartão de Crédito.</h2>"; |
174 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
173 | + echo "<p><strong>Date: </strong> ".$transaction->getDate()."</p> "; |
|
175 | 174 | echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
176 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
177 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
178 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
179 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
175 | + echo "<p><strong>code: </strong> ".$transaction->getCode()."</p> "; |
|
176 | + echo "<p><strong>reference: </strong> ".$transaction->getReference()."</p> "; |
|
177 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue()."</p> "; |
|
178 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue()."</p> "; |
|
180 | 179 | |
181 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
182 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
180 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue()."</p> "; |
|
181 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue()."</p> "; |
|
183 | 182 | |
184 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
185 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
186 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
187 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
188 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
183 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount()."</p> "; |
|
184 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount()."</p> "; |
|
185 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount()."</p> "; |
|
186 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount()."</p> "; |
|
187 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount()."</p> "; |
|
189 | 188 | |
190 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
191 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
189 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount()."</p> "; |
|
190 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount()."</p> "; |
|
192 | 191 | |
193 | 192 | echo "<p><strong>Items: </strong></p>"; |
194 | 193 | foreach ($transaction->getItems() as $item) |
195 | 194 | { |
196 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
197 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
198 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
199 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
195 | + echo "<p><strong>id: </strong> ".$item->getId()."</br> "; |
|
196 | + echo "<strong>description: </strong> ".$item->getDescription()."</br> "; |
|
197 | + echo "<strong>quantity: </strong> ".$item->getQuantity()."</br> "; |
|
198 | + echo "<strong>amount: </strong> ".$item->getAmount()."</p> "; |
|
200 | 199 | } |
201 | 200 | |
202 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
203 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
204 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
205 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
201 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName()."</p> "; |
|
202 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail()."</p> "; |
|
203 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode()." - ". |
|
204 | + $transaction->getSender()->getPhone()->getNumber()."</p> "; |
|
206 | 205 | echo "<p><strong>Shipping: </strong></p>"; |
207 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
208 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
209 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
210 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
211 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
212 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
213 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
214 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
206 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet()."</p> "; |
|
207 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber()."</p> "; |
|
208 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement()."</p> "; |
|
209 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict()."</p> "; |
|
210 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode()."</p> "; |
|
211 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity()."</p> "; |
|
212 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState()."</p> "; |
|
213 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry()."</p> "; |
|
215 | 214 | } |
216 | 215 | |
217 | 216 | echo "<pre>"; |
@@ -26,138 +26,138 @@ |
||
26 | 26 | class CreateTransactionUsingInternationalCreditCard |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - |
|
32 | - // Instantiate a new payment request |
|
33 | - $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
34 | - |
|
35 | - // Set the Payment Mode for this payment request |
|
36 | - $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
37 | - |
|
38 | - // Set the Payment Method for this payment request |
|
39 | - $directPaymentRequest->setPaymentMethod('CREDIT_CARD'); |
|
40 | - |
|
41 | - /** |
|
42 | - * @todo Change the receiver Email |
|
43 | - */ |
|
44 | - $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
45 | - |
|
46 | - // Set the currency |
|
47 | - $directPaymentRequest->setCurrency("BRL"); |
|
48 | - |
|
49 | - // Add an item for this payment request |
|
50 | - // Add an item for this payment request |
|
51 | - $directPaymentRequest->addItem( |
|
52 | - '0001', |
|
53 | - 'Descricao do item a ser vendido', |
|
54 | - 2, |
|
55 | - 10.00 |
|
56 | - ); |
|
57 | - |
|
58 | - // Add an item for this payment request |
|
59 | - $directPaymentRequest->addItem( |
|
60 | - '0002', |
|
61 | - 'Descricao do item a ser vendido', |
|
62 | - 2, |
|
63 | - 5.00 |
|
64 | - ); |
|
65 | - |
|
66 | - // Set a reference code for this payment request. It is useful to identify this payment |
|
67 | - // in future notifications. |
|
68 | - $directPaymentRequest->setReference("REF123"); |
|
69 | - |
|
70 | - // Set your customer information. |
|
71 | - // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
72 | - $directPaymentRequest->setSender( |
|
73 | - 'João Comprador', |
|
74 | - '[email protected]' |
|
75 | - ); |
|
76 | - |
|
77 | - $directPaymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br'); |
|
78 | - |
|
79 | - $token = "5b97542cd1524b67a9e89b3d90c1f262"; |
|
80 | - |
|
81 | - $installment = new PagSeguroInstallment( |
|
82 | - array("quantity" => 1, |
|
83 | - "value" => "30.00") |
|
84 | - ); |
|
85 | - |
|
86 | - $cardCheckout = new PagSeguroCreditCardCheckout( |
|
87 | - array( |
|
88 | - 'token' => $token, |
|
89 | - 'installment' => $installment |
|
90 | - ) |
|
91 | - ); |
|
92 | - |
|
93 | - //Set credit card for payment |
|
94 | - $directPaymentRequest->setCreditCard($cardCheckout); |
|
95 | - |
|
96 | - try { |
|
97 | - /** |
|
98 | - * #### Credentials ##### |
|
99 | - * Replace the parameters below with your credentials |
|
100 | - * You can also get your credentials like this: |
|
101 | - * $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
102 | - * "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
103 | - */ |
|
104 | - |
|
105 | - // seller authentication |
|
106 | - $credentials = PagSeguroConfig::getAccountCredentials(); |
|
107 | - |
|
108 | - // application authentication |
|
109 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
110 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
111 | - |
|
112 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
113 | - $return = $directPaymentRequest->register($credentials); |
|
114 | - |
|
115 | - self::printTransactionReturn($return); |
|
116 | - |
|
117 | - } catch (PagSeguroServiceException $e) { |
|
118 | - die($e->getMessage()); |
|
119 | - } |
|
120 | - } |
|
121 | - |
|
122 | - public static function printTransactionReturn($transaction) |
|
123 | - { |
|
124 | - |
|
125 | - if ($transaction) { |
|
126 | - echo "<h2>Retorno da transação com Cartão de Crédito Internacional.</h2>"; |
|
127 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
128 | - echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
129 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
130 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
131 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
132 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
133 | - |
|
134 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
135 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
136 | - |
|
137 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
138 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
139 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
140 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
141 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
142 | - |
|
143 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
144 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
145 | - |
|
146 | - echo "<p><strong>Items: </strong></p>"; |
|
147 | - foreach ($transaction->getItems() as $item) |
|
148 | - { |
|
149 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
150 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
151 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
152 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
153 | - } |
|
154 | - |
|
155 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
156 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
157 | - } |
|
158 | - |
|
159 | - echo "<pre>"; |
|
160 | - } |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + |
|
32 | + // Instantiate a new payment request |
|
33 | + $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
34 | + |
|
35 | + // Set the Payment Mode for this payment request |
|
36 | + $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
37 | + |
|
38 | + // Set the Payment Method for this payment request |
|
39 | + $directPaymentRequest->setPaymentMethod('CREDIT_CARD'); |
|
40 | + |
|
41 | + /** |
|
42 | + * @todo Change the receiver Email |
|
43 | + */ |
|
44 | + $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
45 | + |
|
46 | + // Set the currency |
|
47 | + $directPaymentRequest->setCurrency("BRL"); |
|
48 | + |
|
49 | + // Add an item for this payment request |
|
50 | + // Add an item for this payment request |
|
51 | + $directPaymentRequest->addItem( |
|
52 | + '0001', |
|
53 | + 'Descricao do item a ser vendido', |
|
54 | + 2, |
|
55 | + 10.00 |
|
56 | + ); |
|
57 | + |
|
58 | + // Add an item for this payment request |
|
59 | + $directPaymentRequest->addItem( |
|
60 | + '0002', |
|
61 | + 'Descricao do item a ser vendido', |
|
62 | + 2, |
|
63 | + 5.00 |
|
64 | + ); |
|
65 | + |
|
66 | + // Set a reference code for this payment request. It is useful to identify this payment |
|
67 | + // in future notifications. |
|
68 | + $directPaymentRequest->setReference("REF123"); |
|
69 | + |
|
70 | + // Set your customer information. |
|
71 | + // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
72 | + $directPaymentRequest->setSender( |
|
73 | + 'João Comprador', |
|
74 | + '[email protected]' |
|
75 | + ); |
|
76 | + |
|
77 | + $directPaymentRequest->addParameter('notificationURL', 'http://www.lojamodelo.com.br'); |
|
78 | + |
|
79 | + $token = "5b97542cd1524b67a9e89b3d90c1f262"; |
|
80 | + |
|
81 | + $installment = new PagSeguroInstallment( |
|
82 | + array("quantity" => 1, |
|
83 | + "value" => "30.00") |
|
84 | + ); |
|
85 | + |
|
86 | + $cardCheckout = new PagSeguroCreditCardCheckout( |
|
87 | + array( |
|
88 | + 'token' => $token, |
|
89 | + 'installment' => $installment |
|
90 | + ) |
|
91 | + ); |
|
92 | + |
|
93 | + //Set credit card for payment |
|
94 | + $directPaymentRequest->setCreditCard($cardCheckout); |
|
95 | + |
|
96 | + try { |
|
97 | + /** |
|
98 | + * #### Credentials ##### |
|
99 | + * Replace the parameters below with your credentials |
|
100 | + * You can also get your credentials like this: |
|
101 | + * $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
102 | + * "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
103 | + */ |
|
104 | + |
|
105 | + // seller authentication |
|
106 | + $credentials = PagSeguroConfig::getAccountCredentials(); |
|
107 | + |
|
108 | + // application authentication |
|
109 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
110 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
111 | + |
|
112 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
113 | + $return = $directPaymentRequest->register($credentials); |
|
114 | + |
|
115 | + self::printTransactionReturn($return); |
|
116 | + |
|
117 | + } catch (PagSeguroServiceException $e) { |
|
118 | + die($e->getMessage()); |
|
119 | + } |
|
120 | + } |
|
121 | + |
|
122 | + public static function printTransactionReturn($transaction) |
|
123 | + { |
|
124 | + |
|
125 | + if ($transaction) { |
|
126 | + echo "<h2>Retorno da transação com Cartão de Crédito Internacional.</h2>"; |
|
127 | + echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
128 | + echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
129 | + echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
130 | + echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
131 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
132 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
133 | + |
|
134 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
135 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
136 | + |
|
137 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
138 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
139 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
140 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
141 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
142 | + |
|
143 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
144 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
145 | + |
|
146 | + echo "<p><strong>Items: </strong></p>"; |
|
147 | + foreach ($transaction->getItems() as $item) |
|
148 | + { |
|
149 | + echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
150 | + echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
151 | + echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
152 | + echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
153 | + } |
|
154 | + |
|
155 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
156 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
157 | + } |
|
158 | + |
|
159 | + echo "<pre>"; |
|
160 | + } |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | CreateTransactionUsingInternationalCreditCard::main(); |
@@ -124,36 +124,36 @@ |
||
124 | 124 | |
125 | 125 | if ($transaction) { |
126 | 126 | echo "<h2>Retorno da transação com Cartão de Crédito Internacional.</h2>"; |
127 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
127 | + echo "<p><strong>Date: </strong> ".$transaction->getDate()."</p> "; |
|
128 | 128 | echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
129 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
130 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
131 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
132 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
129 | + echo "<p><strong>code: </strong> ".$transaction->getCode()."</p> "; |
|
130 | + echo "<p><strong>reference: </strong> ".$transaction->getReference()."</p> "; |
|
131 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue()."</p> "; |
|
132 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue()."</p> "; |
|
133 | 133 | |
134 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
135 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
134 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue()."</p> "; |
|
135 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue()."</p> "; |
|
136 | 136 | |
137 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
138 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
139 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
140 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
141 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
137 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount()."</p> "; |
|
138 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount()."</p> "; |
|
139 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount()."</p> "; |
|
140 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount()."</p> "; |
|
141 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount()."</p> "; |
|
142 | 142 | |
143 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
144 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
143 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount()."</p> "; |
|
144 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount()."</p> "; |
|
145 | 145 | |
146 | 146 | echo "<p><strong>Items: </strong></p>"; |
147 | 147 | foreach ($transaction->getItems() as $item) |
148 | 148 | { |
149 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
150 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
151 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
152 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
149 | + echo "<p><strong>id: </strong> ".$item->getId()."</br> "; |
|
150 | + echo "<strong>description: </strong> ".$item->getDescription()."</br> "; |
|
151 | + echo "<strong>quantity: </strong> ".$item->getQuantity()."</br> "; |
|
152 | + echo "<strong>amount: </strong> ".$item->getAmount()."</p> "; |
|
153 | 153 | } |
154 | 154 | |
155 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
156 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
155 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName()."</p> "; |
|
156 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail()."</p> "; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | echo "<pre>"; |
@@ -26,157 +26,157 @@ |
||
26 | 26 | class CreateTransactionUsingOnlineDebit |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - // Instantiate a new payment request |
|
32 | - $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
33 | - |
|
34 | - // Set the Payment Mode for this payment request |
|
35 | - $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
36 | - |
|
37 | - // Set the Payment Method for this payment request |
|
38 | - $directPaymentRequest->setPaymentMethod('EFT'); |
|
39 | - |
|
40 | - /** |
|
41 | - * @todo Change the receiver Email |
|
42 | - */ |
|
43 | - $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
44 | - |
|
45 | - // Set the currency |
|
46 | - $directPaymentRequest->setCurrency("BRL"); |
|
47 | - |
|
48 | - // Add an item for this payment request |
|
49 | - $directPaymentRequest->addItem( |
|
50 | - '0001', |
|
51 | - 'Descricao do item a ser vendido', |
|
52 | - 2, |
|
53 | - 10.00 |
|
54 | - ); |
|
55 | - |
|
56 | - // Add an item for this payment request |
|
57 | - $directPaymentRequest->addItem( |
|
58 | - '0002', |
|
59 | - 'Descricao do item a ser vendido', |
|
60 | - 2, |
|
61 | - 5.00 |
|
62 | - ); |
|
63 | - |
|
64 | - // Set a reference code for this payment request. It is useful to identify this payment |
|
65 | - // in future notifications. |
|
66 | - $directPaymentRequest->setReference("REF123"); |
|
67 | - |
|
68 | - // Set your customer information. |
|
69 | - // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
70 | - $directPaymentRequest->setSender( |
|
71 | - 'João Comprador', |
|
72 | - '[email protected]', |
|
73 | - '11', |
|
74 | - '56273440', |
|
75 | - 'CPF', |
|
76 | - '156.009.442-76', |
|
77 | - true |
|
78 | - ); |
|
79 | - |
|
80 | - $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
81 | - |
|
82 | - // Set shipping information for this payment request |
|
83 | - $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
84 | - $directPaymentRequest->setShippingType($sedexCode); |
|
85 | - $directPaymentRequest->setShippingAddress( |
|
86 | - '01452002', |
|
87 | - 'Av. Brig. Faria Lima', |
|
88 | - '1384', |
|
89 | - 'apto. 114', |
|
90 | - 'Jardim Paulistano', |
|
91 | - 'São Paulo', |
|
92 | - 'SP', |
|
93 | - 'BRA' |
|
94 | - ); |
|
95 | - |
|
96 | - // Set bank for this payment request |
|
97 | - $directPaymentRequest->setOnlineDebit( |
|
98 | - array( |
|
99 | - "bankName" => 'ITAU' |
|
100 | - ) |
|
101 | - ); |
|
102 | - |
|
103 | - try { |
|
104 | - /** |
|
105 | - * #### Credentials ##### |
|
106 | - * Replace the parameters below with your credentials |
|
107 | - * You can also get your credentials from a config file. See an example: |
|
108 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
109 | - */ |
|
110 | - |
|
111 | - // seller authentication |
|
112 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
113 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
114 | - |
|
115 | - // application authentication |
|
116 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
117 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
118 | - |
|
119 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
120 | - $return = $directPaymentRequest->register($credentials); |
|
121 | - |
|
122 | - self::printTransactionReturn($return); |
|
123 | - |
|
124 | - } catch (PagSeguroServiceException $e) { |
|
125 | - die($e->getMessage()); |
|
126 | - } |
|
127 | - } |
|
128 | - |
|
129 | - public static function printTransactionReturn($transaction) |
|
130 | - { |
|
131 | - |
|
132 | - if ($transaction) { |
|
133 | - echo "<h2>Retorno da transação de Debito Online</h2>"; |
|
134 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
135 | - echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
136 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
137 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
138 | - echo "<p><strong>recovery code: </strong> ".$transaction->getRecoveryCode() ."</p> "; |
|
139 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
140 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
141 | - |
|
142 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
143 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
144 | - |
|
145 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
146 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
147 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
148 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
149 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
150 | - |
|
151 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
152 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
153 | - |
|
154 | - echo "<p><strong>Items: </strong></p>"; |
|
155 | - foreach ($transaction->getItems() as $item) |
|
156 | - { |
|
157 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
158 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
159 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
160 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
161 | - } |
|
162 | - |
|
163 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
164 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
165 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
166 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
167 | - echo "<p><strong>Shipping: </strong></p>"; |
|
168 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
169 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
170 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
171 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
172 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
173 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
174 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
175 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
176 | - } |
|
177 | - |
|
178 | - echo "<pre>"; |
|
179 | - } |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + // Instantiate a new payment request |
|
32 | + $directPaymentRequest = new PagSeguroDirectPaymentRequest(); |
|
33 | + |
|
34 | + // Set the Payment Mode for this payment request |
|
35 | + $directPaymentRequest->setPaymentMode('DEFAULT'); |
|
36 | + |
|
37 | + // Set the Payment Method for this payment request |
|
38 | + $directPaymentRequest->setPaymentMethod('EFT'); |
|
39 | + |
|
40 | + /** |
|
41 | + * @todo Change the receiver Email |
|
42 | + */ |
|
43 | + $directPaymentRequest->setReceiverEmail('[email protected]'); |
|
44 | + |
|
45 | + // Set the currency |
|
46 | + $directPaymentRequest->setCurrency("BRL"); |
|
47 | + |
|
48 | + // Add an item for this payment request |
|
49 | + $directPaymentRequest->addItem( |
|
50 | + '0001', |
|
51 | + 'Descricao do item a ser vendido', |
|
52 | + 2, |
|
53 | + 10.00 |
|
54 | + ); |
|
55 | + |
|
56 | + // Add an item for this payment request |
|
57 | + $directPaymentRequest->addItem( |
|
58 | + '0002', |
|
59 | + 'Descricao do item a ser vendido', |
|
60 | + 2, |
|
61 | + 5.00 |
|
62 | + ); |
|
63 | + |
|
64 | + // Set a reference code for this payment request. It is useful to identify this payment |
|
65 | + // in future notifications. |
|
66 | + $directPaymentRequest->setReference("REF123"); |
|
67 | + |
|
68 | + // Set your customer information. |
|
69 | + // If you using SANDBOX you must use an email @sandbox.pagseguro.com.br |
|
70 | + $directPaymentRequest->setSender( |
|
71 | + 'João Comprador', |
|
72 | + '[email protected]', |
|
73 | + '11', |
|
74 | + '56273440', |
|
75 | + 'CPF', |
|
76 | + '156.009.442-76', |
|
77 | + true |
|
78 | + ); |
|
79 | + |
|
80 | + $directPaymentRequest->setSenderHash("d94d002b6998ca9cd69092746518e50aded5a54aef64c4877ccea02573694986"); |
|
81 | + |
|
82 | + // Set shipping information for this payment request |
|
83 | + $sedexCode = PagSeguroShippingType::getCodeByType('SEDEX'); |
|
84 | + $directPaymentRequest->setShippingType($sedexCode); |
|
85 | + $directPaymentRequest->setShippingAddress( |
|
86 | + '01452002', |
|
87 | + 'Av. Brig. Faria Lima', |
|
88 | + '1384', |
|
89 | + 'apto. 114', |
|
90 | + 'Jardim Paulistano', |
|
91 | + 'São Paulo', |
|
92 | + 'SP', |
|
93 | + 'BRA' |
|
94 | + ); |
|
95 | + |
|
96 | + // Set bank for this payment request |
|
97 | + $directPaymentRequest->setOnlineDebit( |
|
98 | + array( |
|
99 | + "bankName" => 'ITAU' |
|
100 | + ) |
|
101 | + ); |
|
102 | + |
|
103 | + try { |
|
104 | + /** |
|
105 | + * #### Credentials ##### |
|
106 | + * Replace the parameters below with your credentials |
|
107 | + * You can also get your credentials from a config file. See an example: |
|
108 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
109 | + */ |
|
110 | + |
|
111 | + // seller authentication |
|
112 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
113 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
114 | + |
|
115 | + // application authentication |
|
116 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
117 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
118 | + |
|
119 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
120 | + $return = $directPaymentRequest->register($credentials); |
|
121 | + |
|
122 | + self::printTransactionReturn($return); |
|
123 | + |
|
124 | + } catch (PagSeguroServiceException $e) { |
|
125 | + die($e->getMessage()); |
|
126 | + } |
|
127 | + } |
|
128 | + |
|
129 | + public static function printTransactionReturn($transaction) |
|
130 | + { |
|
131 | + |
|
132 | + if ($transaction) { |
|
133 | + echo "<h2>Retorno da transação de Debito Online</h2>"; |
|
134 | + echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
135 | + echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
|
136 | + echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
137 | + echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
138 | + echo "<p><strong>recovery code: </strong> ".$transaction->getRecoveryCode() ."</p> "; |
|
139 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
140 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
141 | + |
|
142 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
143 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
144 | + |
|
145 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
146 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
147 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
148 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
149 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
150 | + |
|
151 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
152 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
153 | + |
|
154 | + echo "<p><strong>Items: </strong></p>"; |
|
155 | + foreach ($transaction->getItems() as $item) |
|
156 | + { |
|
157 | + echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
158 | + echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
159 | + echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
160 | + echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
161 | + } |
|
162 | + |
|
163 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
164 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
165 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
166 | + $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
167 | + echo "<p><strong>Shipping: </strong></p>"; |
|
168 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
169 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
170 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
171 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
172 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
173 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
174 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
175 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
176 | + } |
|
177 | + |
|
178 | + echo "<pre>"; |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | CreateTransactionUsingOnlineDebit::main(); |
@@ -131,48 +131,48 @@ |
||
131 | 131 | |
132 | 132 | if ($transaction) { |
133 | 133 | echo "<h2>Retorno da transação de Debito Online</h2>"; |
134 | - echo "<p><strong>Date: </strong> ".$transaction->getDate() ."</p> "; |
|
134 | + echo "<p><strong>Date: </strong> ".$transaction->getDate()."</p> "; |
|
135 | 135 | echo "<p><strong>lastEventDate: </strong> ".$transaction->getLastEventDate()."</p> "; |
136 | - echo "<p><strong>code: </strong> ".$transaction->getCode() ."</p> "; |
|
137 | - echo "<p><strong>reference: </strong> ".$transaction->getReference() ."</p> "; |
|
138 | - echo "<p><strong>recovery code: </strong> ".$transaction->getRecoveryCode() ."</p> "; |
|
139 | - echo "<p><strong>type: </strong> ".$transaction->getType()->getValue() ."</p> "; |
|
140 | - echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue() ."</p> "; |
|
136 | + echo "<p><strong>code: </strong> ".$transaction->getCode()."</p> "; |
|
137 | + echo "<p><strong>reference: </strong> ".$transaction->getReference()."</p> "; |
|
138 | + echo "<p><strong>recovery code: </strong> ".$transaction->getRecoveryCode()."</p> "; |
|
139 | + echo "<p><strong>type: </strong> ".$transaction->getType()->getValue()."</p> "; |
|
140 | + echo "<p><strong>status: </strong> ".$transaction->getStatus()->getValue()."</p> "; |
|
141 | 141 | |
142 | - echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue() ."</p> "; |
|
143 | - echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue() ."</p> "; |
|
142 | + echo "<p><strong>paymentMethodType: </strong> ".$transaction->getPaymentMethod()->getType()->getValue()."</p> "; |
|
143 | + echo "<p><strong>paymentModeCode: </strong> ".$transaction->getPaymentMethod()->getCode()->getValue()."</p> "; |
|
144 | 144 | |
145 | - echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount() ."</p> "; |
|
146 | - echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount() ."</p> "; |
|
147 | - echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount() ."</p> "; |
|
148 | - echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount() ."</p> "; |
|
149 | - echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount() ."</p> "; |
|
145 | + echo "<p><strong>grossAmount: </strong> ".$transaction->getGrossAmount()."</p> "; |
|
146 | + echo "<p><strong>discountAmount: </strong> ".$transaction->getDiscountAmount()."</p> "; |
|
147 | + echo "<p><strong>feeAmount: </strong> ".$transaction->getFeeAmount()."</p> "; |
|
148 | + echo "<p><strong>netAmount: </strong> ".$transaction->getNetAmount()."</p> "; |
|
149 | + echo "<p><strong>extraAmount: </strong> ".$transaction->getExtraAmount()."</p> "; |
|
150 | 150 | |
151 | - echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount() ."</p> "; |
|
152 | - echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount() ."</p> "; |
|
151 | + echo "<p><strong>installmentCount: </strong> ".$transaction->getInstallmentCount()."</p> "; |
|
152 | + echo "<p><strong>itemCount: </strong> ".$transaction->getItemCount()."</p> "; |
|
153 | 153 | |
154 | 154 | echo "<p><strong>Items: </strong></p>"; |
155 | 155 | foreach ($transaction->getItems() as $item) |
156 | 156 | { |
157 | - echo "<p><strong>id: </strong> ". $item->getId() ."</br> "; |
|
158 | - echo "<strong>description: </strong> ". $item->getDescription() ."</br> "; |
|
159 | - echo "<strong>quantity: </strong> ". $item->getQuantity() ."</br> "; |
|
160 | - echo "<strong>amount: </strong> ". $item->getAmount() ."</p> "; |
|
157 | + echo "<p><strong>id: </strong> ".$item->getId()."</br> "; |
|
158 | + echo "<strong>description: </strong> ".$item->getDescription()."</br> "; |
|
159 | + echo "<strong>quantity: </strong> ".$item->getQuantity()."</br> "; |
|
160 | + echo "<strong>amount: </strong> ".$item->getAmount()."</p> "; |
|
161 | 161 | } |
162 | 162 | |
163 | - echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName() ."</p> "; |
|
164 | - echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail() ."</p> "; |
|
165 | - echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode() . " - " . |
|
166 | - $transaction->getSender()->getPhone()->getNumber() . "</p> "; |
|
163 | + echo "<p><strong>senderName: </strong> ".$transaction->getSender()->getName()."</p> "; |
|
164 | + echo "<p><strong>senderEmail: </strong> ".$transaction->getSender()->getEmail()."</p> "; |
|
165 | + echo "<p><strong>senderPhone: </strong> ".$transaction->getSender()->getPhone()->getAreaCode()." - ". |
|
166 | + $transaction->getSender()->getPhone()->getNumber()."</p> "; |
|
167 | 167 | echo "<p><strong>Shipping: </strong></p>"; |
168 | - echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet() ."</p> "; |
|
169 | - echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber() ."</p> "; |
|
170 | - echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement() ."</p> "; |
|
171 | - echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict() ."</p> "; |
|
172 | - echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode() ."</p> "; |
|
173 | - echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity() ."</p> "; |
|
174 | - echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState() ."</p> "; |
|
175 | - echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry() ."</p> "; |
|
168 | + echo "<p><strong>street: </strong> ".$transaction->getShipping()->getAddress()->getStreet()."</p> "; |
|
169 | + echo "<p><strong>number: </strong> ".$transaction->getShipping()->getAddress()->getNumber()."</p> "; |
|
170 | + echo "<p><strong>complement: </strong> ".$transaction->getShipping()->getAddress()->getComplement()."</p> "; |
|
171 | + echo "<p><strong>district: </strong> ".$transaction->getShipping()->getAddress()->getDistrict()."</p> "; |
|
172 | + echo "<p><strong>postalCode: </strong> ".$transaction->getShipping()->getAddress()->getPostalCode()."</p> "; |
|
173 | + echo "<p><strong>city: </strong> ".$transaction->getShipping()->getAddress()->getCity()."</p> "; |
|
174 | + echo "<p><strong>state: </strong> ".$transaction->getShipping()->getAddress()->getState()."</p> "; |
|
175 | + echo "<p><strong>country: </strong> ".$transaction->getShipping()->getAddress()->getCountry()."</p> "; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | echo "<pre>"; |
@@ -26,63 +26,63 @@ |
||
26 | 26 | class GetInstallments |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
31 | - try { |
|
32 | - |
|
33 | - /** |
|
34 | - * #### Credentials ##### |
|
35 | - * Replace the parameters below with your credentials |
|
36 | - * You can also get your credentials from a config file. See an example: |
|
37 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
38 | - */ |
|
39 | - |
|
40 | - // seller authentication |
|
41 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
42 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
43 | - |
|
44 | - // application authentication |
|
45 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
46 | - |
|
47 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
48 | - |
|
49 | - $session = "97e12ffaaad04452b9e2b5e9efefd3ee"; |
|
50 | - $cardBrand = "visa"; |
|
51 | - |
|
52 | - try { |
|
53 | - $installments = PagSeguroInstallmentService::getInstallments($credentials, |
|
54 | - $session, |
|
55 | - "5000.00", |
|
56 | - $cardBrand); |
|
57 | - } catch (Exception $e) { |
|
58 | - die($e->getMessage()); |
|
59 | - } |
|
60 | - |
|
61 | - self::printInstallment($installments); |
|
62 | - |
|
63 | - |
|
64 | - } catch (PagSeguroServiceException $e) { |
|
65 | - die($e->getMessage()); |
|
66 | - } |
|
67 | - } |
|
68 | - |
|
69 | - public static function printInstallment($installments) |
|
70 | - { |
|
71 | - |
|
72 | - if ($installments) { |
|
73 | - echo "<h2>Installments</h2>"; |
|
74 | - |
|
75 | - foreach ($installments as $installment) { |
|
76 | - echo "<p> <strong> brand: </strong> ". $installment->getCardBrand()."<br> "; |
|
77 | - echo "<strong> quantity: </strong> ". $installment->getQuantity()."<br> "; |
|
78 | - echo "<strong> installmentAmount: </strong> ". $installment->getInstallmentAmount()."<br> "; |
|
79 | - echo "<strong> totalAmount: </strong> ". $installment->getTotalAmount()."<br> "; |
|
80 | - echo "<strong> interestFree: </strong> ". $installment->getInterestFree()."</p> "; |
|
81 | - |
|
82 | - } |
|
83 | - } |
|
84 | - echo "<pre>"; |
|
85 | - } |
|
29 | + public static function main() |
|
30 | + { |
|
31 | + try { |
|
32 | + |
|
33 | + /** |
|
34 | + * #### Credentials ##### |
|
35 | + * Replace the parameters below with your credentials |
|
36 | + * You can also get your credentials from a config file. See an example: |
|
37 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
38 | + */ |
|
39 | + |
|
40 | + // seller authentication |
|
41 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
42 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
43 | + |
|
44 | + // application authentication |
|
45 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
46 | + |
|
47 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
48 | + |
|
49 | + $session = "97e12ffaaad04452b9e2b5e9efefd3ee"; |
|
50 | + $cardBrand = "visa"; |
|
51 | + |
|
52 | + try { |
|
53 | + $installments = PagSeguroInstallmentService::getInstallments($credentials, |
|
54 | + $session, |
|
55 | + "5000.00", |
|
56 | + $cardBrand); |
|
57 | + } catch (Exception $e) { |
|
58 | + die($e->getMessage()); |
|
59 | + } |
|
60 | + |
|
61 | + self::printInstallment($installments); |
|
62 | + |
|
63 | + |
|
64 | + } catch (PagSeguroServiceException $e) { |
|
65 | + die($e->getMessage()); |
|
66 | + } |
|
67 | + } |
|
68 | + |
|
69 | + public static function printInstallment($installments) |
|
70 | + { |
|
71 | + |
|
72 | + if ($installments) { |
|
73 | + echo "<h2>Installments</h2>"; |
|
74 | + |
|
75 | + foreach ($installments as $installment) { |
|
76 | + echo "<p> <strong> brand: </strong> ". $installment->getCardBrand()."<br> "; |
|
77 | + echo "<strong> quantity: </strong> ". $installment->getQuantity()."<br> "; |
|
78 | + echo "<strong> installmentAmount: </strong> ". $installment->getInstallmentAmount()."<br> "; |
|
79 | + echo "<strong> totalAmount: </strong> ". $installment->getTotalAmount()."<br> "; |
|
80 | + echo "<strong> interestFree: </strong> ". $installment->getInterestFree()."</p> "; |
|
81 | + |
|
82 | + } |
|
83 | + } |
|
84 | + echo "<pre>"; |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | GetInstallments::main(); |
@@ -73,11 +73,11 @@ |
||
73 | 73 | echo "<h2>Installments</h2>"; |
74 | 74 | |
75 | 75 | foreach ($installments as $installment) { |
76 | - echo "<p> <strong> brand: </strong> ". $installment->getCardBrand()."<br> "; |
|
77 | - echo "<strong> quantity: </strong> ". $installment->getQuantity()."<br> "; |
|
78 | - echo "<strong> installmentAmount: </strong> ". $installment->getInstallmentAmount()."<br> "; |
|
79 | - echo "<strong> totalAmount: </strong> ". $installment->getTotalAmount()."<br> "; |
|
80 | - echo "<strong> interestFree: </strong> ". $installment->getInterestFree()."</p> "; |
|
76 | + echo "<p> <strong> brand: </strong> ".$installment->getCardBrand()."<br> "; |
|
77 | + echo "<strong> quantity: </strong> ".$installment->getQuantity()."<br> "; |
|
78 | + echo "<strong> installmentAmount: </strong> ".$installment->getInstallmentAmount()."<br> "; |
|
79 | + echo "<strong> totalAmount: </strong> ".$installment->getTotalAmount()."<br> "; |
|
80 | + echo "<strong> interestFree: </strong> ".$installment->getInterestFree()."</p> "; |
|
81 | 81 | |
82 | 82 | } |
83 | 83 | } |
@@ -26,42 +26,42 @@ |
||
26 | 26 | class RequestCancellation |
27 | 27 | { |
28 | 28 | |
29 | - public static function main() |
|
30 | - { |
|
29 | + public static function main() |
|
30 | + { |
|
31 | 31 | |
32 | - $transactionCode = "33373E4564B94A58A0E764F07B49715C"; |
|
32 | + $transactionCode = "33373E4564B94A58A0E764F07B49715C"; |
|
33 | 33 | |
34 | - try { |
|
34 | + try { |
|
35 | 35 | |
36 | - /** |
|
37 | - * @todo |
|
38 | - * #### Credentials ##### |
|
39 | - * Replace the parameters below with your credentials (e-mail and token) |
|
40 | - * You can also get your credentials from a config file. See an example: |
|
41 | - * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
42 | - */ |
|
43 | - $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
44 | - "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
36 | + /** |
|
37 | + * @todo |
|
38 | + * #### Credentials ##### |
|
39 | + * Replace the parameters below with your credentials (e-mail and token) |
|
40 | + * You can also get your credentials from a config file. See an example: |
|
41 | + * $credentials = PagSeguroConfig::getAccountCredentials(); |
|
42 | + */ |
|
43 | + $credentials = new PagSeguroAccountCredentials("[email protected]", |
|
44 | + "E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
45 | 45 | |
46 | - $response = PagSeguroCancelService::createRequest($credentials, $transactionCode); |
|
46 | + $response = PagSeguroCancelService::createRequest($credentials, $transactionCode); |
|
47 | 47 | |
48 | - self::printResponse($response); |
|
48 | + self::printResponse($response); |
|
49 | 49 | |
50 | - } catch (PagSeguroServiceException $e) { |
|
51 | - die($e->getMessage()); |
|
52 | - } |
|
53 | - } |
|
50 | + } catch (PagSeguroServiceException $e) { |
|
51 | + die($e->getMessage()); |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - public static function printResponse($response) |
|
56 | - { |
|
55 | + public static function printResponse($response) |
|
56 | + { |
|
57 | 57 | |
58 | - if ($response) { |
|
59 | - echo utf8_decode("<h2>Response:</h2>"); |
|
60 | - echo "<p>".$response ."</p> "; |
|
61 | - } |
|
58 | + if ($response) { |
|
59 | + echo utf8_decode("<h2>Response:</h2>"); |
|
60 | + echo "<p>".$response ."</p> "; |
|
61 | + } |
|
62 | 62 | |
63 | - echo "<pre>"; |
|
64 | - } |
|
63 | + echo "<pre>"; |
|
64 | + } |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | RequestCancellation::main(); |
@@ -57,7 +57,7 @@ |
||
57 | 57 | |
58 | 58 | if ($response) { |
59 | 59 | echo utf8_decode("<h2>Response:</h2>"); |
60 | - echo "<p>".$response ."</p> "; |
|
60 | + echo "<p>".$response."</p> "; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | echo "<pre>"; |