Exemple #1
0
 /**
  * Save a credit card with paypal
  *
  * @param array $params	credit card parameters
  */
 public function saveCard($payerId, $firstName, $lastName, $ccNumber, $ccExpirationMonth, $ccExpirationYear, $ccCVV, $ccBrandType)
 {
     $card = new \PayPal\Api\CreditCard();
     $card->setPayerId($payerId);
     $card->setFirstName($firstName);
     $card->setLastName($lastName);
     $card->setType($ccBrandType);
     $card->setNumber($ccNumber);
     $card->setExpireMonth($ccExpirationMonth);
     $card->setExpireYear($ccExpirationYear);
     $card->setCvv2($ccCVV);
     $card->create($this->contextFactory->createContext());
     return $card->getId();
 }
Exemple #2
0
    $cardnumber = mysqli_real_escape_string($link, $_POST['cardnumber']);
    $cvv = mysqli_real_escape_string($link, $_POST['cvv']);
    $monthValueParts = explode('-', mysqli_real_escape_string($link, $_POST['expirationmonth']));
    $expiryYear = $monthValueParts[0];
    $expiryMonth = $monthValueParts[1];
    $firstname = mysqli_real_escape_string($link, $_POST['firstname']);
    $lastname = mysqli_real_escape_string($link, $_POST['lastname']);
    $creditcard = new \PayPal\Api\CreditCard();
    $creditcard->setType($cardtype);
    $creditcard->setNumber($cardnumber);
    $creditcard->setExpire_month($expiryMonth);
    $creditcard->setExpire_year($expiryYear);
    $creditcard->setCvv2($cvv);
    $creditcard->setFirst_name($firstname);
    $creditcard->setLast_name($lastname);
    try {
        $creditcard->create($apiContext);
        //error happens here
        //                echo $creditcard;
        $_SESSION['CARD_CREATED'] = true;
        //allows for dynamic display of card creation later
        header('Location: billing-information.php');
    } catch (\PPConnectionException $ex) {
        echo '<p class="error-catch">Exception thrown!</p>';
        echo '<p class="error-catch">' . $ex . '</p>';
    } finally {
        mysqli_close($link);
    }
    //Something's not working with the way the Credit Card is being sent out
}
require $INC_DIR . "footer.php";
Exemple #3
0
<?php

// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
require __DIR__ . '/vendor/autoload.php';
// 2. Define PP_CONFIG_PATH directory
if (!defined("PP_CONFIG_PATH")) {
    define("PP_CONFIG_PATH", __DIR__);
}
// After Step 2
$creditCard = new \PayPal\Api\CreditCard();
$creditCard->setType("visa")->setNumber("4417119669820331")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper");
// After Step 3
try {
    //ApiContext is not required anymore as it get loaded from file
    $creditCard->create();
    echo $creditCard;
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
    echo $ex;
}
 public function paypalApi()
 {
     require __DIR__ . '/PayPal-PHP-SDK/autoload.php';
     // 2. Provide your Secret Key. Replace the given one with your app clientId, and Secret
     // https://developer.paypal.com/webapps/developer/applications/myapps
     $apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential('AZL8y_b5_YMk3t9FFpIK39QA9c7GhF16rG0L4KPbnxclQw36MoQBHB0pIOFndHdgz3Ims3he7pPgB1I-', 'EF0wu84NNCfmnYX3J1aQlGbia15m67pDAmm2kuGXv9-wh69-ofn7Lv_kWcjKzAiE7fxD27oWEHhBzdyp'));
     // 3. Lets try to save a credit card to Vault using Vault API mentioned here
     // https://developer.paypal.com/webapps/developer/docs/api/#store-a-credit-card
     $creditCard = new \PayPal\Api\CreditCard();
     $creditCard->setType("visa")->setNumber("4417119669820331")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper");
     // 4. Make a Create Call and Print the Card
     try {
         $creditCard->create($apiContext);
         echo $creditCard;
     } catch (\PayPal\Exception\PayPalConnectionException $ex) {
         // This will print the detailed information on the exception.
         //REALLY HELPFUL FOR DEBUGGING
         echo $ex->getData();
     }
 }