Bitcoin Forum
November 12, 2024, 04:55:25 PM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
   Home   Help Search Login Register More  
Pages: [1] 2 »  All
  Print  
Author Topic: Looking for a PHP dev that can give me some Pseudo-code for Dwolla API [2BTC]  (Read 4906 times)
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 04:20:09 AM
 #1

I will give 2 BTC to anyone that can give me some pseudo code or near complete and working code with explination or even simple comments of what everything is doing( i can figure things out pretty quickly if its done in front of my eyes so nothing too specific)

Just go to this link and at the end of your response post your BTC address
http://stackoverflow.com/questions/7543582/integrating-dwolla-with-php-with-their-api
mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 25, 2011, 04:57:55 AM
Last edit: September 25, 2011, 05:09:21 AM by mjcmurfy
 #2

You use the SOAP protocol to communicate with their API.

Here is a link to a discussion on the API:
http://www.dwolla.org/d/showthread.php?3-SOAP-API

Here is a link to the php.net database on SOAP, and how to implement it:
http://www.php.net/manual/en/class.soapclient.php

This is the address that you use to communicate with the API:
https://www.dwolla.com/api/API.svc?wsdl

You authenticate with an API key, generated in your dwolla API settings, I believe. Then you can use the other functions of the API.

Sorry can't be more specific right now, it's pretty late here right now.
But it's pretty easy to do, just read through the documentation on both of those links, and you should figure it out.

I can post more detailed information tomorrow for you.

http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 05:40:49 AM
 #3

excellent documentation, I didn't learn about SOAP until like just now although I've heard of it, i think I'm missing something here..... take a look at my format

<?php
Code:
$client = new SoapClient("https://www.dwolla.com/api/API.svc?wsdl");
//Attempt to buy something with dwolla form
$client->RequestPaymentKey("0Aw5gdfgfdgdfgdfgJjfsjdfsdfsdfsdfsfsfsfsdfgfgdj2NA+r0QUFnTeofqvRPl",
"oDzdfgdfgdrgdfvsdfwefvtdbyndgsjfgdgfdghjgklgVwga7qbWoL",
"1.50",
"Testing testing testing",
"812-504-6527");
print_r($client);

var_dump($client->__getFunctions());
?>
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 05:50:39 AM
 #4

Bounty is still up for grabs if someone wants to assist in writing some psuedo-code
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 05:58:26 AM
 #5

excellent documentation, I didn't learn about SOAP until like just now although I've heard of it, i think I'm missing something here..... take a look at my format

<?php
Code:
$client = new SoapClient("https://www.dwolla.com/api/API.svc?wsdl");
//Attempt to buy something with dwolla form
$client->RequestPaymentKey("0Aw5gdfgfdgdfgdfgJjfsjdfsdfsdfsdfsfsfsfsdfgfgdj2NA+r0QUFnTeofqvRPl",
"oDzdfgdfgdrgdfvsdfwefvtdbyndgsjfgdgfdghjgklgVwga7qbWoL",
"1.50",
"Testing testing testing",
"812-504-6527");
print_r($client);

var_dump($client->__getFunctions());
?>

oh yeah error is like this
Quote from: error
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:16 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(16): SoapClient->__call('RequestPaymentK...', Array) #1 /home/swiftbitcoins/purchase_order.php(16): SoapClient->RequestPaymentKey('s:50:"0AwevY8CP...', 'oDz1XJ1bjbaTk0i...', '1.50', 'Testing testing...', '812-504-6527') #2 {main} thrown in /home/swiftbitcoins/purchase_order.php on line 16
mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 25, 2011, 06:25:42 AM
Last edit: September 25, 2011, 06:41:48 AM by mjcmurfy
 #6

