1. Go to this page and download the library: Download bocapro/boca-payments library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bocapro / boca-payments example snippets
use BetterFutures\BocaPayments\Facades\BocaPayments;
use BetterFutures\BocaPayments\Data\Customer;
use BetterFutures\BocaPayments\Enums\Currency;
use BetterFutures\BocaPayments\Enums\Gateway;
$response = BocaPayments::setAmount(99.99)
->setCurrency(Currency::USD)
->setCustomer(new Customer(email: '[email protected]', firstName: 'John', lastName: 'Doe'))
->setDescription('Order #1234')
->setReturnUrl('https://myapp.com/payment/success')
->setCancelUrl('https://myapp.com/payment/cancel')
->pay();
$response->status; // PaymentStatus::Completed, Pending, Failed, RequiresAction, etc.
$response->paymentId; // "pi_3abc123" - store this in your orders table
$response->redirectUrl; // "https://..." - for gateways that redirect (PayPal, MercadoPago)
$response->html; // rendered html for gateways that need it
$response->message; // "succeeded"
$response->raw; // full raw gateway response
$response->isSuccessful(); // true if completed
$response->
use BetterFutures\BocaPayments\Facades\BocaPayments;
use BetterFutures\BocaPayments\Data\Customer;
use BetterFutures\BocaPayments\Enums\Currency;
use BetterFutures\BocaPayments\Enums\Gateway;
use Smpita\TypeAs\TypeAs;
class PaymentController extends Controller
{
public function pay(Request $request)
{
$response = BocaPayments::gateway(Gateway::from($request->input('gateway', 'stripe')))
->setAmount(TypeAs::float($request->input('amount')))
->setCurrency(Currency::USD)
->setCustomer(new Customer(
email: TypeAs::string($request->input('email')),
firstName: TypeAs::nullableString($request->input('first_name')),
lastName: TypeAs::nullableString($request->input('last_name')),
))
->setReturnUrl(route('payment.verify'))
->pay();
if ($response->