public function testSerializeDeserialize() { $a1 = $this->address; $a2 = new Address(); $a2->fromJson($a1->toJson()); $this->assertEquals($a1, $a2); }
/** * @depends testSerializationDeserialization * @param Address $obj */ public function testGetters($obj) { $this->assertEquals($obj->getLine1(), "TestSample"); $this->assertEquals($obj->getLine2(), "TestSample"); $this->assertEquals($obj->getCity(), "TestSample"); $this->assertEquals($obj->getCountryCode(), "TestSample"); $this->assertEquals($obj->getPostalCode(), "TestSample"); $this->assertEquals($obj->getState(), "TestSample"); $this->assertEquals($obj->getPhone(), "TestSample"); $this->assertEquals($obj->getNormalizationStatus(), "TestSample"); $this->assertEquals($obj->getStatus(), "TestSample"); }
public function setPaypalAddress($line1, $line2, $city, $countryCode, $postalCode, $state) { $address = new Address(); $address->setLine1($line1); $address->setLine2($line2); $address->setCity($city); $address->setCountryCode($countryCode); $address->setPostalCode($postalCode); $address->setState($state); return $address; }
/** * Creates a new mock 'payment authorization' * * @param PayPal\Api\ApiContext apiContext * @return PayPal\Api\Authorization */ function createAuthorization($apiContext) { $addr = new Address(); $addr->setLine1("3909 Witmer Road")->setLine2("Niagara Falls")->setCity("Niagara Falls")->setState("NY")->setPostalCode("14305")->setCountryCode("US")->setPhone("716-298-1822"); $card = new CreditCard(); $card->setType("visa")->setNumber("4417119669820331")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper")->setBillingAddress($addr); $fi = new FundingInstrument(); $fi->setCreditCard($card); $payer = new Payer(); $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi)); $amount = new Amount(); $amount->setCurrency("USD")->setTotal("1.00"); $transaction = new Transaction(); $transaction->setAmount($amount)->setDescription("Payment description."); $payment = new Payment(); // Setting intent to authorize creates a payment // authorization. Setting it to sale creates actual payment $payment->setIntent("authorize")->setPayer($payer)->setTransactions(array($transaction)); $paymnt = $payment->create($apiContext); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; }
public static function authorize() { $addr = new Address(); $addr->setLine1("3909 Witmer Road"); $addr->setLine2("Niagara Falls"); $addr->setCity("Niagara Falls"); $addr->setState("NY"); $addr->setPostal_code("14305"); $addr->setCountry_code("US"); $addr->setPhone("716-298-1822"); $card = new CreditCard(); $card->setType("visa"); $card->setNumber("4417119669820331"); $card->setExpire_month("11"); $card->setExpire_year("2019"); $card->setCvv2("012"); $card->setFirst_name("Joe"); $card->setLast_name("Shopper"); $card->setBilling_address($addr); $fi = new FundingInstrument(); $fi->setCredit_card($card); $payer = new Payer(); $payer->setPayment_method("credit_card"); $payer->setFunding_instruments(array($fi)); $amount = new Amount(); $amount->setCurrency("USD"); $amount->setTotal("1.00"); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription("This is the payment description."); $payment = new Payment(); $payment->setIntent("authorize"); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); $paymnt = $payment->create(); $resArray = $paymnt->toArray(); return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id']; }
public function payDemo() { $this->authorize(); $addr = new Address(); $addr->setLine1('52 N Main ST'); $addr->setCity('Johnstown'); $addr->setCountryCode('US'); $addr->setPostalCode('43210'); $addr->setState('OH'); $card = new CreditCard(); $card->setNumber('4417119669820331'); $card->setType('visa'); $card->setExpireMonth('11'); $card->setExpireYear('2018'); $card->setCvv2('874'); $card->setFirstName('Joe'); $card->setLastName('Shopper'); $card->setBillingAddress($addr); $fi = new FundingInstrument(); $fi->setCreditCard($card); $payer = new Payer(); $payer->setPaymentMethod('credit_card'); $payer->setFundingInstruments(array($fi)); $amountDetails = new \PayPal\Api\Details(); $amountDetails->setSubtotal('7.41'); $amountDetails->setTax('0.03'); $amountDetails->setShipping('0.03'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('7.47'); $amount->setDetails($amountDetails); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment transaction description.'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); $payment->create($this->_apiContext); }
// # Authorize Payment // This sample code demonstrates how you can authorize a payment. // API used: /v1/payments/authorization // https://developer.paypal.com/webapps/developer/docs/integration/direct/capture-payment/#authorize-the-payment require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\CreditCard; use PayPal\Api\FundingInstrument; use PayPal\Api\Payer; use PayPal\Api\Amount; use PayPal\Api\Transaction; use PayPal\Api\Payment; // 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")->setLine2("Niagara Falls")->setCity("Niagara Falls")->setState("NY")->setPostalCode("14305")->setCountryCode("US")->setPhone("716-298-1822"); $card = new CreditCard(); $card->setType("visa")->setNumber("4417119669820331")->setExpireMonth("11")->setExpireYear("2019")->setCvv2("012")->setFirstName("Joe")->setLastName("Shopper")->setBillingAddress($addr); $fi = new FundingInstrument(); $fi->setCreditCard($card); $payer = new Payer(); $payer->setPaymentMethod("credit_card")->setFundingInstruments(array($fi)); $amount = new Amount(); $amount->setCurrency("USD")->setTotal(1); $transaction = new Transaction(); $transaction->setAmount($amount)->setDescription("Payment description."); $payment = new Payment(); // Setting intent to authorize creates a payment // authorization. Setting it to sale creates actual payment $payment->setIntent("authorize")->setPayer($payer)->setTransactions(array($transaction));
function complete_cart($order_exists = true) { global $insert_id; // check $check_query = xtc_db_query("SELECT * \n FROM " . TABLE_PAYPAL_PAYMENT . "\n WHERE payment_id = '" . xtc_db_input($_SESSION['paypal']['paymentId']) . "'"); if (xtc_db_num_rows($check_query) > 0) { $status_id = $this->order_status_tmp; if ($status_id < 0) { $check_query = xtc_db_query("SELECT orders_status\n FROM " . TABLE_ORDERS . " \n WHERE orders_id = '" . (int) $insert_id . "'"); $check = xtc_db_fetch_array($check_query); $status_id = $check['orders_status']; } $this->update_order('duplicate call, cancel', $status_id, $insert_id); return; } // auth $apiContext = $this->apiContext(); try { // Get the payment Object by passing paymentId $payment = Payment::get($_SESSION['paypal']['paymentId'], $apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $this->remove_order($insert_id); unset($_SESSION['paypal']); unset($_SESSION['tmp_oID']); xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'NONSSL')); } // set order $order = new order($insert_id); $patches_array = array(); $patchRequest = new PatchRequest(); $payment_address = new Address(); $payment_address->setLine1($this->encode_utf8($order->billing['street_address']))->setCity($this->encode_utf8($order->billing['city']))->setState($this->encode_utf8($order->billing['state'] != '' ? xtc_get_zone_code($order->billing['country_id'], $order->billing['zone_id'], $order->billing['state']) : ''))->setPostalCode($this->encode_utf8($order->billing['postcode']))->setCountryCode($this->encode_utf8(isset($order->billing['country_iso_2']) ? $order->billing['country_iso_2'] : $order->billing['country']['iso_code_2'])); if ($order->billing['suburb'] != '') { $payment_address->setLine2($this->encode_utf8($order->billing['suburb'])); } $patch_payment = new Patch(); $patch_payment->setOp('add')->setPath('/potential_payer_info/billing_address')->setValue($payment_address); $patches_array[] = $patch_payment; // set address $shipping_address = new ShippingAddress(); $shipping_address->setRecipientName($this->encode_utf8($order->delivery['firstname'] . ' ' . $order->delivery['lastname']))->setLine1($this->encode_utf8($order->delivery['street_address']))->setCity($this->encode_utf8($order->delivery['city']))->setCountryCode($this->encode_utf8(isset($order->delivery['country_iso_2']) ? $order->delivery['country_iso_2'] : $order->delivery['country']['iso_code_2']))->setPostalCode($this->encode_utf8($order->delivery['postcode']))->setState($this->encode_utf8($order->delivery['state'] != '' ? xtc_get_zone_code($order->delivery['country_id'], $order->delivery['zone_id'], $order->delivery['state']) : '')); if ($order->delivery['suburb'] != '') { $shipping_address->setLine2($this->encode_utf8($order->delivery['suburb'])); } $patch_shipping = new Patch(); $patch_shipping->setOp('add')->setPath('/transactions/0/item_list/shipping_address')->setValue($shipping_address); $patches_array[] = $patch_shipping; $patch_invoice = new Patch(); $patch_invoice->setOp('replace')->setPath('/transactions/0/invoice_number')->setValue($this->get_config('PAYPAL_CONFIG_INVOICE_PREFIX') . $insert_id); $patches_array[] = $patch_invoice; // set details $this->details = new Details(); // set amount $this->amount = new Amount(); // set totals $this->get_totals($order->totals); $this->amount->setCurrency($order->info['currency'])->setDetails($this->details); $patch_amount = new Patch(); $patch_amount->setOp('replace')->setPath('/transactions/0/amount')->setValue($this->amount); $patches_array[] = $patch_amount; // set ItemList if ($this->get_config('PAYPAL_ADD_CART_DETAILS') == '0' || $this->check_discount() === true) { $item = array(); $item[0] = new Item(); $item[0]->setName($this->encode_utf8(MODULE_PAYMENT_PAYPAL_TEXT_ORDER))->setCurrency($order->info['currency'])->setQuantity(1)->setPrice($this->details->getSubtotal()); } else { for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) { $item[$i] = new Item(); $item[$i]->setName($this->encode_utf8($order->products[$i]['name']))->setCurrency($order->info['currency'])->setQuantity($order->products[$i]['qty'])->setPrice($order->products[$i]['price'])->setSku($order->products[$i]['model'] != '' ? $order->products[$i]['model'] : $order->products[$i]['id']); } } $patch_items = new Patch(); $patch_items->setOp('replace')->setPath('/transactions/0/item_list/items')->setValue($item); $patches_array[] = $patch_items; $patchRequest->setPatches($patches_array); try { // update payment $payment->update($patchRequest, $apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); if ($order_exists === false) { unset($_SESSION['paypal']); xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'payment_error=' . $this->code, 'SSL')); } $this->remove_order($insert_id); unset($_SESSION['paypal']); unset($_SESSION['tmp_oID']); xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'NONSSL')); } $payment = Payment::get($_SESSION['paypal']['paymentId'], $apiContext); // PaymentExecution $execution = new PaymentExecution(); $execution->setPayerId($_SESSION['paypal']['PayerID']); try { // Execute the payment $payment->execute($execution, $apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $this->remove_order($insert_id); unset($_SESSION['paypal']); unset($_SESSION['tmp_oID']); xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'NONSSL')); } // capture if (($this->transaction_type == 'order' || $this->transaction_type == 'authorize') && $this->get_config('PAYPAL_CAPTURE_MANUELL') == '0') { $this->capture_payment($payment); } $sql_data_array = array('orders_id' => $insert_id, 'payment_id' => $_SESSION['paypal']['paymentId'], 'payer_id' => $_SESSION['paypal']['PayerID']); xtc_db_perform(TABLE_PAYPAL_PAYMENT, $sql_data_array); try { // Get the payment Object by passing paymentId $payment = Payment::get($_SESSION['paypal']['paymentId'], $apiContext); } catch (Exception $ex) { $this->LoggingManager->log(print_r($ex, true), 'DEBUG'); $this->remove_order($insert_id); unset($_SESSION['paypal']); unset($_SESSION['tmp_oID']); xtc_redirect(xtc_href_link(FILENAME_SHOPPING_CART, 'payment_error=' . $this->code, 'NONSSL')); } $status = $this->get_orders_status($payment); if ($status['status_id'] < 0) { $check_query = xtc_db_query("SELECT orders_status\n FROM " . TABLE_ORDERS . " \n WHERE orders_id = '" . (int) $insert_id . "'"); $check = xtc_db_fetch_array($check_query); $status['status_id'] = $check['orders_status']; } $this->update_order($status['comment'], $status['status_id'], $insert_id); }
/** * Creates an address object * * @param OrderInterface $order * * @return Address */ protected function createAddress(OrderInterface $order) : Address { $address = new Address(); $address->setLine1($order->getBillingAddress()->getLine1()); $address->setLine2($order->getBillingAddress()->getLine2()); $address->setCity($order->getBillingAddress()->getCity()); $address->setPostalCode($order->getBillingAddress()->getPostalCode()); $address->setCountryCode($order->getBillingAddress()->getCountry()); return $address; }
public function createBillingAgreement($planId, $shippingAddress, $billingAddress, $productName, $cartSummary, $cardDetails, $apiContext) { $billingPlanDefaultValues = $this->getBillingPlanDefaultValues(); $billingAgreement = new Agreement(); $billingAgreement->setName('Billing Agreement For ' . $productName); $billingAgreement->setDescription($cartSummary->paymentPlanTitle); $startDate = new Zend_Date(); $startDate->addDay($billingPlanDefaultValues->startDateInterval); $billingAgreement->setStartDate($startDate->get(Zend_Date::ISO_8601)); $payerInfo = new PayerInfo(); $payerInfo->setFirstName($billingAddress->firstname); $payerInfo->setLastName($billingAddress->lastname); $payerInfo->setEmail($billingAddress->emailAddress); /* Fields not supported yet */ //$payerInfo->setEmail($cart->address->billing['billing_email']); //$payerInfo->setPhone($cart->address->billing['billing_contactNo']); /* Get a MALFORMED_REQUEST error when using this field */ //$payerInfo->setCountryCode($cart->address->billing['billing_countryCode']); $cardName = $cardDetails->cardName; $cardNumber = $cardDetails->cardNumber; $cardType = strtolower($cardDetails->cardType); $cardExpiryMonth = $cardDetails->cardExpiryMonth; $cardExpiryYear = $cardDetails->cardExpiryYear; $cardSecurityCode = $cardDetails->cardSecurityCode; $nameParser = new Om_Model_Name(); $name = $nameParser->parse_name($cardName); $card = new CreditCard(); $card->setType($cardType); $card->setNumber($cardNumber); $card->setExpireMonth($cardExpiryMonth); $card->setExpireYear($cardExpiryYear); $card->setCvv2($cardSecurityCode); $card->setFirstName($name['fname']); $card->setLastName($name['lname']); $fundingInstrument = new FundingInstrument(); $fundingInstrument->setCreditCard($card); $payer = new Payer(); $payer->setPaymentMethod("credit_card"); $payer->setFundingInstruments(array($fundingInstrument)); $payer->setPayerInfo($payerInfo); $billingAgreement->setPayer($payer); $shippingAddressPayPal = new Address(); $shippingAddressPayPal->setLine1($shippingAddress->addressLine1); $shippingAddressPayPal->setLine2($shippingAddress->addressLine2 . ' ' . $shippingAddress->addressLine3); $shippingAddressPayPal->setCity($shippingAddress->city); $shippingAddressPayPal->setCountryCode($shippingAddress->getCountry()->code); $shippingAddressPayPal->setPostalCode($shippingAddress->postcode); $shippingAddressPayPal->setState($shippingAddress->county); $shippingAddressPayPal->setPhone($shippingAddress->contactNumber); $billingAgreement->setShippingAddress($shippingAddressPayPal); $plan = new Plan(); $plan->setId($planId); $billingAgreement->setPlan($plan); return $billingAgreement->create($apiContext); }
public function teszt($amount, $description) { $apiContext = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential('AfikH2WfU1x0YF1ThuSkBaMKqDh-rxE5NEBpLWOF3UVmii-P97WdgJCUhoH1ff5pMHToHnB-sXoejgGv', 'EM7ObD_onQ1EqaeiVBFvSId9AIQevTlsYcLPi-3SeVivyQ9A361Ov5jx4KlFkamOsh_c6I25VM1Ck4ZX')); //SAMPLE 1 // $card = new CreditCard(); // $card->setType("visa") // ->setNumber("4148529247832259") // ->setExpireMonth("11") // ->setExpireYear("2019") // ->setCvv2("012") // ->setFirstName("Joe") // ->setLastName("Shopper"); // // ### FundingInstrument // // 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 // // 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(); // $payer->setPaymentMethod("credit_card") // ->setFundingInstruments(array($fi)); // // ### Itemized information // // (Optional) Lets you specify item wise // // information // $item1 = new Item(); // $item1->setName('Ground Coffee 40 oz') // ->setDescription('Ground Coffee 40 oz') // ->setCurrency('USD') // ->setQuantity(1) // ->setTax(0.3) // ->setPrice(7.50); // $item2 = new Item(); // $item2->setName('Granola bars') // ->setDescription('Granola Bars with Peanuts') // ->setCurrency('USD') // ->setQuantity(5) // ->setTax(0.2) // ->setPrice(2); // $itemList = new ItemList(); // $itemList->setItems(array($item1, $item2)); // // ### Additional payment details // // Use this optional field to set additional // // payment information such as tax, shipping // // charges etc. // $details = new Details(); // $details->setShipping(1.2) // ->setTax(1.3) // ->setSubtotal(17.5); // // ### Amount // // Lets you specify a payment amount. // // You can also specify additional details // // such as shipping, tax. // $amount = new Amount(); // $amount->setCurrency("USD") // ->setTotal(20) // ->setDetails($details); // // ### Transaction // // A transaction defines the contract of a // // payment - what is the payment for and who // // is fulfilling it. // $transaction = new Transaction(); // $transaction->setAmount($amount) // ->setItemList($itemList) // ->setDescription("Payment description") // ->setInvoiceNumber(uniqid()); // // ### Payment // // A Payment Resource; create one using // // the above types and intent set to sale 'sale' // $payment = new Payment(); // $payment->setIntent("sale") // ->setPayer($payer) // ->setTransactions(array($transaction)); // // For Sample Purposes Only. // $request = clone $payment; // // ### Create Payment // // Create a payment by calling the payment->create() method // // with a valid ApiContext (See bootstrap.php for more on `ApiContext`) // // The return object contains the state. // try { // $payment->create($apiContext); // } catch (Exception $ex) { // // ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex); // exit(1); // } //ResultPrinter::printResult('Create Payment Using Credit Card', 'Payment', $payment->getId(), $request, $payment); //return $payment; //END SAMPLE 1 //SAMPLE 2 // $creditCard = new \PayPal\Api\CreditCard(); // $creditCard->setType("visa") // ->setNumber("4417119669820331") // ->setExpireMonth("11") // ->setExpireYear("2019") // ->setCvv2("012") // ->setFirstName("Joe") // ->setLastName("Shopper"); // try { // $creditCard->create($apiContext); // echo '<pre>'; // print_r($creditCard); // } // catch (\PayPal\Exception\PayPalConnectionException $ex) { // echo $ex; // } //END SAMPLE 2 //SAMPLE 3 $payer = new Payer(); $payer->setPaymentMethod("paypal"); // ### Itemized information // (Optional) Lets you specify item wise // information $item1 = new Item(); $item1->setName('Ground Coffee 40 oz')->setCurrency('USD')->setQuantity(1)->setPrice(7.5); $item2 = new Item(); $item2->setName('Granola bars')->setCurrency('USD')->setQuantity(5)->setPrice(2); $itemList = new ItemList(); $itemList->setItems(array($item1, $item2)); // ### Additional payment details // Use this optional field to set additional // payment information such as tax, shipping // charges etc. /* $details = new Details(); $details->setShipping(1.2) ->setTax(1.3) ->setSubtotal(17.50); */ // ### Amount // Lets you specify a payment amount. // You can also specify additional details // such as shipping, tax. /* $amount = new Amount(); $amount->setCurrency("USD") ->setTotal(20) ->setDetails($details); */ // ### Transaction // A transaction defines the contract of a // payment - what is the payment for and who // is fulfilling it. $transaction = new Transaction(); $transaction->setAmount($amount)->setItemList($itemList)->setDescription("Payment description"); // ->setInvoiceNumber('134'); //>setInvoiceNumber(uniqid()); // ### Redirect urls // Set the urls that the buyer must be redirected to after // payment approval/ cancellation. //$baseUrl = getBaseUrl(); $redirectUrls = new RedirectUrls(); $redirectUrls->setReturnUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/ordered")->setCancelUrl("http://localhost/yii-application/frontend/web/index.php?r=/cart/default/index"); // ### Payment // A Payment Resource; create one using // the above types and intent set to 'sale' /* $payment = new Payment(); $payment->setIntent("sale") ->setPayer($payer) ->setRedirectUrls($redirectUrls) ->setTransactions(array($transaction)); */ $addr = new Address(); $addr->setLine1('52 N Main ST'); $addr->setCity('Johnstown'); $addr->setCountryCode('US'); $addr->setPostalCode('43210'); $addr->setState('OH'); $card = new CreditCard(); $card->setNumber('5110929378020149'); $card->setType('MASTERCARD'); $card->setExpireMonth('08'); $card->setExpireYear('2020'); $card->setCvv2('874'); $card->setFirstName('Nishanth'); $card->setLastName('Pininti'); $card->setBillingAddress($addr); $fi = new FundingInstrument(); $fi->setCreditCard($card); $payer = new Payer(); $payer->setPaymentMethod('credit_card'); $payer->setFundingInstruments(array($fi)); $amountDetails = new \PayPal\Api\Details(); $amountDetails->setSubtotal('7.41'); $amountDetails->setTax('0.03'); $amountDetails->setShipping('0.03'); $amount = new Amount(); $amount->setCurrency('USD'); $amount->setTotal('7.47'); $amount->setDetails($amountDetails); $transaction = new Transaction(); $transaction->setAmount($amount); $transaction->setDescription('This is the payment transaction description.'); $payment = new Payment(); $payment->setIntent('sale'); $payment->setPayer($payer); $payment->setTransactions(array($transaction)); // For Sample Purposes Only. $request = clone $payment; // ### Create Payment // Create a payment by calling the 'create' method // passing it a valid apiContext. // (See bootstrap.php for more on `ApiContext`) // The return object contains the state and the // url to which the buyer must be redirected to // for payment approval try { $payment->create($apiContext); } catch (Exception $ex) { ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex); exit(1); } // ### Get redirect url // The API response provides the url that you must redirect // the buyer to. Retrieve the url from the $payment->getApprovalLink() // method //$approvalUrl = $payment->getRedirectUrls(); // ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment); var_dump($payment); return $payment; //END SAMPLE 3 }
// # CreatePaymentSample // This sample code demonstrate how you can process // a payment with a credit card. // API used: /v1/payments/payment require __DIR__ . '/../bootstrap.php'; use PayPal\Api\Address; use PayPal\Api\Amount; use PayPal\Api\CreditCard; use PayPal\Api\Payer; use PayPal\Api\Payment; use PayPal\Api\FundingInstrument; use PayPal\Api\Transaction; // ### Address // Base Address object used as shipping or billing // address in a payment. [Optional] $addr = new Address(); $addr->setLine1("3909 Witmer Road"); $addr->setLine2("Niagara Falls"); $addr->setCity("Niagara Falls"); $addr->setState("NY"); $addr->setPostal_code("14305"); $addr->setCountry_code("US"); $addr->setPhone("716-298-1822"); // ### CreditCard // A resource representing a credit card that can be // used to fund a payment. $card = new CreditCard(); $card->setType("visa"); $card->setNumber("4417119669820331"); $card->setExpire_month("11"); $card->setExpire_year("2019");