PayPal\Api\CreditCard::setMerchantId PHP Method

setMerchantId() public method

A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
public setMerchantId ( string $merchant_id )
$merchant_id string
    public function setMerchantId($merchant_id)
    {
        $this->merchant_id = $merchant_id;
        return $this;
    }

Usage Example

 public function store(CreditCardInterface $cardInterface, Address $address = null, $externalCustomerId = null, $merchantId = null, $externalCardId = null)
 {
     $dispatcher = $this->connectionService->getDispatcher();
     $apiContext = $this->connectionService->getApiContext();
     $dispatcher->dispatch(CreditCardEvent::STORE_SETUP);
     $creditCard = new CreditCard();
     $creditCard->setType($cardInterface->getType())->setNumber($cardInterface->getNumber())->setExpireMonth($cardInterface->getExpireMonth())->setExpireYear($cardInterface->getExpireYear())->setCvv2($cardInterface->getCsc())->setFirstName($cardInterface->getFirstName())->setLastName($cardInterface->getLastName());
     if ($address instanceof Address) {
         $creditCard->setBillingAddress($address);
     }
     if ($externalCustomerId !== null) {
         $creditCard->setExternalCustomerId($externalCustomerId);
     }
     if ($merchantId !== null) {
         $creditCard->setMerchantId($merchantId);
     }
     if ($externalCardId !== null) {
         $creditCard->setExternalCardId($externalCardId);
     }
     $creditCardEvent = new CreditCardEvent($creditCard);
     $dispatcher->dispatch(CreditCardEvent::STORE_START, $creditCardEvent);
     $result = $creditCard->create($apiContext);
     $creditCardEvent = new CreditCardEvent($result);
     $dispatcher->dispatch(CreditCardEvent::STORE_END, $creditCardEvent);
     return $result;
 }
All Usage Examples Of PayPal\Api\CreditCard::setMerchantId