Jump to content

Php Script For Mobile Website Checkout


LightBulb1

Recommended Posts

I need to add parameters to include a telephone number option and a url option for the purchaser to enter when making a purchase with the below mobile website checkout script, i need to know how and where to add the parameters,

 

I have tried a few options but with out success,

 

Any help would be much appreciated,

 

 

<?php

 

require_once 'PaypalMobile.php';

require_once 'Curl.php';

 

$paypal = new PaypalMobile();

 

/**

* configuration for both sandbox and live NVP

*/

$config['env'] = 'dev';

if ($config['env'] != 'live') {

$config['paypal']['api']['user'] = '';

$config['paypal']['api']['pass'] = '';

$config['paypal']['api']['signature'] = '';

$config['paypal']['api']['endpoint'] = 'https://api-3t.paypal.com/nvp';

$config['paypal']['api']['url'] = 'https://mobile.paypal.com/wc?t=';

} else {

$config['paypal']['api']['user'] = '';

$config['paypal']['api']['pass'] = '';

$config['paypal']['api']['signature'] = '';

$config['paypal']['api']['endpoint'] = 'https://api-3t.paypal.com/nvp';

$config['paypal']['api']['url'] = 'https://mobile.paypal.com/wc?t=';

}

$config['paypal']['api']['version'] = '3.0';

 

 

 

/**

* give our library our config

*/

$paypal->setApiVersion($config['paypal']['api']['version'])

->setApiUrl($config['paypal']['api']['endpoint'])

->setApiUser($config['paypal']['api']['user'])

->setApiPass($config['paypal']['api']['pass'])

->setApiSignature($config['paypal']['api']['signature']);

 

 

// SetMobileChechout

if (!isset($_REQUEST['token']) || $_REQUEST['token'] == '') {

 

 

/**

* Optional params

*

* $params['email'] = ''; // email to propagate the login page with

* $params['phonenum'] = ''; // phone number to propagate the login page with

* $params['taxamt'] = ''; // tax

* $params['shippingamt'] = ''; // shipping

* $params['number'] = ''; // internal item number

* $params['custom'] = ''; // internal returned data

* $params['invnum'] = ''; // unique invoice number

* $params['addressdisplay'] = '0'; // 1|0 require address

* $params['sharephonenum'] = '1'; // 1|0 return customers mobile number

* $params['shiptocity'] = ''; // city to propogate address form with

* $params['shiptostate'] = ''; // state to propogate the address form with

* $params['shiptocountry'] = ''; // country to propogate the address form with

* $params['shiptozip'] = ''; // zip to propogate the address form with

*/

 

$response = $paypal->setAmt('0.50')

->setCurrencycode('GBP')

->setDesc('Mobile Website Design')

->setReturnurl('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'])

->setCancelurl('http://')

->setMobileCheckout($params);

 

 

if ($paypal->getResponseStatus()) {

/**

* forward user off to paypal

*/

header('Location: '.$config['paypal']['api']['url'].urldecode($paypal->getToken()));

} else {

/**

* error!!

*/

echo 'ERROR<br /><pre>'.print_r($response,1);

}

 

// DoMobileCheckout

} else {

 

$response = $paypal->setToken($_REQUEST['token'])

->doMobileCheckoutPayment();

 

/**

* success!!

*/

if ($paypal->getResponseStatus()) {

 

 

 

 

 

 

 

/**

* Returned data

*

* $response['email'] // buyers email address

* $response['payerid'] // unique buyer id

* $response['payerstatus'] // status of buyers email

* $response['countrycode'] // country code

* $response['business'] // buyers business name

* $response['phonenum'] // buyers phone number

* $response['salutation'] // buyers salutation

* $response['firstname'] // buyers first name

* $response['middlename'] // buyers middle name

* $response['lastname'] // buyers last name

* $response['suffix'] // buyers suffix

*

* $response['custom'] // internaly returned data

* $response['invnum'] // returned unique invoice number

* $response['transactionid'] // external transaction id

* $response['parenttransactionid'] // used for cancels and reversals

* $response['receiptid'] // external receipt id

*

* $response['ordertime'] // current date and time

* $response['amt'] // order amount

* $response['currencycode'] // currency code

* $response['feeamt'] // processing fee deducted

* $response['exchangerate'] // exchange rate for currency conversion

*

* $response['transactiontype'] // send-money

* $response['paymentstatus'] // Completed, Pending, or Reversed

* $response['reasoncode'] // used for reversals

*

* $response['name'] // buyers shipping name

* $response['shiptostreet'] // buyers shipping address

* $response['shiptostreet2'] // buters shipping address 2

* $response['shiptocity'] // buyers shipping city

* $response['shiptostate'] // buyers shipping state

* $response['shiptocountry'] // buyers shipping country

* $response['shiptozip'] // buyers shipping zip

* $response['shiptophonenum'] // buyers shipping phone number

* $response['addressowner'] // eBay or PayPal

* $response['addressstatus'] // None, Confirmed, or Unconfirmed

*/

 

 

} else {

/**

* error!!

*/

echo 'ERROR<br /><pre>'.print_r($response,1);

}

 

}

 

 

?>

Link to comment
Share on other sites

I can't help you with the exact code.... I'm actually trying to understand it myself for php.... but when I had it correctly hooked up in my old ActionScript, my code was the following which was in some old documentation.... I'm assuming if you use the same variables "night_phone_a"... etc it might work. I don't know why they split it up like that.. (area code, next three digits, then last 4)

 

paypal.night_phone_a="200";

paypal.night_phone_b="123";

paypal.night_phone_c="6789";

Link to comment
Share on other sites

http://www.google.no/search?client=opera&q=paypal+mobile+api+documentation&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest <- I found lots of information/documentation on the mobile API. Including a PDF (second hit) which seems quite interesting.

 

Also, if you indeed cannot find any documentation on how to do what you want to, you need to actually study the code itself. Something I, personally, would have done anyway. That will help to ensure that you understand what it does, how it works, and (most importantly) what it doesn't do.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.