LendingClub API OrderSubmitOrders action - php

I am attempting to interface with the LendingClub API using SOAP. I've generated some classes using wsdl2php.
The wsdl file can be found here: https://www.lendingclub.com/ws/1.3?wsdl
I've successfully executed 4 of the 5 API methods, but the submit order method results in the following error:
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR:
Encoding: Violation of encoding rules
Code exert (integer IDs replaced by XXXXXX:
$order = new Order();
$order->loanId = XXXXXX;
$order->requestedAmount = 25.00;
$order->portfolioId = XXXXXX;
$order_instruct = new OrderInstruct();
$order_instruct->aid = XXXXXX;
$order_instruct->orders = $order;
$submit_order = new OrderSubmitOrders();
$submit_order->instructs = $order_instruct;
$submit_order_response = $lendingClub->OrderSubmitOrders($submit_order);
var_dump($submit_order_response);
Thanks in advance.

$my_order= new Order();
$my_order->loanId = $soapResponse->result->loans[0]->id;
$my_order->requestedAmount = 'xxx';
$my_order->portfolioId = 'xxxxxxxxx';
$instruct = new OrderInstruct();
$instruct->aid = "xxxxxxxxx";
$instruct->orders = array(my_order);
$orderSubmitObject = new OrderSubmitOrders();
$orderSubmitObject->instructs = $instructs;
$lendingClub->OrderSubmitOrders($orderSubmitObject);

Related

Paytm php sdk integration PaymentDetailBuilder Class not found

Fatal error: Uncaught Error: Class 'PaymentDetailBuilder' not found
initial code is like this:
require_once('vendor/autoload.php');
use paytmpg\merchant\models\PaymentDetail\PaymentDetailBuilder;
use paytmpg\merchant\models\PaymentStatusDetail\PaymentStatusDetailBuilder;
use paytmpg\merchant\models\RefundDetail\RefundDetailBuilder;
use paytmpg\merchant\models\RefundStatusDetail\RefundStatusDetailBuilder;
// For Staging
$environment = LibraryConstants::STAGING_ENVIRONMENT;
// For Production
// $environment = LibraryConstants::PRODUCTION_ENVIRONMENT;
// Find your mid, key, website in your Paytm Dashboard at https://dashboard.paytm.com/next/apikeys
$mid = MERCHANT_MID;
$key = MERCHANT_KEY;
$website = MERCHANT_WEBSITE;
$client_id = MERCHANT_CLIENT_ID;
$callbackUrl = MERCHANT_CALLBACK_URL;
MerchantProperties::setCallbackUrl($callbackUrl);
MerchantProperties::initialize($environment, $mid, $key, $client_id, $website);
// If you want to add log file to your project, use below code
// Config::$monologName = '[PAYTM]';
// Config::$monologLevel = MonologLogger::INFO;
// Config::$monologLogfile = 'file.log';
$channelId = EChannelId::WEB;
$orderId = "ORDER_ID".rand(0,99); // post order id
$txnAmount = Money::constructWithCurrencyAndValue(EnumCurrency::INR, "11.00"); // post amount to be paid
$userInfo = new UserInfo("CUSTID_002");
$userInfo->setAddress("CUSTOMER_ADDRESS");
$userInfo->setEmail("CUSTOMER_EMAIL_ID");
$userInfo->setFirstName("CUSTOMER_FIRST_NAME");
$userInfo->setLastName("CUSTOMER_LAST_NAME");
$userInfo->setMobile("CUSTOMER_MOBILE_NO");
$userInfo->setPincode("CUSTOMER_PINCODE");
$paymentDetailBuilder = new PaymentDetailBuilder($channelId, $orderId, $txnAmount, $userInfo);
$paymentDetail = $paymentDetailBuilder->build();
$response = Payment::createTxnToken($paymentDetail);
print_r($response);
I have copied from => https://developer.paytm.com/docs/server-sdk/php/?ref=serverSdk#SDKCode;

How to forward mail with php-ews

I'll try to forward a mail with php-ews, but can't get it to work.
I have read the documentation for XML EWS
https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-respond-to-email-messages-by-using-ews-in-exchange
but I'll guess I've missed something.
$request = new CreateItemType();
$request->MessageDisposition = MessageDispositionType::SEND_AND_SAVE_COPY;
$request->Items = new NonEmptyArrayOfAllItemsType();
$request->Items->ForwardedItem = new ForwardItemType();
$request->Items->ForwardedItem->ToRecipients = new MessageType();
$request->Items->ForwardedItem->ToRecipients->Mailbox = new EmailAddressType();
$request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxName = 'Foo Bar';
$request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxAddress = 'Foo#Bar.com';
$request->Items->ForwardedItem->ReferenceItemId = new ItemIdType();
$request->Items->ForwardedItem->ReferenceItemId->Id = 'AAMk.....AAA=';
$request->Items->ForwardedItem->ReferenceItemId->ChangeKey = 'CQAA.....GOP';
$request->Items->ForwardedItem->NewBodyContent = new BodyContentType();
$request->Items->ForwardedItem->NewBodyContent->Value = 'Test';
$request->Items->ForwardedItem->NewBodyContent->BodyType = BodyTypeType::HTML;
The error message I'll get is:
Fatal error: Uncaught SoapFault exception: [a:ErrorInvalidRequest] Id
must be non-empty.
This doesn't look right
$request->Items->ForwardedItem->ToRecipients = new MessageType();
$request->Items->ForwardedItem->ToRecipients->Mailbox = new EmailAddressType();
$request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxName = 'Foo Bar';
$request->Items->ForwardedItem->ToRecipients->Mailbox->MailboxAddress = 'Foo#Bar.com';
ToRecipients should be an array of recipient types so i think it should be
$request->Items->ForwardedItem->ToRecipients = new ArrayOfRecipientsType();
$recipient = new EmailAddressType();
$recipient->Name = 'Homer Simpson';
$recipient->EmailAddress = 'hsimpson#example.com';
$request->Items->ForwardedItem->ToRecipients->Mailbox[] = $recipient;

SoapFault: looks like we got no XML document Magento and laravel

i am with a problem in my application Laravel, when i use the SoapClient, for example my_object_soap->login(); returned this error:
Fatal error: Uncaught SoapFault exception: [Client] looks like we got no XML
I already tried several solutions that I researched in google and here, but I did not solve my problem.
my code follows:
ini_set("soap.wsdl_cache_enabled",0);
ini_set("soap.wsdl_cache",0);
ini_set("error_reporting",-1);
ini_set("display_errors","On");
$wsdl_url = "https://example.com/index.php/api/v2_soap/index/?wsdl";
$apiAuth = new \stdClass();
$apiAuth->username = trim("myusermagento");
$apiAuth->apiKey = trim("mykeymagento");
try{
$proxy = new SoapClient($wsdl_url,array('cache_wsdl' => WSDL_CACHE_NONE, 'trace' => true));
$session = $proxy->login($apiAuth);
$data = $session;
$status = true;
$responseStatus = 200;
} catch(SoapFault $e) {
$error = $e->getMessage();
$data = $proxy->__getLastResponse();
$status = false;
$responseStatus = 500;
}
return Response::json([
'success' => $status,
'data' => $data,
'erros'=> $error,
],$responseStatus);
I have no idea which a problem, when i tested in SoapUI, with this user and key, it's alright, but in my app not.
My magento version app is 1.6.2, and my php is 7.2, I already tried to downgrade to php 5.6 because it could be incompatibility with the magento version and my php but it still did not work.
Can someone help me?
Try this one, structure your request as follows
$options = array('trace'=> true,'exceptions' => true);
$client = new \SoapClient('https://www.example.com?wsdl',$options);
$params = new \stdClass();
$params->key1 = 'XXXXXX';
$params->Key2 = 'XXXXX';
$soapVar = new \SoapVar($params,SOAP_ENC_OBJECT);
$header = new \SoapHeader('https://www.example?wsdl','credentials',$soapVar);
$client->__setSoapHeaders(array($header));
$result=$client->login(function parameters here);
Cheers!!!

how do i authenticate against cybersource soap toolkit api on php

I have the following code on my index.php
<?php
// This sample demonstrates how to run a sale request, which combines an
// authorization with a capture in one request.
// Using Composer-generated autoload file.
require __DIR__ . '/vendor/autoload.php';
// Or, uncomment the line below if you're not using Composer autoloader.
//require_once(__DIR__ . '/lib/CybsSoapClient.php');
// Before using this example, you can use your own reference code for the transaction.
$referenceCode = 'holla';
$client = new CybsSoapClient();
$request = $client->createRequest($referenceCode);
// Build a sale request (combining an auth and capture). In this example only
// the amount is provided for the purchase total.
$ccAuthService = new stdClass();
$ccAuthService->run = 'true';
$request->ccAuthService = $ccAuthService;
$ccCaptureService = new stdClass();
$ccCaptureService->run = 'true';
$request->ccCaptureService = $ccCaptureService;
$billTo = new stdClass();
$billTo->firstName = 'John';
$billTo->lastName = 'Doe';
$billTo->street1 = '1295 Charleston Road';
$billTo->city = 'Mountain View';
$billTo->state = 'CA';
$billTo->postalCode = '94043';
$billTo->country = 'US';
$billTo->email = 'null#cybersource.com';
$billTo->ipAddress = '10.7.111.111';
$request->billTo = $billTo;
$card = new stdClass();
$card->accountNumber = '4111111111111111';
$card->expirationMonth = '12';
$card->expirationYear = '2020';
$request->card = $card;
$purchaseTotals = new stdClass();
$purchaseTotals->currency = 'USD';
$purchaseTotals->grandTotalAmount = '90.01';
$request->purchaseTotals = $purchaseTotals;
$reply = $client->runTransaction($request);
// This section will show all the reply fields.
print("\nRESPONSE: " . print_r($reply, true));
and the cybs.ini is like
merchant_id = "firefy"
transaction_key = "5430494897960177107046"
; Modify the URL to point to either a live or test WSDL file with the desired API version.
wsdl = "https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"
when i run the code on my local machine i get the following error messaage.
Fatal error: Uncaught SoapFault exception: [wsse:FailedCheck] Security Data : UsernameToken authentication failed. in C:\xampp\htdocs\cybersourceTest\index.php:50 Stack trace: #0 C:\xampp\htdocs\cybersourceTest\index.php(50): SoapClient->__call('runTransaction', Array) #1 {main} thrown in C:\xampp\htdocs\cybersourceTest\index.php on line 50
How do i know what caused the error above and how can i solve the above error.
I am trying to add payout api to my app and this is giving a headache right now.
Please guys help me out if anyone can.
The error “authentication failed” is saying your merchant_id and transaction_key are not correct.
Assuming that your merchant_id is correct your transaction_key is not the correct format. You can get a transaction_key by going to the business center at https://ebctest.cybersource.com then go to Account Management-> Transaction Security Keys -> Security Keys for the SOAP Toolkit API. Generate a key there.
I found out that i the url that i was pointing to was not valid or something but i fixed it by changing the endpoint of the wsdl from
wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.109.wsdl"
to
wsdl="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.151.wsdl"
That took care of everything that was wrong with the error that was popping up.

Google Cloud DNS Services - entity.change parameter is required but missing

With the following code using Google's PHP API Client I am receiving this response.
Google_Service_Exception with message 'Error calling POST https://www.googleapis.com/dns/v1/projects/PROJECT-NAME/managedZones/DNSZONE/changes: (400) The 'entity.change' parameter is required but was missing.
Where PROJECT-NAME and DNSZONE are my project and zone.
$client_email = MYCLIENT;
$private_key = file_get_contents('config/credentials/KEY.p12');
$scopes = array('https://www.googleapis.com/auth/ndev.clouddns.readwrite');
$project = "PROJECT-NAME";
$managedZone = "DNSZONE";
$creds = new Google_Auth_AssertionCredentials($client_email,$scopes,$private_key);
$client = new Google_Client();
$client->setAssertionCredentials($creds);
$resource = new Google_Service_Dns_ResourceRecordSet();
$resource->kind = "dns#resourceRecordSet";
$resource->name = "testing.DNSZONE.net.";
$resource->rrdatas[] = "testing.otherhost.com.";
$resource->ttl = 800;
$resource->type = "CNAME";
$dns = new Google_Service_Dns($client);
$change = new Google_Service_Dns_Change();
$change->kind = "dns#change";
$change->setAdditions($resource);
$dns->changes->create($project,$managedZone,$change);
I am a bit confused as to how to set this parameter. Or where I am even am to define it.
Just for clarify what the answer is, setAdditions expects an array.
$change->setAdditions([ $resource ]);

Categories