コード例 #1
0
     $_SESSION['shipping_state'] = isset($_SESSION['billing_state']) ? $_SESSION['billing_state'] : '';
     $_SESSION['shipping_postal_code'] = isset($_SESSION['billing_postal_code']) ? $_SESSION['billing_postal_code'] : '';
     $_SESSION['shipping_country_code'] = isset($_SESSION['billing_country_code']) ? $_SESSION['billing_country_code'] : '';
 }
 $_SESSION['amount'] = isset($_POST['GrandTotal']) ? str_replace(",", "", $_POST['GrandTotal']) : '0.00';
 $_SESSION['subtotal'] = isset($_POST['NetAmount']) ? str_replace(",", "", $_POST['NetAmount']) : '0.00';
 $_SESSION['shipping_amount'] = isset($_POST['ShippingAmount']) && $_POST['ShippingAmount'] != '' ? str_replace(",", "", $_POST['ShippingAmount']) : '0.00';
 $_SESSION['handling_amount'] = isset($_POST['HandlingAmount']) && $_POST['HandlingAmount'] != '' ? str_replace(",", "", $_POST['HandlingAmount']) : '0.00';
 $_SESSION['tax_amount'] = isset($_POST['TaxAmount']) && $_POST['TaxAmount'] != '' ? str_replace(",", "", $_POST['TaxAmount']) : '0.00';
 $_SESSION['billingInfo'] = isset($_POST['billingInfo']) ? $_POST['billingInfo'] : array();
 $_SESSION['shippingInfo'] = isset($_POST['shippingInfo']) ? $_POST['shippingInfo'] : array();
 ##########[ Create Payment ]############
 // Create new PayPal Api Context
 $paypal_rest = new \PayPal\Rest\ApiContext(new \PayPal\Auth\OAuthTokenCredential($config['RESTAPIClient_Id'], $config['RESTAPIClient_Secret']));
 // Add to header
 $paypal_rest->addRequestHeader('PayPal-Partner-Attribution-Id', 'AngellEYE_SP_POS_VT');
 $addr = new \PayPal\Api\Address();
 $addr->setLine1($_SESSION['billing_street1']);
 $addr->setLine2($_SESSION['billing_street2']);
 $addr->setCity($_SESSION['billing_city']);
 $addr->setCountryCode($_SESSION['billing_country_code']);
 $addr->setPostalCode($_SESSION['billing_postal_code']);
 $addr->setState($_SESSION['billing_state']);
 $card = new \PayPal\Api\CreditCard();
 $card->setNumber($_SESSION['cc_number']);
 $card->setType(strtolower($_SESSION['cc_type']));
 $card->setExpireMonth($_SESSION['cc_exp_month']);
 $card->setExpireYear($_SESSION['cc_exp_year']);
 $card->setCvv2($_SESSION['cvv2']);
 $card->setFirstName($_SESSION['billing_first_name']);
 $card->setLastName($_SESSION['billing_last_name']);