From PhpCOIN DocumentationBRPay (now named PagSeguro) is a Brazilian payment system that is a little more complex than the other PayLinks due to the way that BRPay handles the processing of PayLinks:
- For PayPal and similar, a FORM on your site sends data to PayPal, which processes the payment and then sends the customer back to your site where we can display an appropriate success of fail message.
- With BRPay, a FORM on your site sends data to BRPAY, which holds the customer on their site while they send info to a special page on your site which echoes the data back to BRPay which then responds with a validation code then finally sends the customer back to your site where we can display an appropriate success of fail message.
Despite this, Using BRPay as a payment method is still a relatively simple process:
- Goto http://www.brpay.com.br and set yourself up with an account
- Log into phpCOIN on your website as an admin
- Add the vendor
- Add paylinks
Admin -> Vendors
If BRPay exists in the list of available vendors, you can simply edit the existing record. If it does not exist, then click [Add New] to add BRPay as a payment method that you will accept. The info should look like the following:
Vendor ID: (will be auto-completed by phpCOIN) Status: On (Off to disable this payment method) Vendor Name: BRPay (for the drop-down lists) Buy Return Param Name: Status Buy Return Param Value: 1 URL / Website: http://www.brpay.com.br Use IPN: Yes Notes:
Admin -> PayLinks
Select the PayLink you want to edit, or click [Create New] to create a new one. Paste the following code into the order link, changing the parameters shown in bold:
Vendor Product Id: (Auto-created by phpCOIN) Vendor ID: (From the drop-down, choose "BRPay") Product ID: (From the drop-down, choose the product that this paylink applies to) Description: BRPay Product x (for listing) Order Link: (This is for the "pay link" html provided by BRPay, such as: <form method="post" action="https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx"> <input type="hidden" name="email_cobranca" value="YOURBRPAYEMAIL" /> <input type="hidden" name="tipo" value="CP" /> <input type="hidden" name="moeda" value="BRL" /> <input type="hidden" name="item_id" value="<prod_id>" /> <input type="hidden" name="item_descr" value="<prod_desc>" /> <input type="hidden" name="item_quant" value="1" /> <input type="hidden" name="item_valor" value="<total_amt>" /> <input type="hidden" name="frete" value="0" /> <input type="hidden" name="peso" value="0" /> <input type="hidden" name="cliente_email" value="<ord_email>" /> <input type="hidden" name="ref_transacao" value="<invoice_id>" /> <input type="image" src="https://pagseguro.uol.com.br/Security/Imagens/btnComprarBR.jpg" name="submit" alt="Pague com PagSeguro - é rápido, grátis e seguro!" /> </form>
In the above link, the <> tells phpCOIN that it should replace the tag name with the actual value at run-time. For example, leaving <total_amt> means that phpCOIN will enter the actual amount of this order when it displays an order paylink. It also means that you can use the same paylink for every product.
Lather, Rinse, Repeat
Repeat the above steps as many times as necessary, so that you end up with one PayLink for each product or service that will allow BRPay as a payment method.
CallBack Handling File
BRPay performs a callback to your website with the payment data before the surfer is returned to you. phpCOIN can handle this callback via the IPN module ~ simply set http://URL_TO_YOUR_PHPCOIN_INSTALL/coin_modules/ipn/vendors/brpay.php as the URL that BRPay should notify when a payment is received.