PayPal\Api\CreditCard::setType PHP Method

setType() public method

Credit card type. Valid types are: visa, mastercard, discover, amex
public setType ( string $type )
$type string
    public function setType($type)
    {
        $this->type = $type;
        return $this;
    }

Usage Example

示例#1
0
 /**
  * Runs a card payment with PayPal
  *
  * @link https://devtools-paypal.com/guide/pay_creditcard/php?interactive=ON&env=sandbox
  * @return PayPal\Api\Payment 
  */
 public function payCard($cardInfo = [], $sum = 0, $message = '')
 {
     $card = new CreditCard();
     $card->setType($cardInfo['cardType']);
     $card->setNumber($cardInfo['cardNumber']);
     $card->setExpireMonth($cardInfo['expMonth']);
     $card->setExpireYear($cardInfo['expYear']);
     $card->setFirstName($cardInfo['firstName']);
     $card->setLastName($cardInfo['lastName']);
     $fundingInstrument = new FundingInstrument();
     $fundingInstrument->setCreditCard($card);
     $payer = new Payer();
     $payer->setPaymentMethod('credit_card');
     $payer->setFundingInstruments(array($fundingInstrument));
     $amount = new Amount();
     $amount->setCurrency($this->currency);
     $amount->setTotal($sum);
     $transaction = new Transaction();
     $transaction->setAmount($amount);
     if ($message) {
         $transaction->setDescription($message);
     }
     $payment = new Payment();
     $payment->setIntent('sale');
     $payment->setPayer($payer);
     $payment->setTransactions(array($transaction));
     return $payment->create($this->_apiContext);
     // get state from this json
 }
All Usage Examples Of PayPal\Api\CreditCard::setType