From ae31151ba382581d8da28b7190a4b7d969cc7b05 Mon Sep 17 00:00:00 2001 From: Jay Patel Date: Mon, 17 Oct 2016 17:12:07 -0500 Subject: [PATCH] Use PaymentCard instead of CreditCard - Fixed deprecation messages. - Fixes #639. - Fixes #648. - Updated Samples. --- lib/PayPal/Api/FundingInstrument.php | 5 +++-- .../billing/CreateBillingAgreementWithCreditCard.php | 8 ++++---- .../billing/CreateBillingAgreementWithCreditCard.html | 8 ++++---- sample/doc/payments/AuthorizePayment.html | 8 ++++---- sample/doc/payments/CreatePayment.html | 10 +++++----- sample/payments/AuthorizePayment.php | 8 ++++---- sample/payments/CreatePayment.php | 10 +++++----- 7 files changed, 29 insertions(+), 28 deletions(-) diff --git a/lib/PayPal/Api/FundingInstrument.php b/lib/PayPal/Api/FundingInstrument.php index 18907308..b898a248 100644 --- a/lib/PayPal/Api/FundingInstrument.php +++ b/lib/PayPal/Api/FundingInstrument.php @@ -21,6 +21,7 @@ class FundingInstrument extends PayPalModel * Credit Card instrument. * * @param \PayPal\Api\CreditCard $credit_card + * @deprecated Please use #setPaymentCard instead * * @return $this */ @@ -34,6 +35,8 @@ public function setCreditCard($credit_card) * Credit Card instrument. * * @return \PayPal\Api\CreditCard + * @deprecated Please use #setPaymentCard instead + * */ public function getCreditCard() { @@ -66,7 +69,6 @@ public function getCreditCardToken() /** * Payment Card information. * - * @deprecated Not publicly available * @param \PayPal\Api\PaymentCard $payment_card * * @return $this @@ -80,7 +82,6 @@ public function setPaymentCard($payment_card) /** * Payment Card information. * - * @deprecated Not publicly available * @return \PayPal\Api\PaymentCard */ public function getPaymentCard() diff --git a/sample/billing/CreateBillingAgreementWithCreditCard.php b/sample/billing/CreateBillingAgreementWithCreditCard.php index ae4f25c6..935cb287 100644 --- a/sample/billing/CreateBillingAgreementWithCreditCard.php +++ b/sample/billing/CreateBillingAgreementWithCreditCard.php @@ -12,10 +12,10 @@ $createdPlan = require 'UpdatePlan.php'; use PayPal\Api\Agreement; -use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; use PayPal\Api\PayerInfo; +use PayPal\Api\PaymentCard; use PayPal\Api\Plan; use PayPal\Api\ShippingAddress; @@ -70,15 +70,15 @@ ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com'))); // Add Credit Card to Funding Instruments -$creditCard = new CreditCard(); -$creditCard->setType('visa') +$paymentCard = new PaymentCard(); +$paymentCard->setType('visa') ->setNumber('4491759698858890') ->setExpireMonth('12') ->setExpireYear('2017') ->setCvv2('128'); $fundingInstrument = new FundingInstrument(); -$fundingInstrument->setCreditCard($creditCard); +$fundingInstrument->setPaymentCard($paymentCard); $payer->setFundingInstruments(array($fundingInstrument)); //Add Payer to Agreement $agreement->setPayer($payer); diff --git a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html index a44290c0..c9e52a62 100644 --- a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html +++ b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html @@ -6,10 +6,10 @@ $createdPlan = require 'UpdatePlan.php'; use PayPal\Api\Agreement; -use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; use PayPal\Api\PayerInfo; +use PayPal\Api\PaymentCard; use PayPal\Api\Plan; use PayPal\Api\ShippingAddress; @@ -55,15 +55,15 @@ $plan->setId($createdPlan->getId()); $agreement->setPlan($plan);

Add Payer

$payer = new Payer(); $payer->setPaymentMethod('credit_card') - ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));

Add Credit Card to Funding Instruments

$creditCard = new CreditCard(); -$creditCard->setType('visa') + ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));

Add Credit Card to Funding Instruments

$paymentCard = new PaymentCard(); +$paymentCard->setType('visa') ->setNumber('4491759698858890') ->setExpireMonth('12') ->setExpireYear('2017') ->setCvv2('128'); $fundingInstrument = new FundingInstrument(); -$fundingInstrument->setCreditCard($creditCard); +$fundingInstrument->setPaymentCard($paymentCard); $payer->setFundingInstruments(array($fundingInstrument)); //Add Payer to Agreement $agreement->setPayer($payer);

Add Shipping Address

