I tried to implement Create Account API of paypal with the following sample parameters:
accountType=Premier&addressType.line1=Real+St&addressType.city=San+Jose&addressType.postalCode=92274&addressType.countryCode=US&addressType.state=California&citizenshipCountryCode=US&contactPhoneNumber=123-456-1234&homePhoneNumber=123-456-1234&mobilePhoneNumber=123-456-1234¤cyCode=USD&dateOfBirth=1970-01-01Z&emailAddress=test.test%40gmail.com&nameType.salutation=Miss&nameType.firstName=Malou&nameType.lastName=Perez&nameType.suffix=Sr&preferredLanguageCode=en_US®istrationType=Web&requestEnvelope.errorLanguage=en_US&requestEnvelope.detailLevel=ReturnAll&suppressWelcomeEmail=1&createAccountWebOptionsType.useMiniBrowser=0&createAccountWebOptionsType.returnUrl=http%3A%2F%2Fwww.testurlonly.com&createAccountWebOptionsType.reminderEmailFrequency=NONE&createAccountWebOptionsType.confirmEmail=0
To make it clearer, parameters when put in array has the following values:
$parameters = array(
'accountType' => 'Premier',
'addressType.line1' => 'Real St',
'addressType.city' => 'San Jose',
'addressType.postalCode' => '92274',
'addressType.countryCode' => 'US',
'addressType.state' => 'California',
'citizenshipCountryCode' => 'US',
'contactPhoneNumber' => '123-456-1234',
'homePhoneNumber' => '123-456-1234',
'mobilePhoneNumber' => '123-456-1234',
'currencyCode' => 'USD',
'dateOfBirth' => '1970-01-01Z',
'emailAddress' => 'test.test#gmail.com',
'nameType.salutation' => 'Miss',
'nameType.firstName' => 'Malou',
'nameType.lastName' => 'Perez',
'nameType.suffix' => 'Sr',
'preferredLanguageCode' => 'en_US',
'registrationType' => 'Web',
'requestEnvelope.errorLanguage' => 'en_US',
'requestEnvelope.detailLevel' => 'ReturnAll',
'suppressWelcomeEmail' => true,
'createAccountWebOptionsType.useMiniBrowser' => false,
'createAccountWebOptionsType.returnUrl' => 'http://www.testurlonly.com',
'createAccountWebOptionsType.reminderEmailFrequency' => 'NONE',
'createAccountWebOptionsType.confirmEmail' => false
);
here is the response of AdaptiveAccounts/CreateAccount api (converted to array):
array(18) {
["responseEnvelope.timestamp"]=>
string(29) "2013-01-07T21:33:01.984-08:00"
["responseEnvelope.ack"]=>
string(7) "Failure"
["responseEnvelope.correlationId"]=>
string(13) "ae7c9d245cabf"
["responseEnvelope.build"]=>
string(7) "4055066"
["error(0).errorId"]=>
string(6) "580029"
["error(0).domain"]=>
string(8) "PLATFORM"
["error(0).subdomain"]=>
string(11) "Application"
["error(0).severity"]=>
string(5) "Error"
["error(0).category"]=>
string(11) "Application"
["error(0).message"]=>
string(40) "Missing required request parameter: name"
["error(0).parameter(0)"]=>
string(4) "name"
["error(1).errorId"]=>
string(6) "580029"
["error(1).domain"]=>
string(8) "PLATFORM"
["error(1).subdomain"]=>
string(11) "Application"
["error(1).severity"]=>
string(5) "Error"
["error(1).category"]=>
string(11) "Application"
["error(1).message"]=>
string(43) "Missing required request parameter: address"
["error(1).parameter(0)"]=>
string(7) "address"
}
Please enlighten me why it says "Missing required request parameter: address" and "Missing required request parameter: name".
I was thinking addressType.line1=Real+St&addressType.city=San+Jose&addressType.postalCode=92274&addressType.countryCode=US&addressType.state=California
refers to address
and
nameType.salutation=Miss&nameType.firstName=Malou&nameType.lastName=Perez&nameType.suffix=Sr
refers to name.
Thank you.
Instead of nameType., use name.. Thus, we have
name.firstName, name.lastName, name.salutation and name.suffix
and I removed name.salutation because i do not have any idea on what the correct values for this field are.
For addressType., i replace it with adress. Moreover, address.state must have the state code and not the state name.
I also figured out that paypal returns 580022 Invalid request parameter for fields with incorrect format and values. We can not put dummy data for postalCode, city and state that are not existing.
Related
I'm having some problems with Paypal express in magento 2, I've migrated from magento 1, and now all is working, expect for paypal express.
I've debug paypal express and I get what I will post, for what I see the problem is maybe because o the prodcut prices are with tax included.
I've already acomplished to have the price without tax in checkout, but he always get the price with tax, what can I do? I've already disabled "Transfer cart line items".
The log is:
'AMT' => '16.70',
'CURRENCYCODE' => 'EUR',
'INVNUM' => '1000012787',
'SHIPPINGAMT' => '3.75',
'ITEMAMT' => '12.95',
'TAXAMT' => '2.42',
'BUSINESS' => 'rtr',
'NOTETEXT' => NULL,
'EMAIL' => 'info#test.pt',
'FIRSTNAME' => 'ertr',
'LASTNAME' => 'trt',
'MIDDLENAME' => NULL,
'SALUTATION' => NULL,
'SUFFIX' => NULL,
'COUNTRYCODE' => 'PT',
'STATE' => 'PR',
'CITY' => 'rt',
'STREET' => 'tr',
'ZIP' => '2335',
'PHONENUM' => 'rtrtrt',
'SHIPTOCOUNTRYCODE' => 'PT',
'SHIPTOSTATE' => 'PR',
'SHIPTOCITY' => 'rt',
'SHIPTOSTREET' => 'tr',
'SHIPTOZIP' => '2335',
'SHIPTOPHONENUM' => 'rtrtrt',
'SHIPTOSTREET2' => 'trt',
'STREET2' => 'trt',
'SHIPTONAME' => 'ertr trt',
'ADDROVERRIDE' => 1,
'METHOD' => 'SetExpressCheckout',
'VERSION' => '72.0',
'USER' => '****',
'PWD' => '****',
'SIGNATURE' => '****',
'BUTTONSOURCE' => 'Magento_Cart_Community',
'TIMESTAMP' => '2019-09-03T11:20:28Z',
'CORRELATIONID' => '403c3d4df0570',
'ACK' => 'Failure',
'VERSION' => '72.0',
'BUILD' => '53481737',
'L_ERRORCODE0' => '10413',
'L_SHORTMESSAGE0' => 'Transaction refused because of an invalid argument. See additional error messages for details.',
'L_LONGMESSAGE0' => 'The totals of the cart item amounts do not match order amounts.',
'L_SEVERITYCODE0' => 'Error',
Can anyone help me?
Best regards,
Leonel Nunes
so I'm trying to set a selected option in my form but I can't seem to find out how to do this. I've Googled around and everything seems to be for Symfony2 where default was a thing, this seems to be no longer the case for Symfony4.
I've tried using data and empty_data but both don't select the correct value..
# weirdly, setting to ['guru'] gets undefined index error,
# setting to $options doesn't error
->add('guru', EntityType::class, array(
'class' => User::class,
'choice_label' => 'username',
'data' => $options['guru']
))
and how I pass $options:
$form = $this->createForm(EditCategoryType::class, array('guru' => $guruName));
So with the help of #Juan I. Morales Pestana I found an answer, the only reason I've added the below as an answer rather than marking his as correct was because there seems to be a slight difference in how it works now..:
Controller now reads (Thanks to #Juan):
$category = $this->getDoctrine()->getRepository(Category::class)->find($id);
$category->setGuru($category->getGuru());
$form = $this->createForm(EditCategoryType::class, $category);
My EditCategoryType class:
->add('guru', EntityType::class, array(
'class' => User::class,
'choice_label' => 'username',
'mapped' => false,
'data' => $options['data']->getGuru()
))
updated twig template:
{{ form_widget(form.guru, { 'attr': {'class': 'form-control'} }) }}
<a href="{{ path('register_new', { idpackage: p.id }) }}" class="btn_packages">
//sends to form type the package id
$fromPackage = '';
if($request->query->get('idpackage')) {
$fromPackage = $request->query->get('idpackage');
}
$form = $this->createForm(RegisterFormType::class, $register, ['fromPackage' => $fromPackage]);
in formType set the param in options:
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Register::class,
'fromPackage' => null
]);
}
->add('package',EntityType::class, [
'label' => 'Select one item',
'class' => Package::class,
'choice_label' => function($package) {
return $package->getTitle() . ' | crédits : ' . $package->getAmount();
},
'attr' => ['class' => 'input-text', ],
'placeholder' => '...',
'required' => false,
'choice_attr' => function($package) use ($idFromPackage) {
$selected = false;
if($package->getId() == $idFromPackage) {
$selected = true;
}
return ['selected' => $selected];
},
])
$parentCategory = $categoryRepository->repository->find(2);
$category = new Category();
$category->setParentCategory(parentCategory);
$form = $this->createForm(CategoryType::class, $category);
we chose the predefined top category, it works if you use it this way.
try this :
empty_data documentation
As I said in my comments you are doing something wrong. I will explain all the process:
calling the form in the controller
$person = new Person();
$person->setName('My default name');
$form = $this->createForm('AppBundle\Form\PersonType', $person);
$form->handleRequest($request);
then the createForm function is executed here is the code
Symfony\Bundle\FrameworkBundle\Controller\ControllerTrait
protected function createForm($type, $data = null, array $options = array())
{
return $this->container->get('form.factory')->create($type, $data, $options);
}
As you can see the data or options are nos setted directly in the form, another function is called and then the form is created
This is the result when I make a dump inside the PersonType
PersonType.php on line 20:
array:35 [▼
"block_name" => null
"disabled" => false
"label" => null
"label_format" => null
"translation_domain" => null
"auto_initialize" => true
"trim" => true
"required" => true
"property_path" => null
"mapped" => true
"by_reference" => true
"inherit_data" => false
"compound" => true
"method" => "POST"
"action" => ""
"post_max_size_message" => "The uploaded file was too large. Please try to upload a smaller file."
"error_mapping" => []
"invalid_message" => "This value is not valid."
"invalid_message_parameters" => []
"allow_extra_fields" => false
"extra_fields_message" => "This form should not contain extra fields."
"csrf_protection" => true
"csrf_field_name" => "_token"
"csrf_message" => "The CSRF token is invalid. Please try to resubmit the form."
"csrf_token_manager" => CsrfTokenManager {#457 ▶}
"csrf_token_id" => null
"attr" => []
"data_class" => "AppBundle\Entity\Person"
"empty_data" => Closure {#480 ▶}
"error_bubbling" => true
"label_attr" => []
"upload_max_size_message" => Closure {#478 ▶}
"validation_groups" => null
"constraints" => []
"data" => Person {#407 ▼ // Here is the data!!!
-id: null
-name: "My default name"
-salary: null
-country: null
}
]
As you can see the data is indexed at data so that is the reason why you get an undefined index error
So the proper way is to set the entity value from the controller or use your form as a service and call the repository and set the value using the data option which has not changed since version 2. My point is that you are using the form wrong.
Please change your code.
Hope it help
EDITED IN THE SYMFONY 4 WAY(with out namespaces bundles)
Let's see please, I have a Person Entity with a name just for this example
The controller
$person = new Person(); //or $personsRepository->find('id from request')
$person->setName('My default name');
$form = $this->createForm(PersonType::class, $person);
$form->handleRequest($request);
The form
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name',TextType::class,[
//'data' => 'aaaaa' // <= this works too
]);
}
The options array value which proves that you are accessing wrong
PersonType.php on line 20:
array:35 [▼
"block_name" => null
"disabled" => false
"label" => null
"label_format" => null
"translation_domain" => null
"auto_initialize" => true
"trim" => true
"required" => true
"property_path" => null
"mapped" => true
"by_reference" => true
"inherit_data" => false
"compound" => true
"method" => "POST"
"action" => ""
"post_max_size_message" => "The uploaded file was too large. Please try to upload a smaller file."
"error_mapping" => []
"invalid_message" => "This value is not valid."
"invalid_message_parameters" => []
"allow_extra_fields" => false
"extra_fields_message" => "This form should not contain extra fields."
"csrf_protection" => true
"csrf_field_name" => "_token"
"csrf_message" => "The CSRF token is invalid. Please try to resubmit the form."
"csrf_token_manager" => CsrfTokenManager {#457 ▶}
"csrf_token_id" => null
"attr" => []
"empty_data" => Closure {#480 ▶}
"error_bubbling" => true
"label_attr" => []
"upload_max_size_message" => Closure {#478 ▶}
"validation_groups" => null
"constraints" => []
"data" => Person {#407 ▼
-id: null
-name: "My default name" //Here is the data
-salary: null
-country: null
}
]
AppBundle is just another folder in my folder structure. Be pleased to test your self. The second parameter to the formCreate function is the entity or data not the options you are thinking that the options is the data.
I have TYPO3 7.6.18 and I am making ajaxDispatcher. I stay on final study. I trying to call $this->bootstrap->run( '', $this->configuration ); but it get an error. I can't know what this error is exactly. But I'm sure problem in this line.
My $this->configuration is:
array(8) {
["pluginName"] => string(7) "Piphoto"
["vendorName"] => string(5) "Istar"
["extensionName"] => string(7) "feFiles"
["controller"] => string(5) "Photo"
["action"] => string(4) "test"
["mvc"] => array(1) {
["requestHandlers"] => array(1) {
["TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"] =>
string(48) "TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler"
}
}
["settings"] => array(2) {
["adminemail"] => string(15) "mvnaz#yandex.ru"
["pageShowPhotoId"] => string(2) "32"
}
["persistence"] => array(1) {
["storagePid"] => string(2) "31"
}
}
Action test is allowed in local_conf. The Vendor is set right, extension name, plugin and controller too.
Sorry)
["extensionName"]=>
string(7) "fefiles"
fefiles need Fefiles - uppercase!
Thank you all for help! )
I am trying to get information's user from my Facebook app.
I am using the OAuthUserProvider to get the response data :
array(10) { ["id"]=> string(17) "xxxx" ["first_name"]
=> string(6) "xx" ["gender"]
=> string(4) "male" ["last_name"]
=> string(6) "xx" ["link"]
=> string(62) "https://www.facebook.com/app_scoped_user_id/102xxxx4640725/" ["locale"]
=> string(5) "en_US" ["name"]
=> string(13) "xx xx" ["timezone"]
=> int(1) ["updated_time"]=> string(24) "2014-08-17T21:12:52+0000" ["verified"]
=> bool(true) }
It is missing the email and other information. The problem is from my app because when I use other apps it works well. Should I modify my app's setting to get that missed information?
How are you supposed to get the shipping info back from a Parallel Payment, using PayPal's Adaptive API system? Normally it would just get passed back as payer_country, etc - when the IPN script is requested. However, this doesn't seem to be the case.
Here are the params being passed in when the IPN script is called:
transaction[0].amount
transaction[0].id
verify_sign
transaction[1].receiver
reverse_all_parallel_payments_on_error
transaction[1].pending_reason
transaction[0].pending_reason
transaction[1].id_for_sender_txn
transaction[0].invoiceId
payment_request_date
test_ipn
cancel_url
charset
return_url
transaction[0].status_for_sender_txn
ipn_notification_url
transaction[1].is_primary_receiver
transaction[1].status
transaction_type
transaction[1].amount
transaction[0].status
log_default_shipping_address_in_transaction
transaction[0].receiver
status
transaction[0].id_for_sender_txn
action_type
fees_payer
pay_key
transaction[1].status_for_sender_txn
transaction[0].paymentType
transaction[1].invoiceId
transaction[1].id
sender_email
notify_version
transaction[1].paymentType
transaction[0].is_primary_receiver
If I then do a PaymentDetails API call, I get back stuff like:
$VAR1 = {
'currencyCode' => 'USD',
'responseEnvelope' => {
'correlationId' => '9944330ab9a8c',
'timestamp' => '2014-04-07T06:08:16.094-07:00',
'ack' => 'Success',
'build' => '10273932'
},
'status' => 'COMPLETED',
'senderEmail' => 'andy.aaaa#ultranerds.co.uk',
'cancelUrl' => 'http://somesite.net/paypal/cancel.html',
'paymentInfoList' => {
'paymentInfo' => [
{
'pendingRefund' => 'false',
'receiver' => {
'accountId' => 'NY3AD33DD739C',
'email' => 'andy-xxx#ultranerds.com',
'amount' => '65.00',
'invoiceId' => '1022',
'primary' => 'false',
'paymentType' => 'GOODS'
},
'transactionId' => '8E1114341X895213Y',
'senderTransactionStatus' => 'COMPLETED',
'senderTransactionId' => '5EV71352C33256006',
'transactionStatus' => 'COMPLETED',
'refundedAmount' => '0.00'
},
{
'pendingRefund' => 'false',
'receiver' => {
'accountId' => 'YYP5C69YWCMKE',
'email' => 'andy.yyy#gmail.com',
'amount' => '15.00',
'invoiceId' => '1023',
'primary' => 'false',
'paymentType' => 'GOODS'
},
'transactionId' => '68H86656UP574062X',
'senderTransactionStatus' => 'COMPLETED',
'senderTransactionId' => '2XW88939LK1112523',
'transactionStatus' => 'COMPLETED',
'refundedAmount' => '0.00'
}
]
},
'feesPayer' => 'EACHRECEIVER',
'actionType' => 'CREATE',
'ipnNotificationUrl' => 'http://somesite.net/paypal/test_ipn.cgi',
'sender' => {
'useCredentials' => 'false',
'accountId' => 'B74RBM5F6SLZG',
'email' => 'andy.aaa#ultranerds.co.uk'
},
'returnUrl' => 'http://somesite.net/paypal/success.html',
'payKey' => 'AP-4EK17906VB6613533',
'reverseAllParallelPaymentsOnError' => 'false'
};
As you can see, there is no reference to the delivery address at all. How are you supposed to get that info back?
UPDATE: Mmm ok, so it looks like GetShippingAddresses is what I need - but for some reason its coming back with nothing in when I call it:
{"requestEnvelope":{"errorLanguage":"en_US","detailLevel":"ReturnAll"},"key":"AP-1B1377463N9785350"} /GetShippingAddresses_API_Operation/
...simply returns:
{
'responseEnvelope' => {
'correlationId' => '3a4443aed09c9',
'timestamp' => '2014-04-07T06:40:35.460-07:00',
'ack' => 'Success',
'build' => '10273932'
}
}
I'm a bit baffled as to why its doing that. Any suggestions?
I found a quote here:
http://go.developer.ebay.com/devzone/articles/using-paypals-adaptive-payments-and-google-app-engine-build-online-market-python-part-3
Unfortunately, although this follows the process recommended by
PayPal's documentation, it doesn't work. There's currently a bug in
PayPal's Adaptive Payments implementation. For a traditional payment,
the shipping address is not collected; for embedded payments, the
GetShippingAddresses call does not return the shipping address.
PayPal has acknowledged the bug and indicated that it expects to have
this fixed in April 2011. If you need shipping addresses right now,
the recommendation is to collect them on your site rather than relying
on the PayPal API.
That was from 2011... but is this still the case??
Sorry to bump - but has anyone got any suggestions?
Ok, well I got my answer - but unfortunately its not what I was hoping for:
Yes, unfortunately this feature is only available for embedded payment
flow.
https://developer.paypal.com/webapps/developer/docs/classic/adaptive-payments/ht_ap-embeddedPayment-curl-etc/
If you're using embedded payment flow, then you can retrieve the
address on their PayPal account by passing in
senderOptions.requireShippingAddressSelection = true during
SetPaymentOption API call. You can then retrieve it via
GetShippingAddresses API call.
So it looks like really what I need to do, is ask the user to provide their shipping information BEFORE sending them to paypal, then storing it. Not ideal - but I guess you just have to work with what you got!