Google checkout ,Database updation failed - php

I was download and edit the code for google checkout from google help.Here i specify murchent calculation url in my site.But that function donot work in my site.Here is my code
function UseCase3() {
//Create a new shopping cart object
$merchant_id = "xxxxxxxxxxxxx"; // Your Merchant ID
$merchant_key = "xxxxxxxxxxxxx";
$server_type = "sandbox";
$currency = "USD";
$cart = new GoogleCart($merchant_id, $merchant_key, $server_type, $currency);
// Add items to the cart
$item = new GoogleItem("MegaSound 2GB MP3 Player",
"Portable MP3 player - stores 500 songs", 1, 175.49);
$item->SetMerchantPrivateItemData("<color>blue</color><weight>3.2</weight>");
$cart->AddItem($item);
// Add merchant calculations options
$cart->SetMerchantCalculations(
"https://mysite.com/google2/demo/responsehandlerdemo.php",
"false", // merchant-calculated tax
"true", // accept-merchant-coupons
"true"); // accept-merchant-gift-certificates
// Add merchant-calculated-shipping option
$ship = new GoogleMerchantCalculatedShipping("2nd Day Air", // Shippping method
10.00); // Default, fallback price
$restriction = new GoogleShippingFilters();
$restriction->AddAllowedPostalArea("GB");
$restriction->AddAllowedPostalArea("US");
$restriction->SetAllowUsPoBox(false);
$ship->AddShippingRestrictions($restriction);
$address_filter = new GoogleShippingFilters();
$address_filter->AddAllowedPostalArea("GB");
$address_filter->AddAllowedPostalArea("US");
$address_filter->SetAllowUsPoBox(false);
$ship->AddAddressFilters($address_filter);
$cart->AddShipping($ship);
// Set default tax options
$tax_rule = new GoogleDefaultTaxRule(0.15);
$tax_rule->SetWorldArea(true);
$cart->AddDefaultTaxRules($tax_rule);
$cart->AddRoundingPolicy("UP", "TOTAL");
// Specify <edit-cart-url>
$cart->SetEditCartUrl("https://mysite.com/google/demo/cartdemo.php");
// Specify "Return to xyz" link
$cart->SetContinueShoppingUrl("https://mysite.com");
// Display XML data
// echo "<pre>";
// echo htmlentities($cart->GetXML());
// echo "</pre>";
// Display a disabled, small button
echo $cart->CheckoutButtonCode("SMALL");
}

Clarifications:
Merchant Calculations URL - as the name implies is the URL that Google will use to send a callback request for Shipping and Tax, promotions calculations. That is its purpose as documented in Merchant Calculations API. It is part of the Checkout Phase (sending information to Google for checkout).
API Callback URL - which is set in your account (Integration Settings) and not sent in any request (unlike merchant calculations url) and is the URL Google will send Notifications to as documented in Notification API. This is the API you need to implement in order to obtain data from Google (getting information from Google - e.g. after checkout)
So these urls/APIs serve different purposes.
Based on your comment:
I need to execute a php file after user pay through Google checkout
You need to implement the Notification API (the merchant calcuations url/api is not what you need).

Related

PHP: Moneris Vault with Recurring Bills

I want to add customer profiles to the vault, without charging any money up front, then start billing on a monthly basis starting in 1 month (it's a free 1 month trial). I have this working with the sandbox, but when I change to live credentials and URL, it only adds a profile to the vault and fails to set up recurring bills... there is no response in $mpgResponse->getRecurSuccess();
I have a basic form with email and client/customer name that is submitted to https://www3.moneris.com/HPPDP/index.php. This sets up a temporary profile in the vault (becomes permanent once credit card info has been added) and responds with the form to enter payment info (I simply have the form target set to an iframe so this response is loaded automatically). When the payment info is submitted, Moneris POSTs the result back to my PHP script, where I get the "data_key", which is what I am using instead of "credential on file". Is that a problem?
//GET CUSTOMER ID AND BILLING KEY FROM MONERIS
$client_name = $_POST["cust_id"];
$billing_key = $_POST["data_key"];
//PRIMARY TRANSACTION - No money up front (free 30 day trial)
$txnArray=array(
'type'=>'res_purchase_cc',
'data_key'=>$billing_key,
'order_id'=>$orderID,
'cust_id'=>$client_name,
'amount'=>'0.00',
'crypt_type'=>'7'
);
$mpgTxn = new mpgTransaction($txnArray);
//START BILLING IN 30 DAYS (will upgrade or use EOM to prevent issues like Feb 30th not existing)
$startDate = date('Y/m/d', strtotime('+30 day', strtotime(date('Y/m/d'))));
$recurArray = array(
'recur_unit'=>'day',
'start_now'=>'false',
'start_date'=>$startDate,
'num_recurs'=>'98',
'period' => '1',
'recur_amount'=> '99.00'
);
$mpgRecur = new mpgRecur($recurArray);
//ADD RECURRING VARS TO MAIN TRANSACTION OBJECT
$mpgTxn->setRecur($mpgRecur);
//SEND IT TO MONERIS
$mpgRequest = new mpgRequest($mpgTxn);
$mpgHttpPost = new mpgHttpsPost($store_id, $api_token, $mpgRequest);
//GET RESPONSE FROM MONERIS
$mpgResponse = $mpgHttpPost->getMpgResponse();
$respCode = $mpgResponse->getResponseCode();
$message = $mpgResponse->getMessage();
//$mpgResponse->getIssuerId();
//GET RECUR RESULT: THIS IS EMPTY IN LIVE ENVIRONMENT, BUT "true" IN SANDBOX
$recurResult = $mpgResponse->getRecurSuccess();

Magento Credit card number mismatch with credit card type exception

I am using stripe credit card payment method for website on my magento store and developing a mobile application. I am developing the api's using native magento api. Problem occurred on create order api, everything till adding payment for stripe credit card works fine but when I hit the create order api it throws the exception.
"Credit card number mismatch with credit card type exception"
Below is api code, Please share your knowledge for this issue. Thanks in advance.
$proxy = new SoapClient($this->_client); //soap handle
$sessionId = $proxy->login($this->_apiuser, $this->_apikey);
$resultCustomerAddresses = $proxy->call($sessionId, "cart_customer.addresses", array($shoppingCartId, $arrAddresses));
if ($resultCustomerAddresses != TRUE)
{
return json_encode(array('status' => 0, 'result' => array(),'message' => 'Error in saving address'));
}
$resultShippingMethods = $proxy->call($sessionId, "cart_shipping.list", array($shoppingCartId));
$randShippingMethodIndex = rand(0, count($resultShippingMethods)-1 );
$shippingMethod = $resultShippingMethods[$randShippingMethodIndex]["code"];
$resultShippingMethod = $proxy->call($sessionId, "cart_shipping.method", array($shoppingCartId, $shipping_method));
//$resultTotalOrder = $proxy->call($sessionId,'cart.totals',array($shoppingCartId));
$paymentMethod = array(
"method" => $payment_method
);
$resultPaymentMethod = $proxy->call($sessionId, "cart_payment.method", array($shoppingCartId, $payment_method));
$licenseForOrderCreation = null;
$resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation));
I had the same problem and successfully solved it, see this answer: https://stackoverflow.com/a/41948259/1052675
Basically, you supply the card information before you save the quote. It will validate the card against regex patterns and configured purchase limits and make sure you can use the payment method.
Then it will forget the payment information.
So before you tell it to submit the order, you need to supply the card info again.
My solution was a custom endpoint for simplicity on the front end app and it enabled me to keep the card info in memory to re-save between saving the quote and submitting the order.

Get invoice after payment paypal for merchant api php

My problem is that I want to get a bill after paying for storage ( in .pdf) on the server. I've been looking at the API and create an invoice but know not how to get the bill automatically.
<?php
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Address;
use PayPal\Api\BillingInfo;
use PayPal\Api\Cost;
use PayPal\Api\Currency;
use PayPal\Api\Invoice;
use PayPal\Api\InvoiceAddress;
use PayPal\Api\InvoiceItem;
use PayPal\Api\MerchantInfo;
use PayPal\Api\PaymentTerm;
use PayPal\Api\Phone;
use PayPal\Api\ShippingInfo;
$invoice = new Invoice();
Invoice Info
$invoice
->setMerchantInfo(new MerchantInfo())
->setBillingInfo(array(new BillingInfo()))
->setNote("Medical Invoice 16 Jul, 2013 PST")
->setPaymentTerm(new PaymentTerm())
->setShippingInfo(new ShippingInfo());
Merchant Info
A resource representing merchant information that can be used to identify merchant
$invoice->getMerchantInfo()
->setEmail("jaypatel512-facilitator#hotmail.com")
->setFirstName("Dennis")
->setLastName("Doctor")
->setbusinessName("Medical Professionals, LLC")
->setPhone(new Phone())
->setAddress(new Address());
$invoice->getMerchantInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5032141716");
Address Information
The address used for creating the invoice
$invoice->getMerchantInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
Billing Information
Set the email address for each billing
$billing = $invoice->getBillingInfo();
$billing[0]
->setEmail("example#example.com");
$billing[0]->setBusinessName("Jay Inc")
->setAdditionalInfo("This is the billing Info")
->setAddress(new InvoiceAddress());
$billing[0]->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
Items List
You could provide the list of all items for detailed breakdown of invoice
$items = array();
$items[0] = new InvoiceItem();
$items[0]
->setName("Sutures")
->setQuantity(100)
->setUnitPrice(new Currency());
$items[0]->getUnitPrice()
->setCurrency("USD")
->setValue(5);
Tax Item
You could provide Tax information to each item.
$tax = new \PayPal\Api\Tax();
$tax->setPercent(1)->setName("Local Tax on Sutures");
$items[0]->setTax($tax);
Second Item
$items[1] = new InvoiceItem();
Lets add some discount to this item.
$item1discount = new Cost();
$item1discount->setPercent("3");
$items[1]
->setName("Injection")
->setQuantity(5)
->setDiscount($item1discount)
->setUnitPrice(new Currency());
$items[1]->getUnitPrice()
->setCurrency("USD")
->setValue(5);
Tax Item
You could provide Tax information to each item.
$tax2 = new \PayPal\Api\Tax();
$tax2->setPercent(3)->setName("Local Tax on Injection");
$items[1]->setTax($tax2);
$invoice->setItems($items);
Final Discount
You can add final discount to the invoice as shown below. You could either use "percent" or "value" when providing the discount
$cost = new Cost();
$cost->setPercent("2");
$invoice->setDiscount($cost);
$invoice->getPaymentTerm()
->setTermType("NET_45");
Shipping Information
$invoice->getShippingInfo()
->setFirstName("Sally")
->setLastName("Patient")
->setBusinessName("Not applicable")
->setPhone(new Phone())
->setAddress(new InvoiceAddress());
$invoice->getShippingInfo()->getPhone()
->setCountryCode("001")
->setNationalNumber("5039871234");
$invoice->getShippingInfo()->getAddress()
->setLine1("1234 Main St.")
->setCity("Portland")
->setState("OR")
->setPostalCode("97217")
->setCountryCode("US");
Logo
You can set the logo in the invoice by providing the external URL pointing to a logo
$invoice->setLogoUrl('https://www.paypalobjects.com/webstatic/i/logo/rebrand/ppcom.svg');
For Sample Purposes Only.
$request = clone $invoice;
try {
Create Invoice
Create an invoice by calling the invoice->create() method with a valid ApiContext (See bootstrap.php for more on ApiContext)
$invoice->create($apiContext);
} catch (Exception $ex) {
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
exit(1);
}
NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Create Invoice", "Invoice", $invoice->getId(), $request, $invoice);
return $invoice;
if they could orient themselves, or some link which explains how to find it I would be grateful

PayPal Adaptive Payments - Product Name

I am using paypal adaptive payments for my website. I have many sellers and different products. when I am as a user try to buy any product from my website then I can't see product name in Paypal form summary instead there is the name and surname of the seller.
Let me know please which parameter is being used to Pass product name ..
Here is the screenshot
With Adaptive Payments you can't send itemized details in the Pay request itself. Instead, you have to call Pay like usual, but then follow that up with a call to SetPaymentOptions. With that you'll pass in the PayKey you get back from the Pay request, and then you can setup all the additional details like itemized info that SetPaymentsOptions provides.
Then you would redirect to PayPal after that, and it should show you what you're after.
With Adaptive Payments, the item details you set with SetPaymentOptions are only displayed to the customer via Embedded flow.
The Embedded flow uses either a lightbox or a minibrowser for the checkout pages.
Here’s a technical instruction on how to implement the embedded flow in your front-end page, https://developer.paypal.com/docs/classic/adaptive-payments/ht_ap-embeddedPayment-curl-etc/
I am having the same issue. It looks like it works only in an Embedded Payment Flow.
Embedded Payment Flow Using Adaptive Payments
$receiverOptions = new PayPal\Types\AP\ReceiverOptions();
$setPaymentOptionsRequest->receiverOptions[] = $receiverOptions;
$receiverOptions->description = 'Description';
$invoiceItems = array();
$item = new PayPal\Types\AP\InvoiceItem();
$item->name = 'Item Name';
$item->price = 10;
$item->itemPrice = 10;
$item->itemCount = 1;
$invoiceItems[] = $item;
$receiverOptions->invoiceData = new PayPal\Types\AP\InvoiceData();
$receiverOptions->invoiceData->item = $invoiceItems;
$receiverId = new PayPal\Types\AP\ReceiverIdentifier();
$receiverId->email = 'email#domain.com';//Change it
$receiverOptions->receiver = $receiverId;
$setPaymentOptionsRequest->payKey = $_POST['payKey'];
$servicePaymentOptions = new PayPal\Service\AdaptivePaymentsService($config);
try {
/* wrap API method calls on the service object with a try catch */
$responsePaymentOptions = $servicePaymentOptions->SetPaymentOptions($setPaymentOptionsRequest);
print_r($responsePaymentOptions); die;
} catch(Exception $ex) {
//error
}
if (isset($responsePaymentOptions) && $responsePaymentOptions->responseEnvelope->ack == "Success")
{
//Success
}

How to generate order id by signing in as guest in android app-shopping cart

I'm developing an shopping cart app, as a registered customer I can generate the order id, but I don't know how to use the guest customer.I use the following code to set the guest customer.
SoapObject res = new SoapObject(SOAP_NAMESPACE, SHOPPING_CART_CUSTOMER_SET);
res.addProperty("mode", "guest");
res.addProperty("customer_id",62);
res.addProperty("email", "muthu1984mca#gmail.com");
res.addProperty("firstname", "Muthamizhan");
res.addProperty("lastname", "Chelladurai");
res.addProperty("confirmation", true);
res.addProperty("website_id",1);
res.addProperty("store_id",1);
res.addProperty("group_id",1);
request = new SoapObject(SOAP_NAMESPACE, SHOPPING_CART_CUSTOMER_SET);
request.addProperty("sessionId", sessionId);
request.addProperty("quoteId", shoppingCartID);
request.addProperty("customer",res);
// request.addProperty("storeId","1");
// request.addProperty("paymentData",values);
envelope.setOutputSoapObject(request);
transport.debug = true;
transport.call(SOAP_NAMESPACE + SOAP_PREFIX + SHOPPING_CART_CUSTOMER_SET, envelope);
// getting the response which is the customerId
Log.d("Setting Customer", "request:" + transport.requestDump);
Log.d("Setting Customer", "response:" + transport.responseDump);
For guest customers no need of this method "shoppingCartCustomerSet". Skip this step and directly you can add billing and shipping addresses, shipping method, payment method and then generate order. It will automatically set the customer as guest.

Categories