forked from LiveCarta/PayPal-PHP-SDK
Sanitize Input for Price Variables
- Updated the model to automatically format the price - Updated the samples to reflect the new changes - More Unit Tests
This commit is contained in:
@@ -33,12 +33,12 @@ $paymentDefinition->setName('Regular Payments')
|
||||
->setFrequency('Month')
|
||||
->setFrequencyInterval("2")
|
||||
->setCycles("12")
|
||||
->setAmount(new Currency(['value' => '100', 'currency' => 'USD']));
|
||||
->setAmount(new Currency(['value' => 100, 'currency' => 'USD']));
|
||||
|
||||
// Charge Models
|
||||
$chargeModel = new ChargeModel();
|
||||
$chargeModel->setType('SHIPPING')
|
||||
->setAmount(new Currency(['value' => '10', 'currency' => 'USD']));
|
||||
->setAmount(new Currency(['value' => 10, 'currency' => 'USD']));
|
||||
|
||||
$paymentDefinition->setChargeModels(array($chargeModel));
|
||||
|
||||
@@ -49,7 +49,7 @@ $merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true")
|
||||
->setAutoBillAmount("yes")
|
||||
->setInitialFailAmountAction("CONTINUE")
|
||||
->setMaxFailAttempts("0")
|
||||
->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD']));
|
||||
->setSetupFee(new Currency(['value' => 1, 'currency' => 'USD']));
|
||||
|
||||
|
||||
$plan->setPaymentDefinitions(array($paymentDefinition));
|
||||
|
||||
@@ -21,7 +21,7 @@ try {
|
||||
|
||||
$amt = new Amount();
|
||||
$amt->setCurrency("USD")
|
||||
->setTotal("1.00");
|
||||
->setTotal(1);
|
||||
|
||||
### Capture
|
||||
$capture = new Capture();
|
||||
|
||||
@@ -44,7 +44,7 @@ $payer->setPaymentMethod("credit_card")
|
||||
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD")
|
||||
->setTotal("1.00");
|
||||
->setTotal(1);
|
||||
|
||||
$transaction = new Transaction();
|
||||
$transaction->setAmount($amount)
|
||||
|
||||
@@ -54,15 +54,15 @@ $item1->setName('Ground Coffee 40 oz')
|
||||
->setDescription('Ground Coffee 40 oz')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(1)
|
||||
->setTax('0.30')
|
||||
->setPrice('7.50');
|
||||
->setTax(0.3)
|
||||
->setPrice(7.50);
|
||||
$item2 = new Item();
|
||||
$item2->setName('Granola bars')
|
||||
->setDescription('Granola Bars with Peanuts')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(5)
|
||||
->setTax('0.20')
|
||||
->setPrice('2.00');
|
||||
->setTax(0.2)
|
||||
->setPrice(2);
|
||||
|
||||
$itemList = new ItemList();
|
||||
$itemList->setItems(array($item1, $item2));
|
||||
@@ -72,9 +72,9 @@ $itemList->setItems(array($item1, $item2));
|
||||
// payment information such as tax, shipping
|
||||
// charges etc.
|
||||
$details = new Details();
|
||||
$details->setShipping('1.20')
|
||||
->setTax('1.30')
|
||||
->setSubtotal('17.50');
|
||||
$details->setShipping(1.2)
|
||||
->setTax(1.3)
|
||||
->setSubtotal(17.5);
|
||||
|
||||
// ### Amount
|
||||
// Lets you specify a payment amount.
|
||||
@@ -82,7 +82,7 @@ $details->setShipping('1.20')
|
||||
// such as shipping, tax.
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD")
|
||||
->setTotal("20.00")
|
||||
->setTotal(20)
|
||||
->setDetails($details);
|
||||
|
||||
// ### Transaction
|
||||
|
||||
@@ -29,12 +29,12 @@ $item1 = new Item();
|
||||
$item1->setName('Ground Coffee 40 oz')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(1)
|
||||
->setPrice('7.50');
|
||||
->setPrice(7.5);
|
||||
$item2 = new Item();
|
||||
$item2->setName('Granola bars')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(5)
|
||||
->setPrice('2.00');
|
||||
->setPrice(2);
|
||||
|
||||
$itemList = new ItemList();
|
||||
$itemList->setItems(array($item1, $item2));
|
||||
@@ -44,9 +44,9 @@ $itemList->setItems(array($item1, $item2));
|
||||
// payment information such as tax, shipping
|
||||
// charges etc.
|
||||
$details = new Details();
|
||||
$details->setShipping('1.20')
|
||||
->setTax('1.30')
|
||||
->setSubtotal('17.50');
|
||||
$details->setShipping(1.2)
|
||||
->setTax(1.3)
|
||||
->setSubtotal(17.50);
|
||||
|
||||
// ### Amount
|
||||
// Lets you specify a payment amount.
|
||||
@@ -54,7 +54,7 @@ $details->setShipping('1.20')
|
||||
// such as shipping, tax.
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD")
|
||||
->setTotal("20.00")
|
||||
->setTotal(20)
|
||||
->setDetails($details);
|
||||
|
||||
// ### Transaction
|
||||
|
||||
@@ -46,12 +46,12 @@ $item1 = new Item();
|
||||
$item1->setName('Ground Coffee 40 oz')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(1)
|
||||
->setPrice('7.50');
|
||||
->setPrice(7.5);
|
||||
$item2 = new Item();
|
||||
$item2->setName('Granola bars')
|
||||
->setCurrency('USD')
|
||||
->setQuantity(5)
|
||||
->setPrice('2.00');
|
||||
->setPrice(2);
|
||||
|
||||
$itemList = new ItemList();
|
||||
$itemList->setItems(array($item1, $item2));
|
||||
@@ -61,9 +61,9 @@ $itemList->setItems(array($item1, $item2));
|
||||
// payment information such as tax, shipping
|
||||
// charges etc.
|
||||
$details = new Details();
|
||||
$details->setShipping('1.20')
|
||||
->setTax('1.30')
|
||||
->setSubtotal('17.50');
|
||||
$details->setShipping(1.2)
|
||||
->setTax(1.3)
|
||||
->setSubtotal(17.5);
|
||||
|
||||
// ### Amount
|
||||
// Lets you specify a payment amount.
|
||||
@@ -71,7 +71,7 @@ $details->setShipping('1.20')
|
||||
// such as shipping, tax.
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD")
|
||||
->setTotal("20.00")
|
||||
->setTotal(20)
|
||||
->setDetails($details);
|
||||
|
||||
// ### Transaction
|
||||
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD");
|
||||
$amount->setTotal("1.00");
|
||||
$amount->setTotal(1);
|
||||
|
||||
// ### Reauthorize with amount being reauthorized
|
||||
$authorization->setAmount($amount);
|
||||
|
||||
@@ -20,7 +20,7 @@ use PayPal\Api\Sale;
|
||||
// field to mention fees refund details.
|
||||
$amt = new Amount();
|
||||
$amt->setCurrency('USD')
|
||||
->setTotal('0.01');
|
||||
->setTotal(0.01);
|
||||
|
||||
// ### Refund object
|
||||
$refund = new Refund();
|
||||
|
||||
Reference in New Issue
Block a user