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 1890730..b898a24 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 @@ class FundingInstrument extends PayPalModel
* Credit Card instrument.
*
* @return \PayPal\Api\CreditCard
+ * @deprecated Please use #setPaymentCard instead
+ *
*/
public function getCreditCard()
{
@@ -66,7 +69,6 @@ class FundingInstrument extends PayPalModel
/**
* Payment Card information.
*
- * @deprecated Not publicly available
* @param \PayPal\Api\PaymentCard $payment_card
*
* @return $this
@@ -80,7 +82,6 @@ class FundingInstrument extends PayPalModel
/**
* 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 ae4f25c..935cb28 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 @@ $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')
+$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 a44290c..c9e52a6 100644
--- a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html
+++ b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html
@@ -6,10 +6,10 @@ define Plan information to create an agreement. Make sure the plan you are using
$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 @@ Please note that the plan Id should be only set in this case.
$plan->setId($createdPlan->getId());
$agreement->setPlan($plan);$payer = new Payer();
$payer->setPaymentMethod('credit_card')
- ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));
$creditCard = new CreditCard();
-$creditCard->setType('visa')
+ ->setPayerInfo(new PayerInfo(array('email' => 'jaypatel512-facilitator@hotmail.com')));
$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));
$agreement->setPayer($payer);
$shippingAddress = new ShippingAddress();
diff --git a/sample/doc/payments/AuthorizePayment.html b/sample/doc/payments/AuthorizePayment.html
index f220afc..4f23b15 100644
--- a/sample/doc/payments/AuthorizePayment.html
+++ b/sample/doc/payments/AuthorizePayment.html
@@ -5,10 +5,10 @@ API used: /v1/payments/authorization
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;
$addr = new Address();
$addr->setLine1("3909 Witmer Road")
@@ -19,8 +19,8 @@ to correct setting. In this case, it would be 'authorize'
"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 @@ to correct setting. In this case, it would be 'authorize'
$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 f8b54f9..b9a3590 100644
--- a/sample/doc/payments/CreatePayment.html
+++ b/sample/doc/payments/CreatePayment.html
@@ -5,16 +5,16 @@ credit card payment and related features using the
REST API is restricted in some countries.
API used: /v1/payments/paymentrequire __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;
$card = new CreditCard();
+use PayPal\Api\PaymentCard;
+use PayPal\Api\Transaction;
$card = new PaymentCard();
$card->setType("visa")
->setNumber("4669424246660779")
->setExpireMonth("11")
@@ -25,7 +25,7 @@ used to fund a payment.
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 = new Payer();
diff --git a/sample/payments/AuthorizePayment.php b/sample/payments/AuthorizePayment.php
index f7959fe..205b50a 100644
--- a/sample/payments/AuthorizePayment.php
+++ b/sample/payments/AuthorizePayment.php
@@ -8,10 +8,10 @@ require __DIR__ . '/../bootstrap.php';
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 @@ $addr->setLine1("3909 Witmer Road")
->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 @@ $card->setType("visa")
->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 059622e..a8a0d1d 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 @@ $card->setType("visa")
// 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
Add Payer