示例#1
0
 protected function curlRequest($ctrl, $method, $param)
 {
     $url = \AlternativePayments\Config::getApiUrl() . "/" . $ctrl;
     $key = \AlternativePayments\Config::getApiKey();
     if ($key == null) {
         throw new ApiException("API Key not defined.");
     }
     $encodedKey = base64_encode($key);
     if ($method == "GET" && ($param != null && $param != "")) {
         $url = $url . "/" . $param;
     }
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $param);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'User-Agent: AlternativePayments PHP SDK v0.1.0', 'Content-Length: ' . strlen($param), 'Authorization: Basic ' . $encodedKey));
     $result = curl_exec($curl);
     if (!$result) {
         throw new ApiException("Connection Error - Invalid URL");
     }
     $this->parseResponse(curl_getinfo($curl), $result);
     curl_close($curl);
     return $result;
 }
示例#2
0
<?php

require_once '../vendor/autoload.php';
use AlternativePayments\Config;
Config::setApiKey("rHErfc0m7n9GKFMNFSfNuO1QM7lFhCEh3mv0MKGR");
Config::setApiUrl("https://api.alternativepayments.com/api");
?>
<html>
    <head>        
        <title>Alternative Payments test examples</title>
    </head>
    <body>
        <table>
            <tr>
                <td><strong>Options:</strong></td>
            </tr>
            <tr>
                <td><a href="index.php?option=customer&action=add">Add customer</a></td>
                <td><a href="index.php?option=customer&action=get">Get customer</a></td>
                <td><a href="index.php?option=customer&action=getall">Get all customers</a></td>
            </tr>
            <tr>
                <td><table>
                        <tr>
                            <td><a href="index.php?option=transaction&action=create_new_transaction_sepa">Add SEPA transaction</a></td></tr>
                        <tr>
                            <td><a href="index.php?option=transaction&action=create_new_transaction_brazilpayboleto">Add BrazilPayBoleto transaction</a></td></tr>
                        <tr>
                            <td><a href="index.php?option=transaction&action=create_new_transaction_brazilpaybanktransfer">Add BrazilPayBankTransfer transaction</a></td></tr>
                        <tr>
                            <td><a href="index.php?option=transaction&action=create_new_transaction_teleingreso">Add Teleingreso transaction</a></td></tr>