Created
November 10, 2012 06:15
-
-
Save claudiosanches/4050139 to your computer and use it in GitHub Desktop.
PagSeguro Wordpress WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$email = ''; | |
$token = ''; | |
$postdata = 'email=' . $email . '&token=' . $token . '¤cy=BRL&itemId1=0001&itemDescription1=Notebook Prata&itemAmount1=243.00&itemQuantity1=1&itemWeight1=1000&itemId2=0002&itemDescription2=Notebook Rosa&itemAmount2=256.00&itemQuantity2=2&itemWeight2=750&reference=REF1234&senderName=Jose Comprador&senderAreaCode=11&senderPhone=56273440&[email protected]&shippingType=1&shippingAddressStreet=Av. Brig. Faria Lima&shippingAddressNumber=1384&shippingAddressComplement=5o andar&shippingAddressDistrict=Jardim Paulistano&shippingAddressPostalCode=01452002&shippingAddressCity=Sao Paulo&shippingAddressState=SP&shippingAddressCountry=BRA'; | |
// Send back post vars. | |
$params = array( | |
'body' => $postdata, | |
'sslverify' => false, | |
'timeout' => 30, | |
'headers' => array( 'content-type' => 'application/x-www-form-urlencoded; charset=ISO-8859-1' ) | |
); | |
// Check to see if the request was valid. | |
if ( !is_wp_error( $response ) && $response['response']['code'] == 200 && $response['response']['message'] == 'OK' ) { | |
// Get the Body. | |
$body = wp_remote_retrieve_body( $response ); | |
// XML to Object. | |
$xml = new SimpleXMLElement($body); | |
} else { | |
$xml->code = null; | |
} | |
if ( $xml->code ) : | |
?> | |
<a href="https://pagseguro.uol.com.br/v2/checkout/payment.html?code=<?php echo $xml->code; ?>" target="_blank">Pagar</a> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment