I'm using the Shippo API to try and set my rate/parcel to USPS priority. Per the docs I feel like I need to add/edit the $rate array, but I can't seem to figure it out.
// Select the rate you want to purchase.
// We simply select the first rate in this example.
// $rate = $shipment["rates_list"][0];
$rate = array(
'object_state' => 'VALID',
'provider' => 'USPS',
'servicelevel_name' => 'Priority Mail',
'servicelevel_token' => 'usps_priority'
);
// Purchase the desired rate
$transaction = Shippo_Transaction::create(array(
'rate'=> $rate["object_id"],
//'rate' => $rate["usps_priority"],
'async'=> false
));
Looks like our InstaLabel feature is perfect for you https://goshippo.com/shipping-api/instalabel
There is a complete PHP example on that link but here's the bit of code you specified:
$transaction = Shippo_Transaction::create( array(
'shipment' => $shipment,
'carrier_account' => 'b741b99f95e841639b54272834bc478c',
'servicelevel_token' => 'usps_priority',
);
);
Is there a way to show shipping cost once user is redirected to paypal?
I tried with setPaymentOption but no help.
Here is my code-
This function is generating the payKey
function process_payment($JobId,$company_email,$file_id,$printer_id,$cost){
require('/includes/assets/paypal_config/config.php');
require('admin/config/rs_server.php');
// $secondryReceiverQuery = "UPDATE 3d_job_info set pay_key = '".$PayPalResult['PayKey']."' WHERE job_id ='$JobId'";
// $jobInsertQrrRes = mysqli_query($DB_CONN,$jobInsertQrr);
// $cost =$cost+10;
$primary_amt = ((12/100)*$cost) ;
$secondary_amt = $cost - $primary_amt;
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject,
'PrintHeaders' => $print_headers,
'LogResults' => $log_results,
'LogPath' => $log_path,
);
$PayPal = new Adaptive($PayPalConfig);
// Prepare request arrays
$PayRequestFields = array(
'ActionType' => 'PAY_PRIMARY', // Required. Whether the request pays the receiver or whether the request is set up to create a payment request, but not fulfill the payment until the ExecutePayment is called. Values are: PAY, CREATE, PAY_PRIMARY
'CancelURL' => $domain."index.php?t=cancel_payment&jobid=$JobId",// Required. The URL to which the sender's browser is redirected if the sender cancels the approval for the payment after logging in to paypal.com. 1024 char max.
'CurrencyCode' => 'USD', // Required. 3 character currency code.
'FeesPayer' => 'PRIMARYRECEIVER',// The payer of the fees.lol Values are: SENDER, PRIMARYRECEIVER, EACHRECEIVER, SECONDARYONLY
'IPNNotificationURL' => '', // The URL to which you want all IPN messages for this payment to be sent. 1024 char max.
'Memo' => 'This transection is from localhost', // A note associated with the payment (text, not HTML). 1000 char max
'Pin' => '', // The sener's personal id number, which was specified when the sender signed up for the preapproval
'PreapprovalKey' => '',// The key associated with a preapproval for this payment. The preapproval is required if this is a preapproved payment.
'ReturnURL' => $domain."index.php?t=payment_success&jobid=$JobId", // Required. The URL to which the sener"s browser is redirected after approvaing a payment on paypal.com. 1024 char max.
'ReverseAllParallelPaymentsOnError' => '',// Whether to reverse paralel payments if an error occurs with a payment. Values are: TRUE, FALSE
'SenderEmail' => '',// Sender's email address. 127 char max.
'TrackingID' => '',// Unique ID that you specify to track the payment. 127 char max.
);
$ClientDetailsFields = array(
'CustomerID' => '45', // Your ID for the sender 127 char max.
'CustomerType' => 'type', // Your ID of the type of customer. 127 char max.
'GeoLocation' => '',// Sender's geographic location
'Model' => 'zxc', // A sub-identification of the application. 127 char max.
'PartnerName' => 'zxc' // Your organization's name or ID
);
$FundingTypes = array('ECHECK', 'BALANCE', 'CREDITCARD');// Funding constrainigs require advanced permissions levels.
$Receivers = array();
$Receiver = array(
'Amount' =>$cost,// Required. Amount to be paid to the receiver.
'Email' => 'payment#creiterate.com', // Receiver's email address. 127 char max.
'InvoiceID' => '', // The invoice number for the payment. 127 char max.
'PaymentType' => 'GOODS', // Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
'PaymentSubType' => '', // The transaction subtype for the payment.
'AccountID' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
'Primary' => 'true' // Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
);
array_push($Receivers,$Receiver);
$Receiver = array(
'Amount' => $secondary_amt,// Required. Amount to be paid to the receiver.
'Email' => $company_email, // Receiver's email address. 127 char max.
'InvoiceID' => '',// The invoice number for the payment. 127 char max.
'PaymentType' => '',// Transaction type. Values are: GOODS, SERVICE, PERSONAL, CASHADVANCE, DIGITALGOODS
'PaymentSubType' => '',// The transaction subtype for the payment.
'AccountID' => '',
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => ''), // Receiver's phone number. Numbers only.
'Primary' => 'false'// Whether this receiver is the primary receiver. Values are boolean: TRUE, FALSE
);
array_push($Receivers,$Receiver);
$SenderIdentifierFields = array(
'UseCredentials' => TRUE// If TRUE, use credentials to identify the sender. Default is false.
);
$AccountIdentifierFields = array(
'Email' => $_SESSION['loggin_info']['email_address'],// Sender's email address. 127 char max.
'Phone' => array('CountryCode' => '', 'PhoneNumber' => '', 'Extension' => '')// Sender's phone number. Numbers only.
);
$PayPalRequestData = array(
'PayRequestFields' => $PayRequestFields,
'ClientDetailsFields' => $ClientDetailsFields,
// 'CreateInvoiceFields' => $CreateInvoiceFields,
//'FundingTypes' => $FundingTypes,
'Receivers' => $Receivers,
'SenderIdentifierFields' => $SenderIdentifierFields,
'AccountIdentifierFields' => $AccountIdentifierFields
);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->Pay($PayPalRequestData);
//Before redirecting setting the pay option here
setPaymentOption($PayPalResult['PayKey'],$PayPal,$cost);
header("Location: ". $PayPalResult['RedirectURL']);
}
This is my set payment option function.
function setPaymentOption($PayKey,$PayPal,$cost){
require('/../assets/paypal_config/config.php');
require('/admin/config/rs_server.php');
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject,
'PrintHeaders' => $print_headers,
'LogResults' => $log_results,
'LogPath' => $log_path,
);
// $PayPal = new Adaptive($PayPalConfig);
// Prepare request arrays
$SPOFields = array(
'PayKey' => $PayKey, // Required. The pay key that identifies the payment for which you want to set payment options.
'ShippingAddressID' => '' // Sender's shipping address ID.
);
$DisplayOptions = array(
'EmailHeaderImageURL' => '', // The URL of the image that displays in the header of customer emails. 1,024 char max. Image dimensions: 43 x 240
'EmailMarketingImageURL' => 'http://www.angelleye.com/images/email_marketing_image.jpg', // The URL of the image that displays in the customer emails. 1,024 char max. Image dimensions: 80 x 530
'HeaderImageURL' => 'http://www.angelleye.com/header_image.jpg', // The URL of the image that displays in the header of a payment page. 1,024 char max. Image dimensions: 750 x 90
'BusinessName' => 'Test business' // The business name to display. 128 char max.
);
$InstitutionCustomer = array(
'CountryCode' => 'US', // Required. 2 char code of the home country of the end user.
'DisplayName' => 'Tester Testerson', // Required. The full name of the consumer as known by the institution. 200 char max.
'InstitutionCustomerEmail' => 'payment#creiterate.com ', // The email address of the consumer. 127 char max.
'FirstName' => 'Tester', // Required. The first name of the consumer. 64 char max.
'LastName' => 'Testerson', // Required. The last name of the consumer. 64 char max.
'InstitutionCustomerID' => '12345', // Required. The unique ID assigned to the consumer by the institution. 64 char max.
'InstitutionID' => '6V8R7B4KPS22E' // Required. The unique ID assigned to the institution. 64 char max.
);
$SenderOptions = array(
'RequireShippingAddressSelection' => '' // Boolean. If true, require the sender to select a shipping address during the embedded payment flow. Default is false.
);
// Begin loop to populate receiver options.
$ReceiverOptions = array();
$ReceiverOption = array(
'Description' => 'Test Hello', // A description you want to associate with the payment. 1000 char max.
'CustomID' => '' // An external reference number you want to associate with the payment. 1000 char max.
);
$cost =$cost-10;
$InvoiceData = array(
'TotalTax' => '', // Total tax associated with the payment.
'TotalShipping' => '10' // Total shipping associated with the payment.
);
$InvoiceItems = array();
$InvoiceItem = array(
'Name' => 'Widget ABC', // Name of item.
'Identifier' => '', // External reference to item or item ID.
'Price' => $cost, // Total of line item.
'ItemPrice' => $cost, // Price of an individual item.
'ItemCount' => '1' // Item QTY
);
array_push($InvoiceItems,$InvoiceItem);
$PayPalRequestData = array(
'SPOFields' => $SPOFields,
'DisplayOptions' => $DisplayOptions,
'InstitutionCustomer' => $InstitutionCustomer,
'SenderOptions' => $SenderOptions,
'ReceiverOptions' => $ReceiverOptions
);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->SetPaymentOptions($PayPalRequestData);
}
I am using PayPal's API to process a payment using SetExpressCheckout method.
$requestParams = array(
'RETURNURL' => 'SUCCESS_PAGE_URL',
'CANCELURL' => 'CANCE_PAGE_URL'
);
$orderParams = array(
'PAYMENTREQUEST_0_AMT' => $price,
'PAYMENTREQUEST_0_SHIPPINGAMT' => '0',
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD',
'PAYMENTREQUEST_0_ITEMAMT' => $price
);
$item = array(
'L_PAYMENTREQUEST_0_NAME0' => $item_name,
'L_PAYMENTREQUEST_0_DESC0' => $item_description,
'L_PAYMENTREQUEST_0_AMT0' => $price,
'L_PAYMENTREQUEST_0_QTY0' => '1'
);
$paypal = new Paypal();
$response = $paypal -> request('SetExpressCheckout',$requestParams + $orderParams + $item);
It all works great, but even though the description is showing in the PayPal's checkout page, the email receipt that I get is missing the description information.
Does anyone know what how I can get the description to show on the receipt?
Figured it out. When the SetExpressCheckout is done and returns "Success" it gets redirected to PayPal, after which it goes back to your specified RETURNURL. On this RETURNURL page, for DoExpressCheckoutPayment, you need to specify the order details, this is what shows up in the invoice. Here is the code:
// Complete the checkout transaction
$requestParams = array(
'TOKEN' => $_GET['token'],
'PAYMENTACTION' => 'Sale',
'PAYERID' => $_GET['PayerID'],
'PAYMENTREQUEST_0_AMT' => '1', // Same amount as in the original request
'PAYMENTREQUEST_0_CURRENCYCODE' => 'USD' // Same currency as the original request
);
$item = array(
'L_PAYMENTREQUEST_0_NAME0' => $name,
'L_PAYMENTREQUEST_0_DESC0' => $desc, // <-- this is the description
'L_PAYMENTREQUEST_0_AMT0' => $price,
'L_PAYMENTREQUEST_0_QTY0' => '1'
);
$response = $paypal -> request('DoExpressCheckoutPayment',$requestParams + $item);
I'm trying to set a shipping info (name,address, email, etc) using OmniPay for PayPal Express.
I've tried adding shipping info in options array in purchase($options) object:
$options = array(
// required fields (username, pass, etc)
// .....
'shippingAddress1' => 'Elm Street'
'shippingCity' => 'Elm',
'shippingPostcode' => '1000'
// etc.
);
I also tried passing this info to CreditCard object:
$card = new Omnipay\Common\CreditCard($card_options);
without any success. The code:
$gateway = GatewayFactory::create('PayPal_Express');
$gateway->setUsername(USERNAME);
$gateway->setPassword(PASS);
$gateway->setSignature(SIGNATURE);
$gateway->setTestMode(true);
$card_options = array(
'shippingAddress1' => 'Elm Street',
'shippingCity' => 'Elm',
'shippingPostcode' => '10000',
'shippingState' => '',
'shippingCountry' => 'NEverland',
'shippingPhone' => '123465789',
'company' => '',
'email' => 'shipping#test.com'
);
$card = new Omnipay\Common\CreditCard($card_options);
$response = $gateway->purchase(
array(
'cancelUrl'=>'http://localhost/laravel_paypal/',
'returnUrl'=>'http://localhost/laravel_paypal/public/paypalexpress_confirm',
'amount' => '0.99',
'currency' => 'USD',
'card' => $card
)
)->send();
How to add shipping info to PayPal Express using OmniPay?
BTW, I'm using Laravel with PayPal Sandbox.
This problem has recently been fixed (https://github.com/adrianmacneil/omnipay/pull/140) so it should now be possible to set shipping info properly.
my $csr = Net::OpenID::Consumer->new(
ua => LWP::UserAgent->new,
consumer_secret => '123456xXx',
required_root => "http://www.myopenidsample.net/",
);
my $openid = "https://me.yahoo.com";
my $claimed_id = $csr->claimed_identity($openid);
if ($claimed_id){
my $check_url = $claimed_id->check_url(
delayed_return => 1,
return_to => "http://www.myopenidsample.net/response.cgi",
trust_root => "http://www.myopenidsample.net/",
);
print $q->redirect($check_url);
}
How do I get attributes such as email, firstName, lastName, and country?
How do I append the following parameters to a URL?
openid.ext1.mode fetch_request
openid.ext1.required country,email,firstname,lastname,language
openid.ext1.type.country http://axschema.org/contact/country/home
openid.ext1.type.email http://axschema.org/contact/email
openid.ext1.type.firstname http://axschema.org/namePerson/first
openid.ext1.type.language http://axschema.org/pref/language
openid.ext1.type.lastname http://axschema.org/namePerson/
openid.ns.ext1 http://openid.net/srv/ax/1.0
You need to add the following code before the call to check_url (the example was tested with Google in order to get only the email):
$claimed_id->set_extension_args(
"http://openid.net/srv/ax/1.0",
{
'mode' => 'fetch_request',
'type.email' => 'http://axschema.org/contact/email',
'required' => 'email',
});
To get the value back in the return, I use:
my $email = $csr->message->get_ext
("http://openid.net/srv/ax/1.0", "value.email");