You can use their test API (https://www.dwolla.com/api/TestAPI.svc?wsdl) to mess around, rather than their official one.

The following code:

Quote
<?php

$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl");
var_dump($client->__getFunctions());

?>

returns the following:

Quote
array(5) { [ 0 ]=> string(50) "SendMoneyResponse SendMoney(SendMoney $parameters)" [1]=> string(83) "SendMoneyAssumeCostsResponse SendMoneyAssumeCosts(SendMoneyAssumeCosts $parameters)" [2]=> string(74) "RequestPaymentKeyResponse RequestPaymentKey(RequestPaymentKey $parameters)" [3]=> string(71) "VerifyPaymentKeyResponse VerifyPaymentKey(VerifyPaymentKey $parameters)" [4]=> string(65) "ConfirmPaymentResponse ConfirmPayment(ConfirmPayment $parameters)" }

http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 25, 2011, 06:31:07 AM
 #7

You can call the functions by using:

Quote
$client->__soapCall("SomeFunction", array($a, $b, $c));

I think your way will also work i,e, $client->SomeFunction(yada, yada);
It's just a slightly different way of doing it.

Set each variable first, before the call. So you can be sure your strings are strings and amounts are numbers.
I believe your call failed because where in your call you put "1.50" in quotes, the handler is expecting a decimal value, not a string.
Try removing the quotes and see if it works out for you.

The parameters, types and descriptions of the functions and their variables can be found here:
http://www.dwolla.org/d/showthread.php?3-SOAP-API


http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 25, 2011, 06:51:32 AM
Last edit: September 25, 2011, 07:04:33 AM by mjcmurfy
 #8

Try something along these lines:

Quote
<?php

$apiKey='xyz';
$apiCode='xyz';
$description='test';

//ENTER NUMBER, NOT STRING
$amount=123;

$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl");
$client->__soapCall("RequestPaymentKey", array($apiKey, $apiCode, $amount, $description));

//RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise

if($client)
{
     //function executed succesfully
}
else
{
    //it didn't
}

?>

for testing purposes, it says on the dwolla site:

Quote
You are able to test Dwolla’s API by using the following WSDL:
https://www.dwolla.com/api/TestAPI.svc?wsdl

Test API calls will not hit Dwolla’s database & no action save the responses defined are undertaken. For example, the normal generation of an email containing a secure payment key when RequestPaymentKey() is called does not take place. To simulate success or failure of each method, the amount parameter’s value is changed to one of the following values:

Amount    Result
$1.00      Causes the operation to be successful
$3.00      Amount too large (SOAP fault)
$4.00      User is invalid (SOAP fault)
Other      Amount invalid (SOAP fault)

So I think if you change the amount value to those test values, and it will simulate a success ($1), a too large failure ($3), a user invalid failure ($4) or an amount invalid failure (any other value).

http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 07:15:04 AM
 #9

Thanks a bunch i will report back with my results you should give me BTC address just for the effort already!
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 09:48:27 AM
 #10

I think it's not picking up the parameters correctly as no matter if I try it my way or your way it just gives me this error about Deserlization or somthing of the sort....

Code:
Fatal error: Uncaught SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:21 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(21): SoapClient->__soapCall('RequestPaymentK...', Array) #1 {main} thrown in /home/swiftbitcoins/purchase_order.php on line 21 

Here is the code I use slightly modified you for got the "CustomerId" value

<?php
Code:

$apiKey='0AwevY8CPVHiT2wxoxIl';
$apiCode='oDz1XJ1bjbaTk0i5RMcoEq';
$description='Testing CIB Testing';

$amount=123;

$customerId = "812-504-6527";

$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl");
$client->__soapCall("RequestPaymentKey", array($apiKey, $apiCode, $amount, $description, $customerId));

//RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise

if($client)
{
     //function executed succesfully
}
else
{
    //it didn't
}

?>
captainteemo
Full Member
***
Offline Offline

Activity: 143
Merit: 101


View Profile
September 25, 2011, 05:05:59 PM
 #11

I don't deal with Dwolla, but.


"Fatal error: Uncaught SoapFault exception"

//RequestPaymentKey returns a boolean: true if the request was successfully processed, False or exception otherwise

?
nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
September 25, 2011, 07:37:46 PM
 #12

Is your amount supposed to be a string or int?

Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 25, 2011, 11:52:56 PM
 #13

Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?
nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
September 26, 2011, 12:16:36 AM
 #14

Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?

$amount=123;

Why do you have int, then? Tongue

Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 26, 2011, 01:07:12 AM
 #15

Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?

$amount=123;

Why do you have int, then? Tongue

Becuase I previously tryed a varchar but doing the value in quotes.
I thought you ment like forceing php to do int like this

$amount = (int) 123;

If i do that I wont accept decimals (as far as i know)
nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
September 26, 2011, 01:37:28 AM
Last edit: September 26, 2011, 05:40:36 AM by nhodges
 #16

I think you're not forming your object you are passing to the SOAP interface correctly. Shouldn't you have something, like an associative array, that is defining what parameters you are passing to the API?

Code:
$params = array(
  'ApiKey' => $apiKey,
  'ApiCode' => $apiCode,
  'Amount' => $amount,
  'Description' => $description,
  'CustomerID' => $customerId
);

$client->__soapCall("RequestPaymentKey", $params);

Well-constructed API's don't usually parse bundled data sequentially, since there might be non-required fields that would totally skew that type of processing.

mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 26, 2011, 07:43:48 AM
 #17

Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?

$amount=123;

Why do you have int, then? Tongue

Becuase I previously tryed a varchar but doing the value in quotes.
I thought you ment like forceing php to do int like this

$amount = (int) 123;

If i do that I wont accept decimals (as far as i know)


If you have passed your amount to that script as a string, you can get the float value by using: floatval($amount);
You can have it round to 2 decimal places if you use floatval(round($amount,2));

@nhodges: it doesn't matter what you initialize the variable with. If you initialize it with an integer, the variable will be an integer. If you initialize it with a float, it will be a float variable. So it's not necessarily an integer he has defined. For testing purposes yes, but if he wrote $amount=1.23, it would be initialized as a float.

http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
nhodges
Sr. Member
****
Offline Offline

Activity: 322
Merit: 251


View Profile
September 26, 2011, 09:28:23 AM
 #18

Is your amount supposed to be a string or int?

I don't think (int) can accept decimals?

$amount=123;

Why do you have int, then? Tongue

Becuase I previously tryed a varchar but doing the value in quotes.
I thought you ment like forceing php to do int like this

$amount = (int) 123;

If i do that I wont accept decimals (as far as i know)


If you have passed your amount to that script as a string, you can get the float value by using: floatval($amount);
You can have it round to 2 decimal places if you use floatval(round($amount,2));

@nhodges: it doesn't matter what you initialize the variable with. If you initialize it with an integer, the variable will be an integer. If you initialize it with a float, it will be a float variable. So it's not necessarily an integer he has defined. For testing purposes yes, but if he wrote $amount=1.23, it would be initialized as a float.

Sure, I know about PHP's funky type casting (good or bad, however you want to look at it) I was just thinking it might be an issue on the API side. Do you think the issue Xenland is having is more related to the second suggestion I made, though?

mjcmurfy
Sr. Member
****
Offline Offline

Activity: 336
Merit: 250



View Profile WWW
September 26, 2011, 09:38:05 AM
 #19

Sure, I know about PHP's funky type casting (good or bad, however you want to look at it) I was just thinking it might be an issue on the API side. Do you think the issue Xenland is having is more related to the second suggestion I made, though?

It's quite possible. An associative array might do the trick alright.

http://www.bitcointorrentz.com/images/bct_button_117_30.png - BitCoinTorrentz.com: High-speed HTTP torrent downloads. 0.05 btc/gb. Up to 50% discount with free membership!
Xenland (OP)
Legendary
*
Offline Offline

Activity: 980
Merit: 1003


I'm not just any shaman, I'm a Sha256man


View Profile
September 27, 2011, 12:13:17 AM
 #20

I attempted to use the associative array, and made sure all the variables match exactly from any spelling differences. Still getting this error:

Quote
SoapFault exception: [a:DeserializationFailed] The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'RequestPaymentKey'. End element 'Body' from namespace 'http://schemas.xmlsoap.org/soap/envelope/' expected. Found element 'param1' from namespace ''. Line 2, position 158. in /home/swiftbitcoins/purchase_order.php:31 Stack trace: #0 /home/swiftbitcoins/purchase_order.php(31): SoapClient->__soapCall('RequestPaymentK...', Array) #1 {main}ERROR

using this code
Code:
$client = new SoapClient("https://www.dwolla.com/api/TestAPI.svc?wsdl");
$params = array(
  'ApiKey' => $apiKey,
  'ApiCode' => $apiCode,
  'Amount' => $amount,
  'Description' => $description,
  'CustomerID' => $customerId
);


try{
$client->__soapCall("RequestPaymentKey", $params);
}catch(Exception $e){
echo $e;
echo "ERROR";
}

Just so we are clear ApiCode is really the "Secret" key right?
Pages: [1] 2 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!