PayPal\Api\CreditCard::setNumber PHP Method

setNumber() public method

Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
public setNumber ( string $number )
$number string
    public function setNumber($number)
    {
        $this->number = $number;
        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::setNumber