Perfectmoney API
Perfectmoney API
www.perfectmoney.is
A Programmers Guide to
API
13 March, 2007
This document describes the fields and parameters required for interfacing to the PerfectMoney
system to perform these actions.
1.1.9 Implementation
The user wishing to implement Perfect Money® automation functionality has several options for
implementing the task at hand. The language and platform chosen for the task must provide the
following functionality:
1. Support for HTTPS form submission to a remote host.
2. Support for examining returned data for results.
Security Notes:
1. Do not embed your PerfectMoney account passphrase in your automation
program. Rather, prompt the user for the passphrase when the program runs.
2. Examine your automation program closely for problems. You are just as
responsible for Perfect Money® transactions initiated by an automation program
as if you had entered the transaction by hand. (i.e. Perfect Money® spends are not
reversible regardless of the initiation method).
2. Automation Details
This section provides detailed information to allow a programmer to interface his automation
program to the Perfect Money® payment system.
In general, input fields are provided to the given URL via either an HTML form of the POST or
GET variety. For instance a GET style request to retrieve the balance PerfectMoney account
101574 might look like:
https://perfectmoney.is/acct/balance.asp?AccountID=101574&PassPhrase=This1isnotReal
The history and exchange rate data is returned in comma delimited format to the requestor. The
balance, spend, and preview URLs return result data in hidden fields embedded in normal
HTML. For example, the above balance request might return:
<html>
<head>
<title>Balance</title>
</head>
<body>
<h1>Balance</h1>
<table border=1>
<tr><td><b>Account
No.</b></td><td><b>Balance</b></td></tr><tr><td>U1234567</td><td>1152.31</td></tr>
<tr><td>E1234568</td><td>276.50</td></tr>
<tr><td>G1234569</td><td>0.00</td></tr>
</table>
<input name='U1234567' type='hidden' value='1152.31'>
<input name='E1234568' type='hidden' value='276.50'>
<input name='G1234569' type='hidden' value='0.00'>
</body>
</html>
The caller can ignore all the HTML fields and pull out the return values from the hidden fields.
(See the example scripts).
In order to make API output XML valid you can add this optional parameter to any of API
request described below: api_version=1
2.1 Perfect Money® spend
A spend may be performed by doing an HTML form post of GET or POST variety to the URL:
https://perfectmoney.is/acct/confirm.asp
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/confirm.asp
Input Field Name Description Example Value
AccountID Perfect Money® account login (payer) 10000
PassPhrase Perfect Money® account password This1isnotReal
Payer_Account Your Perfect Money® account to spend from U1234567
Payee_Account Perfect Money® account to spend to U7654321
Amount Amount to be spent. Must be positive numerical amount. 19.95
Memo Up to 100 characters to be placed in memo section of transaction. Thanks for
The memo is visible to both payer and payee. dinner.
PAYMENT_ID Optional merchant reference number. If present, this string of up ID-322223
to 50 characters is placed in the transaction. Payer and/or payee
may search/query account history for this value.
code (Optional) Pass this value if only you want to use transfer mycode123
protection code. If protection code is present, payee must enter
this code to get money to his/her account.
Must be alpha-numerical string of length from 1 to 20 chars.
Period (Optional) You need to pass this value if only you want to use 3
transfer protection code.
Number of days you want your transfer with protection code to be
valid. If payee does not enter protection code during this period,
money will be transferred back to your account.
Must be integer value from 1 to 365 days.
Output from the confirm.asp page will include HTML with embedded hidden form fields for
retrieving results of the spend. These are:
Output Fields from submit to
https://perfectmoney.is/acct/confirm.asp
Output Field Name Description Example Value
ERROR Spend did not occur if this field present. Text description Invalid
of error. PassPhrase.
Payee_Account_Name Name of account of payee. Actually the text payee entered John’s shop
in his/her “Account name” profile field.
Payer_Account Perfect Money® account of sender. U1234567
Payee_Account Perfect Money® account of recipient of spend. U7654321
PAYMENT_AMOUNT Numerical amount of spend as entered. This is the same 5.15
value as the Amount input field.
PAYMENT_BATCH_NUM PerfectMoney batch number generated for this transaction. 758094
Payer and/or payee may query/search account history by
this number.
PAYMENT_ID Optional merchant reference number. If present on input, ID-322223
this string of up to 50 characters is returned on output.
Payer and/or payee may search/query account history for
this value.
code (Optional) This value is present only for transfers with mycode123
protection code. If protection code is present, payee must
enter this code to get money to his/her account.
Can be alpha-numerical string of length from 1 to 20
chars.
Period (Optional) This value is present only for transfers with 3
protection code. Number of days you want your transfer
with protection code to be valid. If payee does not enter
protection code during this period, money will be
transferred back to your account.
Must be integer value from 1 to 365 days.
2.2 Perfect Money® spend preview/verification
An Perfect Money® spend preview may be performed by doing an HTML form post of GET or
POST variety to the URL: https://perfectmoney.is/acct/verify.asp
This preview / verification function might be used to check the validity of a potential spend prior
to executing it. Note that posting to this location does not actually perform any transfer of
Perfect Money®.
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/verify.asp
Input Field Name Description Example Value
AccountID Perfect Money® account login (payer) 10000
PassPhrase Perfect Money® account password This1isnotReal
Payer_Account Perfect Money® account of sender. U1234567
Payee_Account Perfect Money® account to spend to U7654321
Amount Amount to be spent. Must be positive numerical amount.. 19.95
Memo Up to 100 characters to be placed in memo section of payment. Thanks for
The memo is visible to both payer and payee. dinner.
PAYMENT_ID Optional merchant reference number. If present on input, this ID-322223
string of up to 50 characters is returned on output. Payer and/or
payee may search/query account history for this value.
code (Optional) Pass this value if only you want to use transfer mycode123
protection code. If protection code is present, payee must enter
this code to get money to his/her account.
Must be alpha-numerical string of length from 1 to 20 chars.
period (Optional) You need to pass this value if only you want to use 3
transfer protection code.
Number of days you want your transfer with protection code to be
valid. If payee does not enter protection code during this period,
money will be transferred back to your account.
Must be integer value from 1 to 365 days.
Output from the verify.asp page will include HTML with embedded hidden form fields for
retrieving results of the spend. These are:
Output Fields from submit to
https://perfectmoney.is/acct/verify.asp
Output Field Name Description Example Value
ERROR Verification is unsuccessful and did not occur if Invalid
this field present. Text description of error. PassPhrase.
Payee_Account_Name Name of account of payee. Actually the text John’s shop
payee entered in his/her “Account name” profile
field.
Payer_Account Perfect Money® account of sender. U1234567
Payee_Account Perfect Money® account of recipient of spend. U7654321
PAYMENT_AMOUNT Numerical amount of spend as entered. This is 5.15
the same value as the Amount input field.
PAYMENT_ID Optional merchant reference number. If present ID-322223
on input, this string of up to 50 characters is
returned on output. Payer and/or payee may
search/query account history for this value.
code (Optional) This value is present only for transfers mycode123
with protection code. If protection code is
present, payee must enter this code to get money
to his/her account.
Can be alpha-numerical string of length from 1
to 20 chars.
period (Optional) This value is present only for transfers 3
with protection code. Number of days you want
your transfer with protection code to be valid. If
payee does not enter protection code during this
period, money will be transferred back to your
account.
Must be integer value from 1 to 365 days.
2.3 Perfect Money® protection code confirmation
An Perfect Money® protection code confirmation may be performed by doing an HTML form
post of GET or POST variety to the URL: https://perfectmoney.is/acct/protection.asp
This protection code confirmation function is used to enroll payments previously sent to your
account with protection code.
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/protection.asp
Input Field Name Description Example Value
AccountID Perfect Money® account login (payer) 10000
PassPhrase Perfect Money® account password This1isnotReal
batch Perfect Money® batch number of transaction you want to confirm 758094
with protection code.
Must be numerical value.
code Perfect Money® protection code entered by payer of this somecode321
transaction.
Can be alpha-numerical string of length from 1 to 20 chars.
Output from the protection.asp page will include HTML with embedded hidden form fields for
retrieving results of the spend. These are:
Output Fields from submit to
https://perfectmoney.is/acct/protection.asp
Output Field Name Description Example Value
ERROR Confirmation is unsuccessful and did not occur Invalid
if this field present. Text description of error. PassPhrase.
PAYMENT_BATCH_NUM Perfect Money® batch number of transaction you 758094
just confirmed (enrolled) with protection code.
Numerical value.
code Perfect Money® protection code entered by somecode321
payer of this transaction.
Can be alpha-numerical string of length from 1
to 20 chars.
2.4 Perfect Money® account name fetching
An Perfect Money® account name fetching may be performed by doing an HTML form post of
GET or POST variety to the URL: https://perfectmoney.is/acct/acc_name.asp
This account name fetching function is used to get Account name profile field of passed account
ID.
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/acc_name.asp
Input Field Name Description Example Value
AccountID Perfect Money® account login 10000
PassPhrase Perfect Money® account password This1isnotReal
Account Perfect Money® account ID U1234567
Output from the acc_name.asp page will be Account name or error message if operation cannot
be completed:
Description Example
Account name fetching cannot be completed if ERROR prefix present followed by ERROR: Invalid
text description of error. PassPhrase.
Account name field of Account owner. John’s shop
2.5 Perfect Money® history
The transaction history for an Perfect Money® account can be retrieved in CSV (Comma
Separated Value) format using the URL: https://perfectmoney.is/acct/historycsv.asp
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/historycsv.asp
Input Field Name(s) Description Example Value(s)
AccountID Perfect Money® account login (payer) 10000
PassPhrase Perfect Money® account password This1isnotReal
startmonth, These three fields define the starting day to gather account history from. 12
startday, Month should be a number from 1 to 12, day should be a number from 1 1
startyear to 31 and year should be a 4 digit number from 2007 onward. 2007
endmonth, These three fields define the ending day to gather account history from. 12
endday, Month should be a number from 1 to 12, day should be a number from 1 31
endyear to 31 and year should be a 4 digit number from 2007 onward. 2007
History will be provided for records from the beginning of the start date
fields to the end of the end date fields. For instance, the example values
would retrieve one complete month of data for the month of December
2007.
paymentsmade If present on input, Perfect Money® payments made are included in the 1
history display. To not include Perfect Money® payments made, do not
include this as an input field.
paymentsreceived If present on input, Perfect Money® payments received are included in 1
the history display. To not include Perfect Money® payments received,
do not include this as an input field.
batchfilter If present on input, only transactions that have this value as a batch 1289
number are displayed.
counterfilter If present on input, only transactions that have this PerfectMoney U1234567
account number as a counter part (payments to/from this account
number) are displayed.
metalfilter If present on input, only transactions that use the given currency units are 1
displayed. Legal values are 1, 2 and 3 corresponding to US Dollars,
Euro, and Gold troy oz.
desc If present, sort records in descending order instead of the default 1
ascending order.
oldsort If present, defines the column to sort the history transactions on. (Default Amount
is timestamp). Choices are tstamp, batch_num, metal_name,
counteraccount_id and amount corresponding to the available
columns returned.
payment_id If present on input, only transactions that have this value as a payment_id ID-123
are displayed.
Upon submission to historycsv.asp, a set of data matching the requested input information is
returned. The report returned is of ContentType application/csv. If no records are found based on
the input parameters, a single line containing:
No Records Found.
Output from the rates.asp page will be a set of comma delimited ASCII data. This date/time will
be in GMT and will be formatted like “Month/Day/Year Hour:Minutes/Seconds AM/PM”
example: “6/2/00 9:36:45 PM“ corresponding to June 2nd 2000 21:36:45 GMT. The date/time
will be followed two values (depending on USD, EUR, GOLD inputs) giving the exchange rate
per unit for the selected currency (US Dollars default).
Example of input and output:
Example 1 “Current exchange rates for EUR & GOLD to USD”
http://perfectmoney.is/acct/rates.asp
gives:
3/13/08 6:25:05 PM, 0.65 , 0.001
Which provides the US Dollars exchange rates to Euro and Gold.
2.8 Perfect Money® e-Voucher listing
The e-Voucher listing for an Perfect Money® account can be retrieved in CSV (Comma
Separated Value) format using the URL: https://perfectmoney.is/acct/evcsv.asp
The following input fields should be used:
Input Fields for submit to
https://perfectmoney.is/acct/evcsv.asp
Input Field Name(s) Description Example Value(s)
AccountID * Perfect Money® account login (payer) 10000
PassPhrase * Perfect Money® account password This1isnotReal
startmonth, These three fields define the starting day to gather e-voucher listing 12
startday, from. Month should be a number from 1 to 12, day should be a number 1
startyear from 1 to 31 and year should be a 4 digit number from 2007 onward. 2007
Please note this date means the date when e-voucher was created.
endmonth, These three fields define the ending day to gather e-voucher listing from. 12
endday, Month should be a number from 1 to 12, day should be a number from 1 31
endyear to 31 and year should be a 4 digit number from 2007 onward. 2007
Listing will be provided for e-vouchers from the beginning of the start
date fields to the end of the end date fields. For instance, the example
values would retrieve one complete month of data for the month of
December 2007.
ev_number If present on input, only Perfect Money® e-Voucher with that number is 0123456789
included in the listing display.
batchfilter If present on input, only e-Voucher that have this value as a batch 1289
number is displayed.
counterfilter If present on input, only e-Vouchers that have this PerfectMoney account U1234567
as a counter part (payments to/from this account number) are displayed.
currency If present on input, only e-Vouchers that use the given currency units are 1
displayed. Legal values are 1, 2 and 3 corresponding to US Dollars,
Euro, and Gold troy oz.
desc If present, sort records in descending order instead of the default 1
ascending order.
oldsort If present, defines the column to sort the e-Vouvher listing on. (Default amount
is created). Choices are created, amount, currency and
batch corresponding to the available columns returned.
* Fields marked by the red star are mandatory. Other fields are optional.
Upon submission to evcsv.asp, a set of data matching the requested input information is returned.
The report returned is of ContentType application/csv. If no records are found based on the input
parameters, a single line containing:
No Records Found.
/*
*/
if($f===false){
echo 'error openning url';
}
fclose($f);
}else{
// do parsing
$ar=array();
$n=count($lines);
for($i=1; $i<$n; $i++){
echo '<pre>';
print_r($ar);
echo '</pre>';
?>
3.4 PHP script to preview Perfect Money®spend
This is a sample script, that demonstrates sending PerfectMoney spend request and parsing
output data to array.
<?php
/*
*/
if($f===false){
echo 'error openning url';
}
// getting data
$out=array(); $out="";
while(!feof($f)) $out.=fgets($f);
fclose($f);
$ar="";
foreach($result as $item){
$key=$item[1];
$ar[$key]=$item[2];
}
echo '<pre>';
print_r($ar);
echo '</pre>';
?>
3.5 PHP script to fetch Perfect Money® account name
This is a sample script, that demonstrates fetching PerfectMoney account name and by account
id.
<?php
/*
*/
if($f===false){
echo 'error openning url';
}
// getting data
$out="";
while(!feof($f)) $out.=fgets($f);
fclose($f);
echo '<pre>';
echo $out;
echo '</pre>';
?>
3.6 PHP script to display Perfect Money® balance
This is a sample script, that demonstrates sending PerfectMoney balance request and parsing
output data to array.
<?php
/*
*/
if($f===false){
echo 'error openning url';
}
// getting data
$out=array(); $out="";
while(!feof($f)) $out.=fgets($f);
fclose($f);
echo '<pre>';
print_r($ar);
echo '</pre>';
?>
3.7 PHP script to retrieve Perfect Money® e-Voucher listing
This is a sample script, that demonstrates parsing e-Voucher listing to array.
<?php
/*
*/
if($f===false){
echo 'error openning url';
}
fclose($f);
}else{
// do parsing
$ar=array();
$n=count($lines);
for($i=1; $i<$n; $i++){
echo '<pre>';
print_r($ar);
echo '</pre>';
?>
3.8 PHP script to create Perfect Money® e-Voucher
This is a sample script, that demonstrates sending PerfectMoney e-Voucher purchase request and
parsing output data to array.
<?php
/*
*/
if($f===false){
echo 'error openning url';
}
// getting data
$out=array(); $out="";
while(!feof($f)) $out.=fgets($f);
fclose($f);
$ar="";
foreach($result as $item){
$key=$item[1];
$ar[$key]=$item[2];
}
echo '<pre>';
print_r($ar);
echo '</pre>';
?>