Payment to the user using Paypal and Swift

Asked

Viewed 348 times

2

I’ve been trying for days to find an example of Swift code needed to execute a payment to the user.

Paypal’s development guide does not contain Swift syntax and every attempt I made to translate from other languages was unsuccessful.

1 answer

1


According to the Paypal public repository on github you cannot do operation of Pagamento(Payout) directly via the iOS SDK:

The SDK Supports two use cases for making Payments - Single Payment and Future Payments - and a third use case for obtaining information about the Customer - Profile Sharing.

To do this type of operation you will have to implement your backend code using one of Paypal’s Apis:

C# | JAVA | Node.js | PHP | Python | Ruby

and then communicate with your backend through the app, for example, using the default REST API


Here’s an example of how to use the Ruby API to make a payout:

require 'paypal-sdk-rest'
require 'securerandom'
require './runner.rb'

include PayPal::SDK::REST
include PayPal::SDK::Core::Logging

@payout = Payout.new({
                         :sender_batch_header => {
                             :sender_batch_id => SecureRandom.hex(8),
                             :email_subject => 'You have a Payout!'
                         },
                         :items => [
                             {
                                 :recipient_type => 'EMAIL',
                                 :amount => {
                                     :value => '12.34', # valor com até 2 casas decimais representada como string
                                     :currency => 'USD' # código da moeda de 3 letras
                                 },
                                 :note => 'Thanks for your patronage!', # observação para as notificações. A observação é fornecida pelo emissor do pagamento.
                                 :sender_item_id => '2014031400023', # um número de identificação específico do remetente, pode ser usado em um sistema de contabilidade para fins de rastreamento.
                                 :receiver => '[email protected]' # o recebedor do pagamento.
                             }
                         ]
                     })
begin
  @payout_batch = @payout.create
  logger.info "Created Payout with [#{@payout_batch.batch_header.payout_batch_id}]"
rescue ResourceNotFound => err
  logger.error @payout.error.inspect
end

Remembering that: To use Payments, you must request access through your account page. Alternatively, contact your Paypal Account Manager or Customer Support. You must have a Paypal business account.

  • 1

    Can you complete the answer by adding an example of this link and some explanation in English? So the answer would be much better.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.