Advertisement
Guest User

Untitled

a guest
May 9th, 2016
1,186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.46 KB | None | 0 0
  1. <?php
  2. $email = 'seu email cadastrado no pagseguro';
  3. $token = 'seu token';
  4. $url = 'https://ws.pagseguro.uol.com.br/v2/checkout/?email=' . $email . '&token=' . $token;
  5. $xml = '<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
  6.    <checkout>
  7.        <currency>BRL</currency>
  8.        <redirectURL>http://www.minhaloja.com.br/paginaDeRedirecionamento</redirectURL>
  9.        <items>
  10.            <item>
  11.                <id>1</id>
  12.                <description>1000 Cash</description>
  13.                <amount>1.00</amount>
  14.                <quantity>1</quantity>
  15.                <weight>1000</weight>
  16.            </item>
  17.        </items>
  18.        <reference>REF_1</reference>
  19.        <sender>
  20.            <name>Caio Henrique</name>
  21.            <email>caio_bnh22@hotmail.com</email>
  22.            <phone>
  23.                <areaCode>21</areaCode>
  24.                <number>00000000</number>
  25.            </phone>
  26.        </sender>
  27.    </checkout>';
  28.  
  29.     $curl = curl_init($url);
  30.     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  31.     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  32.     curl_setopt($curl, CURLOPT_HTTPHEADER, Array('Content-Type: application/xml; charset=ISO-8859-1'));
  33.     curl_setopt($curl, CURLOPT_POSTFIELDS, $xml);
  34.     $xml= curl_exec($curl);
  35.  
  36.     curl_close($curl);
  37.  
  38.     $xml= simplexml_load_string($xml);
  39.  
  40.     $result = sprintf("https://pagseguro.uol.com.br/v2/checkout/payment.html?code=%s", $xml -> code);
  41.     echo "<a href='$result'>Comprar 1000 Cash</a>";
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement