I'm using Express Checkout PHP-SDK (release 96) in my web app.
I'm trying to prefill my customer's billing details on Paypal.
$address = new AddressType();
$address->CityName = strtoupper_tr( $order['invoice']['address']['city'] );
$address->Name = $order['invoice']['title'];
$address->Street1 = $order['invoice']['address']['address'];
$address->Street2 = $order['invoice']['address']['address-2'];
$address->StateOrProvince = $order['invoice']['address']['province'];
$address->PostalCode = $order['invoice']['address']['postal-code'];
$address->Country = 'TR';
$address->Phone = '5004244244';
...
$set_ec_req_details = new SetExpressCheckoutRequestDetailsType();
$set_ec_req_details->BillingAddress = $address;
This code populate form except Phone Number.
I find that if I change country code to 'US', it works too.
I could not find any information on x.com's forums or documentations. I'll be grateful if someone tell me there is a way to do this or not.
Not familiar with this cart, but Paypals phone codes are very much US centric but I've had good luck using night_phone_b to place the phone number into.
Details are https://www.paypal.com/cgi-bin/webscr?cmd=_pdn_xclick_prepopulate_outside
Related
I'm using Checkout.com and its PHP SDK to set up payment on a website.
I try to set the Phone and The Shipping Address, but i'm doing wrong i suppose.
The API is not so amazing about this as well (or i don't know how to use it to find what i want)
I did something like this for the phone but doesn't work
$customerPhone = new \Checkout\Models\Phone();
$customerPhone->number = $phone;
$payment->shipping = new \stdClass();
$payment->shipping->phone = $customerPhone;
And i have no idea for the address.
If someone knows ?
Thanks
The correct way of sending shipping data on payments is:
$shipping = new \Checkout\Models\Payments\Shipping($address, $phone);
Where $address is an object of Checkout\Models\Address and $phone is an object of Checkout\Models\Phone.
How can I add default credit in WHMCS?
I mean when a user signup with WHMCS, they will receive some predefined credit balance in their account (credits can be used to purchase products)
I did search but didn't get any result.
You could use WHMCS hook system together with the API.
I haven't tested this code, but it should work more or less out of the box.
Create a file in includes/hooks/
add_hook('ClientAreaRegister', 1, function($vars) {
$command = "addcredit";
$adminuser = "admin";
$values["clientid"] = $vars['userid];
$values["description"] = "Adding credits via ClientAreaRegister hook";
$values["amount"] = "40.00";
$results = localAPI($command,$values,$adminuser);
});
Make sure you have a user "admin" or create a new user and change above code to match.
References:
https://developers.whmcs.com/hooks-reference/client-area-interface/#clientarearegister
http://docs.whmcs.com/API:Add_Credit
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.
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
}
This is the essential bit of PHP:
// Add subscription
$subscription = new Recurly_Subscription();
$subscription->plan_code = $planCode;
$subscription->currency = 'USD';
$subscription->quantity = 1;
if ($couponCode != "") { $subscription->coupon_code = $couponCode; }
$subscription->account = new Recurly_Account();
$subscription->account->account_code = $customerID;
$subscription->billing_info = new Recurly_BillingInfo();
$subscription->account->billing_info->token_id = $token;
$subscription->create();
When this code runs, $token has the tokenID created by an earlier call to recurly.token (...) with the billing info.
The account already exists on Recurly -- the account ID, first and last names, but no billing info. This is because we allow people to signup for a complimentary service before subscribing. So I want to create the subscription on the extant account. Initially, following the code examples, the create() call was subscription->account->create(). But that failed because the account existed already.
This sounds like an issue with the old PHP library, which did not support tokenization of billing information. An upgrade to the PHP client library should fix this issue.