reginaldojunior /
winners
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php // |
||
| 2 | |||
| 3 | /* |
||
| 4 | * *********************************************************************** |
||
| 5 | Copyright [2014] [PagSeguro Internet Ltda.] |
||
| 6 | |||
| 7 | Licensed under the Apache License, Version 2.0 (the "License"); |
||
| 8 | you may not use this file except in compliance with the License. |
||
| 9 | You may obtain a copy of the License at |
||
| 10 | |||
| 11 | http://www.apache.org/licenses/LICENSE-2.0 |
||
| 12 | |||
| 13 | Unless required by applicable law or agreed to in writing, software |
||
| 14 | distributed under the License is distributed on an "AS IS" BASIS, |
||
| 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
| 16 | See the License for the specific language governing permissions and |
||
| 17 | limitations under the License. |
||
| 18 | * *********************************************************************** |
||
| 19 | */ |
||
| 20 | |||
| 21 | require_once "../PagSeguroLibrary/PagSeguroLibrary.php"; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Class with a main method to illustrate the usage of the domain class PagSeguroDirectPaymentRequest |
||
| 25 | */ |
||
| 26 | class CreateTransactionUsingCreditCard |
||
| 27 | { |
||
| 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"); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 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 | } |
||
| 220 | |||
| 221 | CreateTransactionUsingCreditCard::main(); |
||
| 222 |