$shippingAddress = new ShippingAddress(); diff --git a/sample/doc/payments/AuthorizePayment.html b/sample/doc/payments/AuthorizePayment.html index f220afcc..4f23b152 100644 --- a/sample/doc/payments/AuthorizePayment.html +++ b/sample/doc/payments/AuthorizePayment.html @@ -5,10 +5,10 @@ use PayPal\Api\Address; use PayPal\Api\Amount; -use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; use PayPal\Api\Payment; +use PayPal\Api\PaymentCard; use PayPal\Api\Transaction;

The biggest difference between creating a payment, and authorizing a payment is to set the intent of payment to correct setting. In this case, it would be 'authorize'

$addr = new Address(); $addr->setLine1("3909 Witmer Road") @@ -19,8 +19,8 @@ ->setCountryCode("US") ->setPhone("716-298-1822"); -$card = new CreditCard(); -$card->setType("visa") +$paymentCard = new PaymentCard(); +$paymentCard->setType("visa") ->setNumber("4417119669820331") ->setExpireMonth("11") ->setExpireYear("2019") @@ -30,7 +30,7 @@ ->setBillingAddress($addr); $fi = new FundingInstrument(); -$fi->setCreditCard($card); +$fi->setPaymentCard($paymentCard); $payer = new Payer(); $payer->setPaymentMethod("credit_card") diff --git a/sample/doc/payments/CreatePayment.html b/sample/doc/payments/CreatePayment.html index f8b54f9e..b9a35903 100644 --- a/sample/doc/payments/CreatePayment.html +++ b/sample/doc/payments/CreatePayment.html @@ -5,16 +5,16 @@ REST API is restricted in some countries. API used: /v1/payments/payment

require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; -use PayPal\Api\CreditCard; use PayPal\Api\Details; use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; use PayPal\Api\Payer; use PayPal\Api\Payment; -use PayPal\Api\Transaction;

CreditCard

-

A resource representing a credit card that can be -used to fund a payment.

$card = new CreditCard(); +use PayPal\Api\PaymentCard; +use PayPal\Api\Transaction;

PaymentCard

+

A resource representing a payment card that can be +used to fund a payment.

$card = new PaymentCard(); $card->setType("visa") ->setNumber("4669424246660779") ->setExpireMonth("11") @@ -25,7 +25,7 @@

A resource representing a Payer's funding instrument. For direct credit card payments, set the CreditCard field on this object.

$fi = new FundingInstrument(); -$fi->setCreditCard($card);

Payer

+$fi->setPaymentCard($card);

Payer

A resource representing a Payer that funds a payment For direct credit card payments, set payment method to 'credit_card' and add an array of funding instruments.

$payer = new Payer(); diff --git a/sample/payments/AuthorizePayment.php b/sample/payments/AuthorizePayment.php index f7959fe2..205b50ae 100644 --- a/sample/payments/AuthorizePayment.php +++ b/sample/payments/AuthorizePayment.php @@ -8,10 +8,10 @@ use PayPal\Api\Address; use PayPal\Api\Amount; -use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; use PayPal\Api\Payment; +use PayPal\Api\PaymentCard; use PayPal\Api\Transaction; // The biggest difference between creating a payment, and authorizing a payment is to set the intent of payment @@ -25,8 +25,8 @@ ->setCountryCode("US") ->setPhone("716-298-1822"); -$card = new CreditCard(); -$card->setType("visa") +$paymentCard = new PaymentCard(); +$paymentCard->setType("visa") ->setNumber("4417119669820331") ->setExpireMonth("11") ->setExpireYear("2019") @@ -36,7 +36,7 @@ ->setBillingAddress($addr); $fi = new FundingInstrument(); -$fi->setCreditCard($card); +$fi->setPaymentCard($paymentCard); $payer = new Payer(); $payer->setPaymentMethod("credit_card") diff --git a/sample/payments/CreatePayment.php b/sample/payments/CreatePayment.php index 059622ed..a8a0d1dc 100644 --- a/sample/payments/CreatePayment.php +++ b/sample/payments/CreatePayment.php @@ -10,19 +10,19 @@ require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Amount; -use PayPal\Api\CreditCard; use PayPal\Api\Details; use PayPal\Api\FundingInstrument; use PayPal\Api\Item; use PayPal\Api\ItemList; use PayPal\Api\Payer; use PayPal\Api\Payment; +use PayPal\Api\PaymentCard; use PayPal\Api\Transaction; -// ### CreditCard -// A resource representing a credit card that can be +// ### PaymentCard +// A resource representing a payment card that can be // used to fund a payment. -$card = new CreditCard(); +$card = new PaymentCard(); $card->setType("visa") ->setNumber("4669424246660779") ->setExpireMonth("11") @@ -36,7 +36,7 @@ // For direct credit card payments, set the CreditCard // field on this object. $fi = new FundingInstrument(); -$fi->setCreditCard($card); +$fi->setPaymentCard($card); // ### Payer // A resource representing a Payer that funds a payment